C++ WM_NCCALCSIZE 未发送 [英] C++ WM_NCCALCSIZE not being sent
问题描述
我试图将编辑控件中的文本垂直居中,经过一些研究,我发现我必须处理 WM_NCCALCSIZE 消息.所以我已经子类化了我的编辑控件,但 WM_NCCALCSIZE 消息从未发送过.
我做错了什么吗?
所以我正在很好地处理 WM_NCCALCSIZE
消息,并且我通过将 WS_EX_CLIENTEDGE
传递给 CreateWindowEx
创建了一个 3d 边框.但是,如果我通过终止主题服务来禁用 Windows 主题,则处理 WM_NCCALCSIZE
消息的控件上的边框会消失.另一个不处理 WM_NCCALCSIZE
消息的控件仍然具有正常的边框.
所以我假设我应该在 WM_NCCALCSIZE
中做一些事情来让我保持边界?如果是什么?如果没有办法恢复边界?
想通了,WM_NCCALCSIZE
在编辑控件被子类化之前发送.
所以我必须超类 EDIT
类.
我刚刚想到的另一个解决方案是对其进行子类化,然后使用 SWP_FRAMECHANGED
调用 SetWindowPos
,这会导致它发送 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.
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?
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 :)
这篇关于C++ WM_NCCALCSIZE 未发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!