Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Feb 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    win32\C++: Modify dialogbar's color

    Given a window's HWND, is there a way to programatically change the color of the dialogbar (the top horizontal bar that has the app title, and the minimize, maximize, and kill buttons)? I can get it's CWnd object executing CWnd::FromWindowHandle(), and muck around there, but apart from changing text properties and size/position I haven't found anything close to what I want to do.

    Thanks!

  • #2
    New Coder
    Join Date
    Nov 2004
    Location
    Netherlands
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I think you can catch the WM_NCPAINT and WM_NCACTIVATE messages. Here are two articles about it, if these help at all.
    http://www.codeproject.com/dialog/gradienttitlebar.asp
    http://www.codeproject.com/dialog/dl...&select=783987

  • #3
    Senior Coder Mhtml's Avatar
    Join Date
    Jun 2002
    Location
    Sydney, Australia
    Posts
    3,531
    Thanks
    0
    Thanked 1 Time in 1 Post
    Didn't read those links, so they probably mention this but I'll say it anyway.

    Catch the WM_NCPAINT (NC is the non client area).
    Code:
    case WM_NCPAINT: {
      DefWindowProc( hwnd, msg, wParam, lParam );
      return paintNonClientArea( hwnd, (HRGN)wParam );
    }
    If you don't call DefWindowProc() it will paint over your modifications, I don't know why, the windows documentation contradicts itself on this if I remember correctly.. so it's obviously an algorithm problem on the API side. So what you're doing is painting over their own paint job, slightly slower I guess but it's the only way until we can move to avalon.

    Make sure to release the DC.

    [edit:] Just noticed you're using MFC. I hate that bloated shemozzle of a library so I wouldn't know if the above code chunk is suitable.
    Last edited by Mhtml; 02-13-2005 at 03:03 PM.
    Omnis mico antequam dominus Spookster!


  •  

    Posting Permissions

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