Skip to content

Possibly better way of calculating maximized client rectangle #3

Description

@avocadoboi

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions