Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possibly better way of calculating maximized client rectangle #3

Open
avocadoboi opened this issue Nov 2, 2019 · 2 comments
Open

Comments

@avocadoboi
Copy link

avocadoboi commented Nov 2, 2019

Hello! Thank you for this example, it helped me a lot.

After experimenting a bit, I think I found a better way of calculating the bounding rectangle of the non-client area in WM_NCCALCSIZE. Firstly, add the WS_MAXIMIZEBOX style flag to the window. This enables it to maximize when dragging it towards an edge of the monitor (size snapping), but it also makes the bottom of the window not get obscured by the taskbar. This makes the hacky solution with has_autohide_appbar unnecessary (the shell won't make it full-screen).

In my WM_NCCALCSIZE message, I then just do this:

auto const parameters = reinterpret_cast<NCCALCSIZE_PARAMS*>(p_data_b);

if (IsMaximized(m_windowHandle)) {
	auto info = MONITORINFO{};
	info.cbSize = sizeof(MONITORINFO);
	GetMonitorInfo(MonitorFromRect(parameters->rgrc, MONITOR_DEFAULTTONEAREST), &info);

	parameters->rgrc[0] = info.rcWork;
}

return 0;

to properly fit the client area.

Hope this could help anyone.

@semihartan
Copy link

Do you add the WS_MAXIMIZEBOX style on WM_NCCALCSIZE handler or on the call to CreateWindowEx?

@avocadoboi
Copy link
Author

Just on the call to CreateWindowEx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants