Custom title bar
-
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 wantDefWindowProc()
to handle most of the functionality, but it is really messing things up. When the close button is clicked aWM_NCLBUTTONDOWN
message is sent. If I handle this and return 0, aWM_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 allowDefWindowProc()
to handle the message, the window can be resized but aWM_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 thatDefWindowProc()
will send the appropriateWM_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. -
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 wantDefWindowProc()
to handle most of the functionality, but it is really messing things up. When the close button is clicked aWM_NCLBUTTONDOWN
message is sent. If I handle this and return 0, aWM_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 allowDefWindowProc()
to handle the message, the window can be resized but aWM_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 thatDefWindowProc()
will send the appropriateWM_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.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 returnHTCLOSE
.
Owner drawn Jesus Loves
-
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 returnHTCLOSE
.
Owner drawn Jesus Loves
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 correctHT...
code and thatDefWindowProc()
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. -
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 correctHT...
code and thatDefWindowProc()
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.Just an update incase of others with similar problems. I can't be sure, but I have a strong feeling that when
DefWindowProc()
handles theWM_NCLBUTTONDOWN
messages it goes into aGetMessage
loop after a call toSetCapture()
, within this loopDefWindowProc()
calls it's ownWM_NCHITTEST
handler rather than sending a message to call the users handler. Since it's impossible forDefWindowProc()
to know where the new HitTest regions are, it will never work. The only solution is to handle allWM_NCLBUTTONDOWN
messages yourself.