How to change the Background Color of a Date Time Picker Control?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11

Thread: How to change the Background Color of a Date Time Picker Control?

Hybrid View

  1. #1
    Join Date
    Jan 2001
    Posts
    39

    How to change the Background Color of a Date Time Picker Control?

    Hi,
    How can I change the Background Color of a Date Time Picker Control?



  2. #2
    Join Date
    Oct 2000
    Location
    India
    Posts
    4,620

    Re: How to change the Background Color of a Date Time Picker Control?

    Hi,

    Take a look at http://www.codeguru.com/controls/dat..._picker3.shtml . Is this what you are looking for ?

    [b]Let me know if that helped.
    Visit http://www.geocities.com/contactgirish/homepage.html for some VC++ Links & Notes.If you have time, you can sign the guest book there.
    Regards,
    V.Girish
    All luck and have a great day.

    Regards,
    V.Girish

    Visit www.geocities.com/contactgirish for Source code, Tutorials, FAQs and Downloads.

  3. #3
    Join Date
    Jan 2001
    Posts
    39

    Re: How to change the Background Color of a Date Time Picker Control?

    No,
    I don't want to change the background color of the droped down control.
    Thanx anyway.



  4. #4
    Join Date
    Apr 2001
    Location
    Turkmenistan
    Posts
    674

    Re: How to change the Background Color of a Date Time Picker Control?

    override the: (WM_CTLCONTROL)

    HBRUSH CDateTimePicker::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
    {
    //change the color
    }


  5. #5
    Join Date
    Jan 2001
    Posts
    39

    Re: How to change the Background Color of a Date Time Picker Control?

    Hi,
    I think the message you mean is the WM_CTLCOLOR. I could not find any WM_CTLCONTROL message.
    Anyway I can't test it right now (I will in 8 hours) but the documentation doesn’t mention anything about DateTimePicker control, are you sure that this will work?



  6. #6
    Join Date
    Apr 2001
    Location
    Turkmenistan
    Posts
    674

    Re: How to change the Background Color of a Date Time Picker Control?

    Yes, you are right, it is WM_CTLCOLOR. I was mistaken, because I was in hurry.
    What about my hint, it sholud work because I used this overridable several times within CDialog, it worked. Since DateTimePicker is an object of CDateTimeCtrl class which is derived from CWnd as CDialog, HBRUSH CDlgDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) should work. The only thing you gotta do is to create a new class derived from CDateTimeCtrl and manually override HBRUSH CDlgDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor).

    Let me know if it works.
    Bayram.


  7. #7
    Join Date
    Jan 2001
    Posts
    39

    Re: How to change the Background Color of a Date Time Picker Control?

    Unfortunately it does not work. The control does not send any WM_CTLCOLOR message. I've tried MFC or plain Win32 API but the result is the same. I guess there is no way to change the background color this way.
    Any ideas?



  8. #8
    Join Date
    Jan 2001
    Posts
    39

    Re: How to change the Background Color of a Date Time Picker Control?

    I've just saw another post with the same issue and they say that the answer is caching the WM_ERASEBKGND message. I don't know if this is true (I will test it in about 7 hours) but I can't believe it was that simple and I never think of it before.
    I will let you know.



  9. #9
    Join Date
    Apr 2001
    Location
    Turkmenistan
    Posts
    674

    Re: How to change the Background Color of a Date Time Picker Control?

    Hi there, how are you going on with the DateTimePicker? Have you got any result?
    After some struggle I have had some result. As you know DTP has two windows: first is main which looks like CEdit ctrl and another one is MonthCalendar. I dealt with the first. I want to send you the project (zip), but I do not know your e-mail address.
    Reply.
    Regard!
    Brm.


  10. #10
    Join Date
    Jan 2001
    Posts
    39

    Re: How to change the Background Color of a Date Time Picker Control?

    No need to send me anything, it works with WM_ERASEBKGND. I can't believe it was that simple and I did't think of it before.
    Thanx for your time. Bye!


  11. #11
    Join Date
    Oct 2012
    Posts
    1

    Exclamation Re: How to change the Background Color of a Date Time Picker Control?

    Hello

    I have read all the thread , my task is similar to change the color of Dropdown of timepicker in MFC.By Erasebackground i got achieved to color the background of the dropdown control, how to change the color of text,

    Anybody have any ideas


    thanks in advance

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center