Cómo utilizar VC++ MFC para minimizar el programa en la bandeja
2. Cambie InitInstance() en myApp.cpp de la siguiente manera:
CDialog* pd = new CDialog;
HICON hIcon = LoadIcon(IDR_MAINFRAME);
pd->Create(IDD_TEMP_DIALOG); //IDD_TEMP_DIALOG es un ID de recurso de diálogo que no se muestra
pd->SetWindowText(" QQ_Loginer ");
pd->SetIcon (hIcon, TRUE);
CQQ_LoginerDlg dlg(pd);
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
3. Agregue inicialización en myAppDlg.
h Variables y funciones:
public:
void InitialNotifyIcon();
BOOL wndst;
NOTIFYICONDATA NotifyIcon;
protegido:
afx_ msg void OnNotifyIcon(WPARAM wParam,LPARAM IParam);
4. Agregue el siguiente código a OnInitDialog() en myAppDlg.cpp:
5.cpp:
wndst = FALSE;
InitialNotifyIcon();
Agregar función:
void CmyAppDlg:: OnNotifyIcon(WPARAM wParam, LPARAM IParam)
{
if (IParam == WM_ LBUTTONUP)
{
if (wndst)
{
ShowWindow(SW_SHOW
}
más
{
ShowWindow(SW_HIDE);
}
wndst = ! wndst;
}
}
void CmyAppDlg::InitialNotifyIcon()
{
ShowWindow(SW_HIDE );
NotifyIcon .cbSize = sizeof(NOTIFYICONDATA);
NotifyIcon.hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
NotifyIcon.hWnd = m_hWnd;
NotifyIcon.p> lstrcpy(NotifyIcon.szTip, "QQ_Loginer");
NotifyIcon.uCallbackMessage = WM_NC;
NotifyIcon.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
Shell_NotifyIcon(NIM_ADD,&NotifyIcon);
}
No olvides agregar la función de mensaje:
void CmyAppDlg:: OnClose()
{
Shell_NotifyIcon(NIM_DELETE, &NotifyIcon);
exit(0);
CDialog: :OnClose() ;
}
Adjunto: cambie el mensaje de permanencia (mensaje de nota de color amarillo claro):
Título de CString;
title = "[ Frecuencia de actualización: " + m_interval + "s]";
AfxGetMainWnd()->SetWindowText(title);
lstrcpy( NotifyIcon.szTip, title);
Shell_NotifyIcon(NIM_MODIFY, &NotifyIcon);
Por favor, dame el código fuente, no me atrevo a tragarme las publicaciones aquí.