Where to Put ShowWindow
-
Hello Friends, I want my application to run in the background. And it displays only when some cliked in taskbar icon. But I am not getting where to put the
ShowWindow(hWnd,SW_HIDE);
to hide the window.so that it doesn't appeare when It is loaded at startup.(I have set the registry, so that it runs at startup). I have tryed to put it in following places but getting errors. case WM_INITDIALOG: { //If I use the ShowWindow in the begining of the WM_INITDIALOG. //I am geeting 02 as Error Code. Which Means "The system cannot find the file specified. " if( ! ShowWindow(hWndDlg,SW_HIDE) ) //Hide the main window dError = GetLastError(); ... ... //If I use the ShowWindow at the End of the WM_INITDIALOG. //I am geeting 170 as Error Code. Which Means "The requested resource is in use." if( ! ShowWindow(hWndDlg,SW_HIDE) ) //Hide the main window dError = GetLastError(); }[ Screen Capture ][ Tool Tip ]
-
Hello Friends, I want my application to run in the background. And it displays only when some cliked in taskbar icon. But I am not getting where to put the
ShowWindow(hWnd,SW_HIDE);
to hide the window.so that it doesn't appeare when It is loaded at startup.(I have set the registry, so that it runs at startup). I have tryed to put it in following places but getting errors. case WM_INITDIALOG: { //If I use the ShowWindow in the begining of the WM_INITDIALOG. //I am geeting 02 as Error Code. Which Means "The system cannot find the file specified. " if( ! ShowWindow(hWndDlg,SW_HIDE) ) //Hide the main window dError = GetLastError(); ... ... //If I use the ShowWindow at the End of the WM_INITDIALOG. //I am geeting 170 as Error Code. Which Means "The requested resource is in use." if( ! ShowWindow(hWndDlg,SW_HIDE) ) //Hide the main window dError = GetLastError(); }[ Screen Capture ][ Tool Tip ]
Why you dont set your program to minimize when its running?
-
Hello Friends, I want my application to run in the background. And it displays only when some cliked in taskbar icon. But I am not getting where to put the
ShowWindow(hWnd,SW_HIDE);
to hide the window.so that it doesn't appeare when It is loaded at startup.(I have set the registry, so that it runs at startup). I have tryed to put it in following places but getting errors. case WM_INITDIALOG: { //If I use the ShowWindow in the begining of the WM_INITDIALOG. //I am geeting 02 as Error Code. Which Means "The system cannot find the file specified. " if( ! ShowWindow(hWndDlg,SW_HIDE) ) //Hide the main window dError = GetLastError(); ... ... //If I use the ShowWindow at the End of the WM_INITDIALOG. //I am geeting 170 as Error Code. Which Means "The requested resource is in use." if( ! ShowWindow(hWndDlg,SW_HIDE) ) //Hide the main window dError = GetLastError(); }[ Screen Capture ][ Tool Tip ]
GauranG33 wrote:
.(I have set the registry, so that it runs at startup).
can you please guide me how you have achieved this. this is great because, i have been trying this since a couple of months but in vain. and to your question, i have temporary solution. 1.set the dialog properties in such a way that, it does not have any border. so that, it will be always running in the background, and gets displayed only if the user clicks the icon in the taskbar. 2.if you know, how to track the GetFocus and Lost Focus events, then, i can suggest a better solution. gud luck.
Suggestion to the members: prefix your main thread subject with [SOLVED] if it is solved. chandu.
-
Hello Friends, I want my application to run in the background. And it displays only when some cliked in taskbar icon. But I am not getting where to put the
ShowWindow(hWnd,SW_HIDE);
to hide the window.so that it doesn't appeare when It is loaded at startup.(I have set the registry, so that it runs at startup). I have tryed to put it in following places but getting errors. case WM_INITDIALOG: { //If I use the ShowWindow in the begining of the WM_INITDIALOG. //I am geeting 02 as Error Code. Which Means "The system cannot find the file specified. " if( ! ShowWindow(hWndDlg,SW_HIDE) ) //Hide the main window dError = GetLastError(); ... ... //If I use the ShowWindow at the End of the WM_INITDIALOG. //I am geeting 170 as Error Code. Which Means "The requested resource is in use." if( ! ShowWindow(hWndDlg,SW_HIDE) ) //Hide the main window dError = GetLastError(); }[ Screen Capture ][ Tool Tip ]
-
Hello Friends, I want my application to run in the background. And it displays only when some cliked in taskbar icon. But I am not getting where to put the
ShowWindow(hWnd,SW_HIDE);
to hide the window.so that it doesn't appeare when It is loaded at startup.(I have set the registry, so that it runs at startup). I have tryed to put it in following places but getting errors. case WM_INITDIALOG: { //If I use the ShowWindow in the begining of the WM_INITDIALOG. //I am geeting 02 as Error Code. Which Means "The system cannot find the file specified. " if( ! ShowWindow(hWndDlg,SW_HIDE) ) //Hide the main window dError = GetLastError(); ... ... //If I use the ShowWindow at the End of the WM_INITDIALOG. //I am geeting 170 as Error Code. Which Means "The requested resource is in use." if( ! ShowWindow(hWndDlg,SW_HIDE) ) //Hide the main window dError = GetLastError(); }[ Screen Capture ][ Tool Tip ]
Why not just create the main window without the WS_VISIBLE flag so you don't have to worry about hiding it? Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
Hello Friends, I want my application to run in the background. And it displays only when some cliked in taskbar icon. But I am not getting where to put the
ShowWindow(hWnd,SW_HIDE);
to hide the window.so that it doesn't appeare when It is loaded at startup.(I have set the registry, so that it runs at startup). I have tryed to put it in following places but getting errors. case WM_INITDIALOG: { //If I use the ShowWindow in the begining of the WM_INITDIALOG. //I am geeting 02 as Error Code. Which Means "The system cannot find the file specified. " if( ! ShowWindow(hWndDlg,SW_HIDE) ) //Hide the main window dError = GetLastError(); ... ... //If I use the ShowWindow at the End of the WM_INITDIALOG. //I am geeting 170 as Error Code. Which Means "The requested resource is in use." if( ! ShowWindow(hWndDlg,SW_HIDE) ) //Hide the main window dError = GetLastError(); }[ Screen Capture ][ Tool Tip ]
See here.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
See here.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
Hey Thanx David. I see the Solution you have suggested, but the problem is the solution is for MFC Application while I am using Win32 API . Can You help me with this. ??? I have tried somthing like this. but the Same thing. Errors, I have Taken the Global Boolean flag
First
. But dont know where to initialize it to True. So I have initialize it inWM_INITDIALOG.
case WM_WINDOWPOSCHANGING:
if(First)
{
if ( ! ShowWindow(hWndDlg,SW_HIDE) )
dError = GetLastError();
First = FALSE;
}
break;case WM_INITDIALOG :
First = TRUE; ... ...
break;
[ Screen Capture ][ Tool Tip ]
-
Why not just create the main window without the WS_VISIBLE flag so you don't have to worry about hiding it? Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
If this solution is taken... The controls can not be used while the window is invisible, but if you use other things as triggers (for example a timer) then the code will be called anyways. Am I right? But if you make the WS_VISIBLE away, and in some conditions need the window another time... can you make it visible with the ShowWindow (TRUE) ??? Or won't be posible because the property has not been set?
Greetings. -------- M.D.V. If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you ;)
-
See here.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
I have got the Idea to do do this. I am using the timer in WM_INIT for about 100 msec. and in the WM_TIMER I am using ShowWinow() to hide the Dialog. Currently It is working fine. But I just want to know will this work all the time. Or there will be the case it can fail. the Code I am using is as follows
case WM_TIMER:
ShowWindow(hWndDlg, FALSE);
KillTimer(hWndDlg,0);break;
case WM_INITDIALOG:
...
...
SetTimer(hWndDlg,0,100,0);
break;[ Screen Capture ][ Tool Tip ]
-
Hey Thanx David. I see the Solution you have suggested, but the problem is the solution is for MFC Application while I am using Win32 API . Can You help me with this. ??? I have tried somthing like this. but the Same thing. Errors, I have Taken the Global Boolean flag
First
. But dont know where to initialize it to True. So I have initialize it inWM_INITDIALOG.
case WM_WINDOWPOSCHANGING:
if(First)
{
if ( ! ShowWindow(hWndDlg,SW_HIDE) )
dError = GetLastError();
First = FALSE;
}
break;case WM_INITDIALOG :
First = TRUE; ... ...
break;
[ Screen Capture ][ Tool Tip ]
GauranG33 wrote:
I have tried somthing like this. but the Same thing. Errors,
Because you did not remove the
SWP_SHOWWINDOW
flag.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
If this solution is taken... The controls can not be used while the window is invisible, but if you use other things as triggers (for example a timer) then the code will be called anyways. Am I right? But if you make the WS_VISIBLE away, and in some conditions need the window another time... can you make it visible with the ShowWindow (TRUE) ??? Or won't be posible because the property has not been set?
Greetings. -------- M.D.V. If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you ;)
It just creates the window hidden. It won't get any messages from user like mouse messages because it's not visible. It will still get messages from timers or messages you send to it. It's just hidden...ShowWindow(SW_SHOW) will make it visible. Hidden windows are common. The CSocketWnd used by the CAsyncSocket class is an example of a hidden window. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
I have got the Idea to do do this. I am using the timer in WM_INIT for about 100 msec. and in the WM_TIMER I am using ShowWinow() to hide the Dialog. Currently It is working fine. But I just want to know will this work all the time. Or there will be the case it can fail. the Code I am using is as follows
case WM_TIMER:
ShowWindow(hWndDlg, FALSE);
KillTimer(hWndDlg,0);break;
case WM_INITDIALOG:
...
...
SetTimer(hWndDlg,0,100,0);
break;[ Screen Capture ][ Tool Tip ]
I'm still wondering why this has to be so complicated. If you never show the window to begin with then there's no reason to go through all of this to hide it. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
It just creates the window hidden. It won't get any messages from user like mouse messages because it's not visible. It will still get messages from timers or messages you send to it. It's just hidden...ShowWindow(SW_SHOW) will make it visible. Hidden windows are common. The CSocketWnd used by the CAsyncSocket class is an example of a hidden window. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java: