Dialog Window
-
Hi, I have an option in my application tray menu to display a dialog.When i have used the IsWindowVisible also that particular dalog is displaying as many times the option in the tray menu is selected.If the dialog is already opened it should not open again.I have used the following code.But it doesn't work.How can i go further. CDialog dlg; if(dlg.IsWindowVisible()) { dlg.ShowWindow(SW_HIDE); } Thanks
-
Hi, I have an option in my application tray menu to display a dialog.When i have used the IsWindowVisible also that particular dalog is displaying as many times the option in the tray menu is selected.If the dialog is already opened it should not open again.I have used the following code.But it doesn't work.How can i go further. CDialog dlg; if(dlg.IsWindowVisible()) { dlg.ShowWindow(SW_HIDE); } Thanks
-
How do you show the dialog? DoModal? Can you show me the code snippet of the menu option handling?
- NS -
void CMainFrame::OnSettings() { // TODO: Add your command handler code here CSettings dlg; if(!(dlg.IsWindowVisible())) { dlg.DoModal(); } } When i right click on my application's tray icon a tray menu will display.My tray menu have one of the option called "Settings".When click on "settings" the settings dialog( class name:CSettings) will display.But my problem is when i click on the settings n times,then n number Settings dilaog is opening.What i required is,if dilaog is already opened it should not open again.How can i do this. Thanks.
-
void CMainFrame::OnSettings() { // TODO: Add your command handler code here CSettings dlg; if(!(dlg.IsWindowVisible())) { dlg.DoModal(); } } When i right click on my application's tray icon a tray menu will display.My tray menu have one of the option called "Settings".When click on "settings" the settings dialog( class name:CSettings) will display.But my problem is when i click on the settings n times,then n number Settings dilaog is opening.What i required is,if dilaog is already opened it should not open again.How can i do this. Thanks.
The problem is that you are using the DoModal and the dlg is local in OnSettings(). In this case I will suggest a simple solution. 1. Make the CSettings dlg as class member, CSettings m_dlgSettings. 2. Change the code as,
void CMainFrame::OnSettings() { if( IsWindow( m_dlgSettings.m_hWnd )) return; m_dlgSettings.DoModal(); }
3. Let me know the result... ;)- NS -
-
The problem is that you are using the DoModal and the dlg is local in OnSettings(). In this case I will suggest a simple solution. 1. Make the CSettings dlg as class member, CSettings m_dlgSettings. 2. Change the code as,
void CMainFrame::OnSettings() { if( IsWindow( m_dlgSettings.m_hWnd )) return; m_dlgSettings.DoModal(); }
3. Let me know the result... ;)- NS -
-
Thanks for ur reply.But it doesn't work.The dialog is displaying again and again when i click on the settings option in the menu again and again . Thanks.
Oops really? I had tested the code in some sample application and it is working fine. Are you sure that when you select the settings, on the second time, the control is coming to the same MainFrame object's OnSettings? And are you sure that the object is now member of the class? Can you show me the relevant updations that you made?
- NS -
-
Oops really? I had tested the code in some sample application and it is working fine. Are you sure that when you select the settings, on the second time, the control is coming to the same MainFrame object's OnSettings? And are you sure that the object is now member of the class? Can you show me the relevant updations that you made?
- NS -
-
Thanks NS17.The problem was that i have given same ID for the two menu options in two menus.It is working fine. Thanks -- modified at 4:47 Friday 10th August, 2007
-
Thanks NS17.The problem was that i have given same ID for the two menu options in two menus.It is working fine. Thanks -- modified at 4:47 Friday 10th August, 2007
-
void CMainFrame::OnSettings() { // TODO: Add your command handler code here CSettings dlg; if(!(dlg.IsWindowVisible())) { dlg.DoModal(); } } When i right click on my application's tray icon a tray menu will display.My tray menu have one of the option called "Settings".When click on "settings" the settings dialog( class name:CSettings) will display.But my problem is when i click on the settings n times,then n number Settings dilaog is opening.What i required is,if dilaog is already opened it should not open again.How can i do this. Thanks.
This is obviously not going to work. When
DoModal()
is called, it does not return until the dialog has been dismissed. Therefore,OnSettings()
will not get called more than once.
"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