Please help make this code more cleaner. It's a part of window procedure that notifies my renderer before client area of window resized.
I need to check two combinations of bit blags: some of them must be set, and some must be not. How to do it without bunch of temp variables? (and probably calculate only 2 possible states and only once, not every call)
Thanks!
LRESULT CALLBACK MSWindow::Impl::WndProc( HWND hWnd, uint msg, WPARAM wParam, LPARAM lParam )
{
switch( msg )
{
// ...
// WM_WINDOWPOSCHANGING is sent just about window position, size or order changed.
case WM_WINDOWPOSCHANGING:
{
const WINDOWPOS* wp = ((WINDOWPOS*)lParam);
const auto& flags = wp->flags;
const bool NOCOPYBITS = (flags & SWP_NOCOPYBITS) > 0;
const bool NOSIZE = (flags & SWP_NOSIZE) > 0;
const bool FRAMECHANGED = (flags & SWP_FRAMECHANGED) > 0;
const bool NOOWNERZORDER = (flags & SWP_NOOWNERZORDER) > 0;
const bool NOZORDER = (flags & SWP_NOZORDER) > 0;
const bool NOACTIVATE = (flags & SWP_NOACTIVATE) > 0;
const bool SHOWWINDOW = (flags & SWP_SHOWWINDOW) > 0;
const bool IsResizingAboutToEnd = !(NOSIZE) && NOOWNERZORDER && NOZORDER && (!NOACTIVATE);
const bool IsGoingToMaximizeOrRestore = FRAMECHANGED && (!NOACTIVATE) && (!NOCOPYBITS) && (!SHOWWINDOW);
if ( IsGoingToMaximizeOrRestore || IsResizingAboutToEnd )
{
Resize(Point(wp->cx, wp->cy));
}
break;
}
// .....
}