ShowWindow(hwnd, 0) ShowWindow(hwnd,1) not working.

Once I do a call to ShowWindow(hwnd, 0) or ShowWindow(hwnd, 1) repeated calls to ShowWindow have no effect.
I would try a 5, 9, or 10, in that order
Here is what is wrong. And its icky.
Its actually hanging up in GetMessage()
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
    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.
ok now I have:
1
2
3
4
5
if ( (window_visible) && (GetMessage(&Msg, NULL, 0, 0) > 0 ) )
     {
            TranslateMessage(&Msg);
            DispatchMessage(&Msg);
     }


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.
closed account (DSLq5Di1)
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.
If the window is not visible, there is no need to call UpdateWindow() like you do in line 6.

Don't use 0 and 1; use FALSE and TRUE SW_HIDE and SW_SHOWNORMAL. Constants instead of magic numbers.

+1 to stop butchering the message pump, hehe.

Whenever the window is not visible and you show it, you should call UpdateWindow().
Last edited on
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.
Topic archived. No new replies allowed.