Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set exact client size for overlapped window? (winapi)

I want to set anexact client size (say 300 x 300) when I create a normal 'overlapped' window.

There is the AdjustWindowRectEx() function where I can pass the desired client area and get sizes that I can pass to CreateWindowEx but it says in the documentation that I should not use it for overlapped windows and I do not understand why.

When I pass 300 x 300, I got 306 x 326 from it, and when I receive WM_SIZE, the client size is 298 x 298 so it is 2 pixels too small.

How to create overlapped window with exact given client size?

like image 780
grunge fightr Avatar asked Oct 22 '25 06:10

grunge fightr


1 Answers

My mistake in my case was the following:

AdjustWindowRectEx(&rect, WS_OVERLAPPEDWINDOW, WS_CLIPSIBLINGS, FALSE, WS_OVERLAPPEDWINDOW);

Changing to this fixes it:

AdjustWindowRectEx(&rect, WS_OVERLAPPEDWINDOW, WS_CLIPSIBLINGS, FALSE, 0);
like image 186
grunge fightr Avatar answered Oct 25 '25 06:10

grunge fightr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!