Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Custom title bar

Custom title bar

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    Waldermort
    wrote on last edited by
    #1

    I have created a custom window in which all the non-client area is redefined. I have custom borders, a custom title bar and custom min/max/close buttons. For the most part everything is working as I want, but I'm having some serious trouble handling button clicks. I handle the WM_NCHITTEST returning the appropriate code for the new window area. I want DefWindowProc() to handle most of the functionality, but it is really messing things up. When the close button is clicked a WM_NCLBUTTONDOWN message is sent. If I handle this and return 0, a WM_NCLBUTTONUP message is sent (if a button was clicked), but the window is unable to be resized, also the window does not close. If I allow DefWindowProc() to handle the message, the window can be resized but a WM_NCLBUTTONUP message is never sent, again nothing happens when clicking the button. I have tried using spy++ to monitor messages of other windows behaviour, but I cannot see much difference. From the docs, I read that DefWindowProc() will send the appropriate WM_SYSCOMMAND message, but I can't understand why it is not working within my code. Does anybody have an idea what I am doing wrong, what I am missing or not handling correctly? Also, is there any way to see the code for DefWindowProc() (possibly a unix/wine variant) to help me understand what is happening behind the scenes.

    O 1 Reply Last reply
    0
    • W Waldermort

      I have created a custom window in which all the non-client area is redefined. I have custom borders, a custom title bar and custom min/max/close buttons. For the most part everything is working as I want, but I'm having some serious trouble handling button clicks. I handle the WM_NCHITTEST returning the appropriate code for the new window area. I want DefWindowProc() to handle most of the functionality, but it is really messing things up. When the close button is clicked a WM_NCLBUTTONDOWN message is sent. If I handle this and return 0, a WM_NCLBUTTONUP message is sent (if a button was clicked), but the window is unable to be resized, also the window does not close. If I allow DefWindowProc() to handle the message, the window can be resized but a WM_NCLBUTTONUP message is never sent, again nothing happens when clicking the button. I have tried using spy++ to monitor messages of other windows behaviour, but I cannot see much difference. From the docs, I read that DefWindowProc() will send the appropriate WM_SYSCOMMAND message, but I can't understand why it is not working within my code. Does anybody have an idea what I am doing wrong, what I am missing or not handling correctly? Also, is there any way to see the code for DefWindowProc() (possibly a unix/wine variant) to help me understand what is happening behind the scenes.

      O Offline
      O Offline
      Owner drawn
      wrote on last edited by
      #2

      Please look up the docs with the following keywords HTCLOSE, HTMAXBUTTON, HTMINBUTTON.... WM_NCHITTEST should return appropriate values based your non client area design. For example clicking on close button, you should try to find out if the mouse pointer is inside the close button area, if it is then you should return HTCLOSE.


      Owner drawn Jesus Loves

      W 1 Reply Last reply
      0
      • O Owner drawn

        Please look up the docs with the following keywords HTCLOSE, HTMAXBUTTON, HTMINBUTTON.... WM_NCHITTEST should return appropriate values based your non client area design. For example clicking on close button, you should try to find out if the mouse pointer is inside the close button area, if it is then you should return HTCLOSE.


        Owner drawn Jesus Loves

        W Offline
        W Offline
        Waldermort
        wrote on last edited by
        #3

        In the opening thread I did state that I handle the WM_NCHITTEST message and return the appropriate value. This is not the cause of the problem since I am correctly returng a value for the min/max/close buttons aswell as the correct value for the border positions. Also, I should note that from the buttonup/down handlers, I can see that the wparam is correctly initialized with the correct HT... code and that DefWindowProc() is also being called with the correct wParam (the hit test value) and lParam (the mouse position). The problem is that somewhere DefWindowProc() is doing something and getting an incorrect value. The trouble is I don't know what other message, if any, I should be handling.

        W 1 Reply Last reply
        0
        • W Waldermort

          In the opening thread I did state that I handle the WM_NCHITTEST message and return the appropriate value. This is not the cause of the problem since I am correctly returng a value for the min/max/close buttons aswell as the correct value for the border positions. Also, I should note that from the buttonup/down handlers, I can see that the wparam is correctly initialized with the correct HT... code and that DefWindowProc() is also being called with the correct wParam (the hit test value) and lParam (the mouse position). The problem is that somewhere DefWindowProc() is doing something and getting an incorrect value. The trouble is I don't know what other message, if any, I should be handling.

          W Offline
          W Offline
          Waldermort
          wrote on last edited by
          #4

          Just an update incase of others with similar problems. I can't be sure, but I have a strong feeling that when DefWindowProc() handles the WM_NCLBUTTONDOWN messages it goes into a GetMessage loop after a call to SetCapture(), within this loop DefWindowProc() calls it's own WM_NCHITTEST handler rather than sending a message to call the users handler. Since it's impossible for DefWindowProc() to know where the new HitTest regions are, it will never work. The only solution is to handle all WM_NCLBUTTONDOWN messages yourself.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups