Can I show a window without showing Windows Explorer taskbar? - c++

I have created a new window using C + Win32 API, and I attached it to a game.
The game runs on Windowed (no border) mode, which means that it's simply a big window which is shown over the taskbar, creating the effect of a full-screen mode.
I've binded F11 to pop-up the console with:
ShowWindow(hConsole, SW_HIDE);
ShowWindow(hConsole, SW_SHOW);
That pop-ups the console window, and it works fine, except that it also shows the taskbar.
Is there any way to make the game still stay over the task bar, while showing the console?

Related

Alt + Space is not working on a borderless window

I have created a borderless window by intercepting the WM_NCCALCSIZE command. The idea is to create a custom GUI. Here is the code that I used to create a clean slate:
case WM_NCCALCSIZE:
return 0;
Somehow though, WM_NCCALCSIZE also disabled the system menu. Pressing Alt + Space only gives an error beep. I am unable to test the "Minimize" and "Maximize" functions. How can I restore the system menu?

How do I make a window inactive on Windows

I'm trying to create an C++ console app that shows itself when I press a button. However, when the app appears, it appears on top of all other windows. Is there a way I can prevent this from happening (i.e. have the window appear in the background)?
Here is the part of the code that is important:
ShowWindow(GetConsoleWindow(), SW_HIDE);
//stuff happens
ShowWindow(GetConsoleWindow(), SW_SHOW);
When the window is shown, it does so in front of all other windows (which I don't want).
Here is an image of this behavior:
You can call SetWindowPos in place of ShowWindow, specifying the SWP_SHOWWINDOW, SWP_NOZORDER, SWP_NOOWNERZORDER, and SWP_NOACTIVATE flags. This will show the window, without moving it up or down the Z order, or activating it.

SW_SHOWNOACTIVATE does not work if program is minimized by clicking the taskbar button

My application can receive a message from another application. If the app is minimized, I want to restore it to the previous state without giving focus to it.
I'm doing it by calling
::ShowWindow(hWnd, SW_SHOWNOACTIVATE);
It works well if the app was minimized using the Minimize button in the title bar, but if the app was minimized by clicking its button in the Windows task bar, then the app will receive focus.
Can this be fixed or worked around?
You could do the following HWND hwndForegroundWindow = GetForegroundWindow() before your ShowWindow function call. Afterwards you can restore the foreground window with SetForegroundWindow(hwndForegroundWindow). It depends on what you mean with focus though, foreground window and focus are something different (For element focus use GetFocus and SetFocus).

How to keep window inactive on simulated clicks?

I made a program in C++ that simulates clicks on an inactive window using:
PostMessage (z, WM_LBUTTONDOWN, 0,MAKELONG(t.left+x,t.top+y));
But whenever it makes a click it activates the window and the window moves to the top.
Is there a way I can make the window stay inactive or another way to click it?
I used SetWindowPos(z , HWND_BOTTOM,....) to make that window be at the bottom of the z-order list but it still activates.
EDIT: the window is a game console
Try switching from PostMessage to SendInput and see if you get the same effect.

Fullscreen mode for ActiveX control

I tried to implement a switch-to-fullscreen mode for an ActiveX control. This currently works by removing and hiding the parent window and changing my control's placement and position.
However, I have a problem with switching between applications while the control is in fullscreen mode. If I switch to another application and then click on my window area (not in the taskbar), it seems to not be activated. You can see in the taskbar, that another application still has the highlight and on the main screen, my window is partly hidden behind the taskbar unless it has the focus.
I process the WM_LBUTTONDOWN window message to detect if my window is clicked. And I already tried to call the following WINAPI functions:
::ShowWindow(m_hWnd, SW_RESTORE);
::SwitchToThisWindow(m_hWnd, FALSE);
::SetForegroundWindow(m_hWnd);
::SetActiveWindow(m_hWnd);
::SetFocus(m_hWnd);
::BringWindowToTop(m_hWnd);
::SetWindowPos(m_hWnd, HWND_TOP, m_monitorInfo.rcMonitor.left, m_monitorInfo.rcMonitor.top, m_monitorInfo.rcMonitor.right, m_monitorInfo.rcMonitor.bottom, SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW); // SWP_NOACTIVATE, SWP_NOOWNERZORDER
I also tried to use ::SetWindowLongW(m_hWnd, GWL_STYLE, WS_VISIBLE); which surprisingly gave my window the focus back. But it then suddenly disappeared when trying to switch back from fullscreen mode again.
I have no idea why there are so many different functions that for me seem all to do roughly the same. But it doesn't matter as none of them worked anyway.
What is the/one correct way to behave my control correctly?
Windows might be getting a bit confused because you're filling the screen with a child window, but you want it to behave like a top-level (overlapped) window. The host application is probably not getting activated because you've hidden its window.
You might do better to create a new top-level full-screen window for full-screen mode. If this is owned by the top-level window that (ultimately) hosts your control then your new window will always be above it, so you don't need to hide the existing window. Activation should just work. In short, you want your window to behave like a pop-up modal dialog.
Adobe's flash player seems to do something similar. Full-screen playback is in a window of class ShockwaveFlashFullScreen.