1
votes

Is there a way (API) of getting the size (vertical and horizontal) in pixels of the resize corners?

I am referring to the area at each of the corners of a window where you can resize the window in both directions (Left-to-Right and Top-to-Bottom) at the same time using your mouse. You will know you are there with your mouse cursor when you hover over the corners of the window and the mouse cursor is a Diagonal Resizing cursor.

Thank you

Edit: An example: Hover your mouse over the right edge of a sizable window. Start in the middle (vertically) of the window and move the mouse up along the edge until the horizontal sizing cursor changes to a diagonal sizing cursor. How do I determine by asking the OS how far that position when the cursor changes, is from the top of the window.

2
What is the underlying problem that made you come up with the solution of "I need to get the resize border pixel size"? Are you trying to capture resize events, and isn't there a different (read: easier) way to do that?CodeCaster
It is baked in the default window procedure if the app doesn't override the WM_NCHITTEST processing. On Win8 it looks like 2x the border height and 1x the border width. The real border size, not the one that Aero lies.Hans Passant
@CodeCaster. I want to simulate the behaviour of top-level windows inside a window with controls that I create. I want them to have the exact same behaviour when it comes to resizing and I do not want to try and get the info from an existing window. I prefer to get the size from some API or combined API calls. That is why I asked this question.Blurry Sterk
@Hans. I am struggling to understand exactly what you mean by "It is baked in the default window procedure". Is it something that I can intercept or read in some way? "looks like 2x the border height and 1x the border width"... In Win7 it also does seem so but it stays the same even if the borderwidth (SM_CYSIZEFRAME) is changed.Blurry Sterk
@BlurrySterk: Your comment "I do not want to get the info from an existing window" is entirely contradictory to the question you asked. Perhaps you should ask a new question.Ben Voigt

2 Answers

2
votes

I would suggest to use the size of the scrollbars. Call GetSystemMetrics with SM_CYHSCROLL and SM_CXVSCROLL. May be also SM_CYSIZEFRAME and SM_CXSIZEFRAME sizes can be combined.

But I think a better value is to use the height of the status bar. However even Microsoft Windows seems to use some fixed value as can seen on the screenshot.

enter image description here

1
votes

Comparing the results of GetClientRect and GetWindowRect will tell you how wide the non-client (border) area is along each edge of the window.

If you're concerned that it might not all be active for sizing (true especially along the top), or you want to distinguish the diagonal sizing areas from edge sizing areas, you can take the coordinates discovered in step 1 and pass them to SendMessage(WM_NCHITTEST) See its documentation for the various return codes. There's no problem sending this message repeatedly -- it's designed to be called for each mouse move event and therefore is very fast.