In my last post I discussed about how to Add an MFC application into tray Icon. The sample application can be Minimized to tray icon, without even shown in task bar when HIDE menu Item is clicked. And again can be relaunched when SHOW menu in tray icon is clicked.
But one problem is there. We can not start the Sample MFC application as a tray icon from the startup.Even a call to ShowWindow(SW_HIDE) from the OnInitDialog() function, will not work.
Well here is a trick of doing this, by modifying the initinstance() function of the App class.
The Normal code for creating the dialog in InitInstance() looks like
CDialogBasedDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
Edit this code as follows :
CDialogBasedDlg dlg;
if(dlg.Create( CDialogBasedDlg::IDD ))
{
dlg.ShowWindow( SW_HIDE );
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.RunModalLoop();
}
And you are done.. Integrating it with previous sample application will result in a Dialog based application starting as a trayicon, Always Minimized and will not appear in System tray. ;))
2 comments:
generic viagra online watermelon viagra canadian viagra non prescription viagra buy generic viagra buy viagra online uk buy viagra in england buy cheap viagra online uk buy generic viagra viagra price comparison effects of viagra viagra from india viagra cheap viagra jelly
I liked this blog, i think is very interesting, most of all for the new ideas that this blog talk.
Post a Comment