MCPcopy Create free account
hub / github.com/bumptop/BumpTop / SetWindowState

Method SetWindowState

trunk/win/Source/BT_WindowsOS.cpp:4167–4269  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4165}
4166
4167void WindowsSystem::SetWindowState(WindowState newWindowState)
4168{
4169 const LONG borderedWStyle = WS_CAPTION | WS_SYSMENU | WS_SIZEBOX | WS_MAXIMIZEBOX | WS_MINIMIZEBOX;
4170 const LONG borderedWExStyle = WS_EX_APPWINDOW;
4171 const LONG noBorderedWExStyle = WS_EX_TOOLWINDOW;
4172
4173 LONG wStyle = GetWindowLong(windowHwnd, GWL_STYLE);
4174 LONG wExStyle = GetWindowLong(windowHwnd, GWL_EXSTYLE);
4175
4176 if (windowState == ShellExt)
4177 {
4178 assert(false); // shell extension windows shouldn't be changing state
4179 return;
4180 }
4181
4182 switch(newWindowState)
4183 {
4184 case ShellExt:
4185 assert(false); // unimplemented; no need for this
4186 break;
4187 case Windowed:
4188 if (windowState == WorkArea)
4189 {
4190 SetParent(windowHwnd, NULL); // make top-level window
4191 winOS->desktopLock->unlock();
4192 }
4193 // enable the bordered window
4194 SetWindowLong(windowHwnd, GWL_STYLE, ((wStyle | borderedWStyle) & ~WS_POPUP) & ~WS_CHILD);
4195 SetWindowLong(windowHwnd, GWL_EXSTYLE, ((wExStyle | borderedWExStyle) & ~noBorderedWExStyle));
4196 SetWindowPos(windowHwnd, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_SHOWWINDOW); // flush the changes
4197
4198 SetWindowPos(windowHwnd, NULL,
4199 prevWindowedRect.left, prevWindowedRect.top, // prevWindowedRect is set in the constructor
4200 prevWindowedRect.right - prevWindowedRect.left, // to the default window size
4201 prevWindowedRect.bottom - prevWindowedRect.top,
4202 SWP_NOZORDER);
4203
4204 // if we're in "show desktop" mode, we won't see our window unless we activate it
4205 SetForegroundWindow(windowHwnd);
4206 windowState = Windowed;
4207 break;
4208 case FullWindow:
4209 if (windowState == WorkArea)
4210 {
4211 SetParent(windowHwnd, NULL); // make top-level window
4212 winOS->desktopLock->unlock();
4213 }
4214 // enable the bordered window
4215 SetWindowLong(windowHwnd, GWL_STYLE, ((wStyle | borderedWStyle) & ~WS_POPUP) & ~WS_CHILD);
4216 SetWindowLong(windowHwnd, GWL_EXSTYLE, ((wExStyle | borderedWExStyle) & ~noBorderedWExStyle));
4217 SetWindowPos(windowHwnd, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_SHOWWINDOW); // flush the changes
4218
4219 ShowWindow(windowHwnd, SW_SHOWMAXIMIZED);
4220
4221 // if we're in "show desktop" mode, we won't see our window unless we activate it
4222 SetForegroundWindow(windowHwnd);
4223 windowState = FullWindow;
4224 break;

Callers 1

Calls 5

attachToDesktopWindowMethod · 0.95
assertClass · 0.85
SetParentFunction · 0.50
unlockMethod · 0.45
tryLockMethod · 0.45

Tested by

no test coverage detected