如何给基于对话框的MFC程序加上最小化按钮,并且最小化到系统栏
1个回答
展开全部
最小化时隐藏,就可以重载DefWindowProc函数: LRESULT CSSMainDlg::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam) { LONG l = CDialog::DefWindowProc(message, wParam, lParam); switch(message) { case WM_SYSCOMMAND: if(wParam == SC_MINIMIZE) ShowWindow(SW_HIDE); break; } return l; }另外要在系统栏显示图标, //任务栏图标添加删除的真正实现 BOOL CTrayIcon::TaskBarAddIcon(HWND hwnd, UINT uID, HICON hicon, LPSTR lpszTip) { BOOL res; NOTIFYICONDATA nid; nid.cbSize = sizeof(NOTIFYICONDATA); nid.hWnd = hwnd; nid.uID = uID; nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; nid.uCallbackMessage = WM_TRAYICONCLICK; nid.hIcon = hicon; if (lpszTip) lstrcpyn(nid.szTip, lpszTip, sizeof(nid.szTip)); else nid.szTip[0] = '\0'; res = Shell_NotifyIcon(NIM_ADD, &nid); if (hicon) DestroyIcon(hicon); return res; } BOOL CTrayIcon::TaskBarDeleteIcon(HWND hwnd, UINT uID) { BOOL res; NOTIFYICONDATA tnid; tnid.cbSize = sizeof(NOTIFYICONDATA); tnid.hWnd = hwnd; tnid.uID = uID; res = Shell_NotifyIcon(NIM_DELETE, &tnid); return res; } //添加系统Icon void CTrayIcon::AddSystemIcon() { HICON hIcon = LoadIcon((AfxGetApp()->m_hInstance), MAKEINTRESOURCE(IDR_MAINFRAME)); char tip[128]; wsprintf(tip, "WP-VDRS网络中心服务器"); TaskBarAddIcon(AfxGetMainWnd()->m_hWnd, IDR_MAINFRAME, hIcon, tip); } //删除系统Icon void CTrayIcon::RemoveSystemIcon() { TaskBarDeleteIcon(AfxGetMainWnd()->m_hWnd, IDR_MAINFRAME); }
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询