Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ WM_NCCALCSIZE not being sent

I'm trying to center the text in a edit control vertically, after some research I found I have to process the WM_NCCALCSIZE message. So i've subclassed my edit control, but the WM_NCCALCSIZE message is never sent.

Am I doing something wrong?

EDIT:

So i'm processing the WM_NCCALCSIZE message fine, and I have a 3d border created by passing WS_EX_CLIENTEDGE to CreateWindowEx. But if I disable windows themes by killing the theme service, the border goes away on the control thats processing the WM_NCCALCSIZE message. Another control that doesnt process the WM_NCCALCSIZE message still has the border like normal.

So i'm assuming I'm supposed to be doing somethign in WM_NCCALCSIZE that allows me to keep the border? If so what? if not any way to get the border back?

like image 220
Josh Avatar asked Jan 17 '26 20:01

Josh


2 Answers

Figured it out, WM_NCCALCSIZE is sent before the edit control is subclassed.
So i had to superclass the EDIT class.

EDIT:
Another solution I just thought of would be to subclass it, then call SetWindowPos with SWP_FRAMECHANGED, this causes it to send the WM_NCCALCSIZE message.

If anyone has any opinions why one method would be better then the other, please comment :)

like image 75
Josh Avatar answered Jan 20 '26 10:01

Josh


Instead of tinkering with WM_NCCALCSIZE (a very difficult message to manage), why not just reposition your edit control vertically so that the text is at the vertical position you prefer? You can put it inside a white box to provide the white space around it. Alternatively, you can use EM_SETRECT to put the text exactly where you want it.

like image 30
Raymond Chen Avatar answered Jan 20 '26 11:01

Raymond Chen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!