Pregunta

I have created window with following properties:

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
        }

I am sending SC_SIZE message using following code :

::DefWindowProc(this->GetSafeHwnd(),WM_SYSCOMMAND, SC_SIZE + Val ,MAKELPARAM(point.x ,point.y));

where value depends on TOP, LEFTTOP, RIGHTBOTTOM ...

For resizing window, I grab the window from any corner or any side and drag it.

I have created window in thread and its loop is like this :

while( (bRet = GetMessage( &WndMsg, NULL, 0, 0 )) != 0)
        { 
            if (bRet != -1)
            {
                TranslateMessage( &WndMsg ); 
                if ( WM_CLOSE == WndMsg.message )
                {
                    PostQuitMessage( 0 );
                }
                DispatchMessage ( &WndMsg ); 
            }
        }

I have see the messages that window is getting using spy++. This is the log( I am sorry I don't know how to attach file on SO so posting logs here).

<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

I observed from log that I am getting WM_WINDOWPOSCHANGING only after I release the mouse.

Odd behaviour: I have set breakpoints and debug, then it sometimes starts working without any changes.

¿Fue útil?

Solución 2

SetForegroundWindow() worked for me. Thanks for all replies.

Otros consejos

Use SetWindowPos to change the size of the window. You have much more control over how the window will be updated.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top