ShowWindow(win, 0);
//ShowWindow(win, nCmdShow); //this is where the window is shown.
window_visible = false;
//window_visible = true;
UpdateWindow(win);
while(1)
{
printf("%d\n", ++a);
if (GetAsyncKeyState(VK_F11) && GetAsyncKeyState(VK_CONTROL))
{
if (window_visible)
{
ShowWindow(win, 0);
window_visible = false;
}
else
{
ShowWindow(win, 1);
window_visible = true;
}
while(GetAsyncKeyState(VK_F12) || GetAsyncKeyState(VK_CONTROL));
UpdateWindow(win);
}
if (GetAsyncKeyState(VK_F12) && GetAsyncKeyState(VK_CONTROL))
{
while(GetAsyncKeyState(VK_F12));
limpiar_con(console_visible);
if (console_visible) console_visible = false;
else console_visible = true;
}
if (GetAsyncKeyState(VK_ESCAPE) && GetAsyncKeyState(VK_CONTROL))
return 0;
//Sleep(1);
while(GetMessage(&Msg, NULL, 0, 0) > 0)
{
cout << "a = " << a << endl;
if (a++ > 2) exit(++a);
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
}
return Msg.wParam;
I didn't know where to put the while (GetMessage() thingie. If I didn't place it anywhere it would crash on me, or rather say that the program was not responding.
as it is now though, it hands up on the second iteration of the loop.
now it seems to work a little better, if the window is currently visible, and either the console or the window has the focus, then ctrl+F11 will hide the main window. but subsequent calls to ctrl+f11 will not work.
Windows rely on the GetMessage loop to be notified by the OS of any events in the system, such as user input.. as your program is now, once window_visible is false it will no longer process system messages and thus will not respond to anything.
I recommend you stop butchering the message pump and handle your input in the window procedure. If you need any more help with this I'd suggest you post the full code.
Ok well what is the vm message code for vk_control and f11 and f2?
Could I just possibly put the whole loop like I have now in the default of the switch in the callback procedure? Would that work? I'm new to windows programming here.