Disabled windows (WinAPI)

Started by
6 comments, last by thre3dee 15 years, 9 months ago
Heya! When I'm running fullscreen (style: WS_POPUP), and press with Windowsbutton on my keyboard, the startmenu pops up, but the window is still drawn in the background. How can I disable my app when for example that button is used, alt-tab is pressed or - in windowed mode - the minimize button is pressed? Lots of thanks, - Stijn
What do I expect? A young man's quest to defeat an evil sorceror while discovering the truth of his origins. A plucky youngster attended by her brutish guardian. A powerful artifact which has been broken into a small number of artifactlets distributed around the world.What do I want? Fewer damn cliches. - Sneftel
Advertisement
The WM_ACTIVATE can tell you if your window is being deactivated or reactivated, is that what you're after?
Quote:Original post by jpetrie
The WM_ACTIVATE can tell you if your window is being deactivated or reactivated, is that what you're after?

That sounds like it. I'll have a look, thanks!

[EDIT]
Hmm...looks right, but how can I stop my window from being drawn? I tried ShowWindow(SW_HIDE), but that also removes the window from the taskbar.
What do I expect? A young man's quest to defeat an evil sorceror while discovering the truth of his origins. A plucky youngster attended by her brutish guardian. A powerful artifact which has been broken into a small number of artifactlets distributed around the world.What do I want? Fewer damn cliches. - Sneftel
Maybe you can minimize the application programatically
by calling:

BOOL ShowWindow(HWND hWnd, int nCmdShow);

nCmdShow should be SW_MINIMIZE.

hopefully this works.



Quote:
Hmm...looks right, but how can I stop my window from being drawn?

Well, you draw the window right? Set state when you become deactivated / minimized, and gate your rendering on that state as appropriate (for example, a boolean flag somewhere).

You shouldn't make the window vanish entirely based purely on activate/deactivate, as this will be extremely jarring for users -- making any other window have the focus will hide your window, which is poor user experience. You can listen for Windows messages that tell you you're being minimized and disable your rendering there, as it makes little sense to actually draw when you are not on the screen at all.
Processing WM_ACTIVATE is a little dangerous because DefProcWindow(..) function processes many thing in this message, so a boolean is more usable i think.
WS_POPUP by itself is not fullscreen. Are you really using Fullscreen (ie. DirectDraw or Direct3d or ChangeDisplaySettings with according parameters set?)

If you're using true full screen proper lost device handling should solve that issue by itself. My games don't have any WM_ACTIVATE checking (only for toggling between busy and multi-app-friendly message pumping) for the window state. When the windows key is pressed the fullscreen apps automatically gets minimized without me doing that.

If you're using fake fullscreen (WS_POPUP with a full size window) you're really in windowed mode. In that case you have to code the wanted behaviour yourself.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

Some games stop their logic (and possibly rendering) calls until they are back in focus.

You do still need to handle lost devices though.

This topic is closed to new replies.

Advertisement