C ++ WM_NCCALCSIZE未发送 [英] C++ WM_NCCALCSIZE not being sent
问题描述
经过一些研究,我发现我必须处理WM_NCCALCSIZE消息,因此我试图将文本垂直放置在编辑控件中. 因此,我将编辑控件归为子类,但是WM_NCCALCSIZE消息从未发送.
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.
我做错什么了吗?
所以我正在很好地处理WM_NCCALCSIZE
消息,并且我通过将WS_EX_CLIENTEDGE
传递给CreateWindowEx
创建了3d边框.
但是,如果我通过杀死主题服务禁用Windows主题,则处理WM_NCCALCSIZE
消息的控件上的边框将消失.
另一个不处理WM_NCCALCSIZE
消息的控件仍然具有正常的边框.
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.
所以我假设我应该在WM_NCCALCSIZE
中做些什么让我保持边界?如果是这样,该怎么办?如果没有任何办法找回边界?
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?
推荐答案
弄清楚了,WM_NCCALCSIZE
是在子类化编辑控件之前发送的.
所以我不得不超类EDIT
类.
Figured it out, WM_NCCALCSIZE
is sent before the edit control is subclassed.
So i had to superclass the EDIT
class.
我刚刚想到的另一种解决方案是将其子类化,然后用SWP_FRAMECHANGED
调用SetWindowPos
,这将导致其发送WM_NCCALCSIZE
消息.
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 :)
这篇关于C ++ WM_NCCALCSIZE未发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!