starting the application minimized - on system tray
-
I used Shell_NotifyIcon to minimize the application to the nofitication area (system tray) and put an icon there. When the minimize button of the system menu is pressed, the dialog is minimized to the system tray. It was working perfectly until I tried to put an option in the title bar menu, which gave the possibility to choose whether or not to start the application as minimized. I save this information in a file, and read from the file on initialization. The problem is that the application starts as minimized, but the main dialog can never be displayed when the Menu->Open is clicked from the tray menu. I guess it is restored to the previous position, and the previous position was "minimized". Does anyone know how to overcome this problem? Thanks in advance... PS: my dialog is of fixed size.
CMyDialog::OnInitDialog()
{
...
// TODO: Add extra initialization here
//
if(startOnTray)
{
SetWindowPos(&this->wndNoTopMost,0,0,0,0,SWP_HIDEWINDOW); // start on tray// form tray icon and minimize the application, normally called when minimize button of the system menu is pressed. this->Minimize2NotifArea(); } else SetWindowPos(&this->wndNoTopMost,0,0,0,0,SWP\_NOMOVE|SWP\_NOSIZE); // normal start return TRUE;
}
CMyDialog::OnMenuOpen()
{
// delete tray icon
Shell_NotifyIcon(...);// // supposed to display the dialog here.
this->ShowWindow(SW_RESTORE);
} -
I used Shell_NotifyIcon to minimize the application to the nofitication area (system tray) and put an icon there. When the minimize button of the system menu is pressed, the dialog is minimized to the system tray. It was working perfectly until I tried to put an option in the title bar menu, which gave the possibility to choose whether or not to start the application as minimized. I save this information in a file, and read from the file on initialization. The problem is that the application starts as minimized, but the main dialog can never be displayed when the Menu->Open is clicked from the tray menu. I guess it is restored to the previous position, and the previous position was "minimized". Does anyone know how to overcome this problem? Thanks in advance... PS: my dialog is of fixed size.
CMyDialog::OnInitDialog()
{
...
// TODO: Add extra initialization here
//
if(startOnTray)
{
SetWindowPos(&this->wndNoTopMost,0,0,0,0,SWP_HIDEWINDOW); // start on tray// form tray icon and minimize the application, normally called when minimize button of the system menu is pressed. this->Minimize2NotifArea(); } else SetWindowPos(&this->wndNoTopMost,0,0,0,0,SWP\_NOMOVE|SWP\_NOSIZE); // normal start return TRUE;
}
CMyDialog::OnMenuOpen()
{
// delete tray icon
Shell_NotifyIcon(...);// // supposed to display the dialog here.
this->ShowWindow(SW_RESTORE);
}I have not tried this recently, but IIRC, when Win32 first came out, the behavior of Minimized windows changed. Instead of a "real" state of being Minimized that did not affect your real X/Y position, they were moved off-screen to some really high X/Y location, and brought back when Restored. That behavior broke older applications that saved and restored their last position when they were closed down while minimized and then restarted. When you restore your window, you should check its current position and make sure that you are being placed somewhere visible. You might have to reposition the dialog yourself. You can save your last position before being minimized and then restore yourself to that position. You might be able to see if this is your problem by trying to restore your dialog from the menu, and then pressing to activate the dialog's System Menu. You can then select Move and try to use the arrow keys to being your window back into the visible screen. Be sure to use the KEYBOARD for this, not the mouse. Peace! -=- James Tip for SUV winter driving survival: "Professional Driver on Closed Course" does not mean "your Dumb Ass on a Public Road"!
Articles -- Products: Delete FXP Files & Check Favorites -
I have not tried this recently, but IIRC, when Win32 first came out, the behavior of Minimized windows changed. Instead of a "real" state of being Minimized that did not affect your real X/Y position, they were moved off-screen to some really high X/Y location, and brought back when Restored. That behavior broke older applications that saved and restored their last position when they were closed down while minimized and then restarted. When you restore your window, you should check its current position and make sure that you are being placed somewhere visible. You might have to reposition the dialog yourself. You can save your last position before being minimized and then restore yourself to that position. You might be able to see if this is your problem by trying to restore your dialog from the menu, and then pressing to activate the dialog's System Menu. You can then select Move and try to use the arrow keys to being your window back into the visible screen. Be sure to use the KEYBOARD for this, not the mouse. Peace! -=- James Tip for SUV winter driving survival: "Professional Driver on Closed Course" does not mean "your Dumb Ass on a Public Road"!
Articles -- Products: Delete FXP Files & Check FavoritesThanks.. From the system menu, I chose move and the keyboard moved the mouse cursor, the dialog did not come into visible area. Then when I clicked close from the system menu, the messages which pop up on closing popped up centering the latest mouse location. :doh: I think now I will try repositioning myself.
-
Thanks.. From the system menu, I chose move and the keyboard moved the mouse cursor, the dialog did not come into visible area. Then when I clicked close from the system menu, the messages which pop up on closing popped up centering the latest mouse location. :doh: I think now I will try repositioning myself.
You might have to "move" the dialog for a long time before it becomes visible. Be sure to trace some information in your dialog class upon handling the Move messages so that you can get an idea of what is going on with your dialog. Peace! -=- James Tip for inexperienced drivers: "Professional Driver on Closed Course" does not mean "your Dumb Ass on a Public Road"!
Articles -- Products: Delete FXP Files & Check Favorites