Skip to main content
GameDev.net gamedev.net
🔒 Locked

[Win32] "Custom" resize box

Started by ak09 May 11, 2013 at 6:32 PM 4 replies 2k views
Original Post
ak09
ak09

Ok, so I have a rectangle drawn on my screen (via OpenGL), and I want to make it resizable — just like the standard resize box of all windows.
Is there a simple way, other than checking mannualy if mouse position is here or there and changing cursor again and again , to do it?

ak09
ak09

Handle the WM_NCHITTEST message and return HTSIZE when the cursor overlaps the rectangle.


The rectangle I mentioned represents a layer on wich my stuff will be drawn.
But I'm dealing with several layers. So, doesn't your suggestion implies in making HWND's of my layers?

ApochPiQ
ApochPiQ
All you should have to do is handle that message in the parent window and convert the coordinates provided so they can be tested against your rectangle. It doesn't need to have its own HWND and indeed giving it it's own HWND wouldn't enable it to get WM_NCHITTEST (that's only for the parent/container window itself, not child windows).
ak09
ak09

I got it, but returning HTSIZE when mouse is over my area just makes it freeze.
This is what I get:


    case WM_NCHITTEST:
        if (onArea(LOWORD(lParam), HIWORD(lParam))
            return HTSIZE;
        return DefWindowProc(hWnd, msg, wParam, lParam);
 
ak09
ak09

Solved!
Instead of HTSIZE I return now HTBOTTOMRIGHT.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.