Jimmyt1988
Jimmyt1988

Reputation: 21126

What is the style to allow win api window to be resizeable?

I've been searching for a while now and I cannot find the answer or style i'm looking for.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms632600(v=vs.85).aspx

What is the flag that allows my window to be resizable.

I have this at the moment:

WNDCLASSEX wcex;
    wcex.cbSize = sizeof(WNDCLASSEX); 
    wcex.style= CS_HREDRAW | CS_VREDRAW;
    wcex.lpfnWndProc= (WNDPROC)WndProc;
    wcex.cbClsExtra= 0;
    wcex.cbWndExtra= 0;
    wcex.hInstance= hInstance;
    wcex.hIcon= 0;
    wcex.hCursor= LoadCursor(NULL, IDC_ARROW);
    wcex.hbrBackground= (HBRUSH)(COLOR_WINDOW+1);
    wcex.lpszMenuName= 0;
    wcex.lpszClassName= "bla";
    wcex.hIconSm= 0;

HWND hWnd = CreateWindow(
    "bla", 
    "bla", 
    WS_OVERLAPPEDWINDOW, 
    CW_USEDEFAULT, 
    CW_USEDEFAULT, 
    CW_USEDEFAULT, 
    CW_USEDEFAULT, 
    NULL, NULL, hInstance, NULL);

and my Proc is:

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message) 
    {
        case WM_SIZE:
            screenServer.OnScreenResize( LOWORD(lParam), HIWORD(lParam) );
        break;
        case WM_NCHITTEST:
            return HTCLIENT;
        break;
        case WM_MOUSEMOVE:
        {
            //SetCapture(hWnd);

            // Retrieve mouse screen position
            int x = ( short )LOWORD( lParam );
            int y = ( short )HIWORD( lParam );

            mouseServer.OnMouseMove( x, y );

            //ReleaseCapture();
        }
        break;
        case WM_RBUTTONDOWN:
            mouseServer.OnRightMouseDown();
        break;
        case WM_RBUTTONUP:
            mouseServer.OnRightMouseUp();
        break;
        case WM_LBUTTONDOWN:
            mouseServer.OnLeftMouseDown();
        break;
        case WM_LBUTTONUP:
            mouseServer.OnLeftMouseUp();
        break;
        case WM_DESTROY:
            PostQuitMessage( 0 );
        break;
        case WM_KEYDOWN:
        {
             //switch(wParam)
             //{
                // case 'ESC':
                //    // w key pressed
                // break;
                // default:
                //   break;
             //}
        }
        default:
            return DefWindowProc( hWnd, message, wParam, lParam );
    }

    return 0;
}

Upvotes: 1

Views: 1195

Answers (2)

David Heffernan
David Heffernan

Reputation: 612964

The windows style you are looking for is WS_THICKFRAME. Note that WS_OVERLAPPEDWINDOW includes WS_THICKFRAME so your window is already sizeable.

Your window procedure handling of WM_NCHITTEST is what is stopping the resizing from working. Remove that case from the switch statement and resizing should start working again.

Upvotes: 0

dudeguy
dudeguy

Reputation: 11

According to http://msdn.microsoft.com/en-us/library/windows/desktop/ms632600%28v=vs.85%29.aspx

WS_SIZEBOX 0x00040000L

The window has a sizing border. Same as the WS_THICKFRAME style.

WS_THICKFRAME 0x00040000L

The window has a sizing border. Same as the WS_SIZEBOX style.

Upvotes: 1

Related Questions