我创建了具有以下属性的窗口:
DWORD WindowStyle;
DWORD WindowExStyle;
WindowStyle = WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE;
WindowExStyle = WS_EX_TOPMOST | WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE;
if ( !CreateEx( WindowExStyle, m_WndClassName,
FUNCTION_PANEL_CAPTION, WindowStyle, 0, 0, 100, 100, NULL, NULL, 0 ) )
{
//handle failure
}
我正在使用以下代码发送 SC_SIZE 消息:
::DefWindowProc(this->GetSafeHwnd(),WM_SYSCOMMAND, SC_SIZE + Val ,MAKELPARAM(point.x ,point.y));
其中值取决于 TOP、LEFTTOP、RIGHTBOTTOM ...
对于调整窗口大小,我从任意角落或任意一侧抓取窗口并拖动它。
我在线程中创建了窗口,它的循环是这样的:
while( (bRet = GetMessage( &WndMsg, NULL, 0, 0 )) != 0)
{
if (bRet != -1)
{
TranslateMessage( &WndMsg );
if ( WM_CLOSE == WndMsg.message )
{
PostQuitMessage( 0 );
}
DispatchMessage ( &WndMsg );
}
}
我已经看到窗口使用 spy++ 收到的消息。这是日志(对不起,我不知道如何在 SO 上附加文件,所以在这里发布日志)。
<00027> 00030758 P WM_LBUTTONDOWN fwKeys:MK_LBUTTON xPos:2 yPos:526
<00028> 00030758 S WM_SYSCOMMAND uCmdType:SC_SIZE xPos:0 yPos:0 (used mnemonic)
<00029> 00030758 S WM_GETMINMAXINFO lpmmi:072FF064
<00030> 00030758 R WM_GETMINMAXINFO lpmmi:072FF064
<00031> 00030758 S WM_ENTERSIZEMOVE
<00032> 00030758 R WM_ENTERSIZEMOVE
<00033> 00030758 P WM_MOUSEMOVE fwKeys:MK_LBUTTON xPos:2 yPos:526
<00034> 00030758 S WM_SIZING fwSide:WMSZ_LEFT lprc:072FF07C
<00035> 00030758 R WM_SIZING fProcessed:False
<00036> 00030758 P WM_MOUSEMOVE fwKeys:MK_LBUTTON xPos:2 yPos:526
<00037> 00030758 S WM_SIZING fwSide:WMSZ_LEFT lprc:072FF07C
<00038> 00030758 R WM_SIZING fProcessed:False
<00039> 00030758 P WM_MOUSEMOVE fwKeys:MK_LBUTTON xPos:1 yPos:526
<00040> 00030758 S WM_SIZING fwSide:WMSZ_LEFT lprc:072FF07C
<00041> 00030758 R WM_SIZING fProcessed:False
<00042> 00030758 P WM_MOUSEMOVE fwKeys:MK_LBUTTON xPos:0 yPos:526
<00043> 00030758 S WM_SIZING fwSide:WMSZ_LEFT lprc:072FF07C
<00044> 00030758 R WM_SIZING fProcessed:False
<00045> 00030758 P WM_MOUSEMOVE fwKeys:MK_LBUTTON xPos:-2 yPos:526
<00046> 00030758 S WM_SIZING fwSide:WMSZ_LEFT lprc:072FF07C
<00047> 00030758 R WM_SIZING fProcessed:False
<00048> 00030758 P WM_MOUSEMOVE fwKeys:MK_LBUTTON xPos:-4 yPos:526
<00049> 00030758 S WM_SIZING fwSide:WMSZ_LEFT lprc:072FF07C
<00050> 00030758 R WM_SIZING fProcessed:False
<00051> 00030758 P WM_MOUSEMOVE fwKeys:MK_LBUTTON xPos:-5 yPos:526
<00052> 00030758 S WM_SIZING fwSide:WMSZ_LEFT lprc:072FF07C
<00053> 00030758 R WM_SIZING fProcessed:False
<00054> 00030758 P WM_MOUSEMOVE fwKeys:MK_LBUTTON xPos:-7 yPos:526
<00055> 00030758 S WM_SIZING fwSide:WMSZ_LEFT lprc:072FF07C
<00056> 00030758 R WM_SIZING fProcessed:False
<00057> 00030758 P WM_MOUSEMOVE fwKeys:MK_LBUTTON xPos:-10 yPos:526
<00058> 00030758 S WM_SIZING fwSide:WMSZ_LEFT lprc:072FF07C
<00059> 00030758 R WM_SIZING fProcessed:False
<00060> 00030758 P WM_MOUSEMOVE fwKeys:MK_LBUTTON xPos:-11 yPos:526
<00061> 00030758 S WM_SIZING fwSide:WMSZ_LEFT lprc:072FF07C
<00062> 00030758 R WM_SIZING fProcessed:False
<00063> 00030758 P WM_MOUSEMOVE fwKeys:MK_LBUTTON xPos:-12 yPos:526
<00064> 00030758 S WM_SIZING fwSide:WMSZ_LEFT lprc:072FF07C
<00065> 00030758 R WM_SIZING fProcessed:False
<00066> 00030758 P WM_MOUSEMOVE fwKeys:MK_LBUTTON xPos:-13 yPos:526
<00067> 00030758 S WM_SIZING fwSide:WMSZ_LEFT lprc:072FF07C
<00068> 00030758 R WM_SIZING fProcessed:False
<00069> 00030758 P WM_MOUSEMOVE fwKeys:MK_LBUTTON xPos:-14 yPos:526
<00070> 00030758 S WM_SIZING fwSide:WMSZ_LEFT lprc:072FF07C
<00071> 00030758 R WM_SIZING fProcessed:False
<00072> 00030758 P WM_MOUSEMOVE fwKeys:MK_LBUTTON xPos:-15 yPos:526
<00073> 00030758 S WM_SIZING fwSide:WMSZ_LEFT lprc:072FF07C
<00074> 00030758 R WM_SIZING fProcessed:False
<00075> 00030758 P WM_MOUSEMOVE fwKeys:MK_LBUTTON xPos:-16 yPos:526
<00076> 00030758 S WM_SIZING fwSide:WMSZ_LEFT lprc:072FF07C
<00077> 00030758 R WM_SIZING fProcessed:False
<00078> 00030758 P WM_MOUSEMOVE fwKeys:MK_LBUTTON xPos:-17 yPos:526
<00079> 00030758 S WM_SIZING fwSide:WMSZ_LEFT lprc:072FF07C
<00080> 00030758 R WM_SIZING fProcessed:False
<00081> 00030758 P WM_MOUSEMOVE fwKeys:MK_LBUTTON xPos:-18 yPos:526
<00082> 00030758 S WM_SIZING fwSide:WMSZ_LEFT lprc:072FF07C
<00083> 00030758 R WM_SIZING fProcessed:False
<00084> 00030758 P WM_MOUSEMOVE fwKeys:MK_LBUTTON xPos:-19 yPos:526
<00085> 00030758 S WM_SIZING fwSide:WMSZ_LEFT lprc:072FF07C
<00086> 00030758 R WM_SIZING fProcessed:False
<00087> 00030758 P WM_MOUSEMOVE fwKeys:MK_LBUTTON xPos:-20 yPos:526
<00088> 00030758 S WM_SIZING fwSide:WMSZ_LEFT lprc:072FF07C
<00089> 00030758 R WM_SIZING fProcessed:False
<00090> 00030758 P WM_MOUSEMOVE fwKeys:MK_LBUTTON xPos:-21 yPos:526
<00091> 00030758 S WM_SIZING fwSide:WMSZ_LEFT lprc:072FF07C
<00092> 00030758 R WM_SIZING fProcessed:False
<00133> 00030758 P WM_MOUSEMOVE fwKeys:MK_LBUTTON xPos:-35 yPos:528
<00134> 00030758 S WM_SIZING fwSide:WMSZ_LEFT lprc:072FF07C
<00135> 00030758 R WM_SIZING fProcessed:False
<00136> 00030758 P WM_MOUSEMOVE fwKeys:MK_LBUTTON xPos:-36 yPos:528
<00137> 00030758 S WM_SIZING fwSide:WMSZ_LEFT lprc:072FF07C
<00138> 00030758 R WM_SIZING fProcessed:False
<00139> 00030758 P WM_MOUSEMOVE fwKeys:MK_LBUTTON xPos:-36 yPos:529
<00140> 00030758 S WM_SIZING fwSide:WMSZ_LEFT lprc:072FF07C
<00141> 00030758 R WM_SIZING fProcessed:False
<00142> 00030758 P WM_LBUTTONUP fwKeys:0000 xPos:-36 yPos:529
<00143> 00030758 S WM_SIZING fwSide:WMSZ_LEFT lprc:072FF07C
<00144> 00030758 R WM_SIZING fProcessed:False
<00145> 00030758 S WM_CAPTURECHANGED hwndNewCapture:00000000
<00146> 00030758 R WM_CAPTURECHANGED
<00147> 00030758 S WM_WINDOWPOSCHANGING lpwp:072FF070
<00148> 00030758 R WM_WINDOWPOSCHANGING
<00149> 00030758 S WM_NCCALCSIZE fCalcValidRects:True lpncsp:072FF044
<00150> 00030758 R WM_NCCALCSIZE fuValidRect:0000 lpncsp:072FF044
<00151> 00030758 S WM_NCPAINT hrgn:00000001
<00152> 00030758 R WM_NCPAINT
<00153> 00030758 S WM_ERASEBKGND hdc:23010F40
<00154> 00030758 R WM_ERASEBKGND fErased:True
<00155> 00030758 S WM_WINDOWPOSCHANGED lpwp:072FF070
<00156> 00030758 S WM_MOVE xPos:1194 yPos:5
<00157> 00030758 R WM_MOVE
<00158> 00030758 S WM_SIZE fwSizeType:SIZE_RESTORED nWidth:102 nHeight:723
<00159> 00030758 R WM_SIZE
<00160> 00030758 R WM_WINDOWPOSCHANGED
<00161> 00030758 S WM_EXITSIZEMOVE
<00162> 00030758 R WM_EXITSIZEMOVE
<00163> 00030758 R WM_SYSCOMMAND
<00164> 00030758 S WM_NCHITTEST xPos:1196 yPos:534
<00165> 00030758 R WM_NCHITTEST nHittest:HTCLIENT
<00166> 00030758 S WM_SETCURSOR hwnd:00030758 nHittest:HTCLIENT wMouseMsg:WM_MOUSEMOVE
<00167> 00030758 R WM_SETCURSOR fHaltProcessing:True
<00168> 00030758 P WM_MOUSEMOVE fwKeys:0000 xPos:2 yPos:529
<00169> 00030758 P WM_MOUSELEAVE
<00170> 00030758 P WM_PAINT hdc:00000000
我从日志中观察到,只有在释放鼠标后我才会得到 WM_WINDOWPOSCHANGING。
奇怪的行为:我设置了断点并进行了调试,然后它有时会在没有任何更改的情况下开始工作。