BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) { if( !CFrameWnd::PreCreateWindow(cs) ) return FALSE; // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs cs.dwExStyle |= WS_EX_TOOLWINDOW; return TRUE; }对话框应用程序,直接可以设置dialog的style为Tool window
完全同意楼上的,解释一下: WS_EX_TOOLWINDOW Creates a tool window, which is a window intended to be used as a floating toolbar. A tool window has a title bar that is shorter than a normal title bar, and the window title is drawn using a smaller font. A tool window does not appear in the task bar or in the window that appears when the user presses ALT+TAB.
Alternative Way(I have tested) --------------------------------->> //在任务条上不显示图标 先从CWinApp继承类中建立一个不显示的顶级窗口. CFrameWnd *abc=new CFrameWnd(); abc->Create(0,0,WS_OVERLAPPEDWINDOW); CNoTaskBarIconDlg dlg(abc); m_pMainWnd = &dlg; int nResponse = dlg.DoModal(); if (nResponse == IDOK) { } else if (nResponse == IDCANCEL) { } delete abc;在 OnInitDialog中修改显示风格 WS_EX_APPWINDOW.BOOL CNoTaskBarIconDlg::OnInitDialog() { CDialog::OnInitDialog(); ModifyStyleEx(WS_EX_APPWINDOW,0); SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs cs.dwExStyle |= WS_EX_TOOLWINDOW;
return TRUE;
}对话框应用程序,直接可以设置dialog的style为Tool window
WS_EX_TOOLWINDOW Creates a tool window, which is a window intended to be used as a floating toolbar. A tool window has a title bar that is shorter than a normal title bar, and the window title is drawn using a smaller font. A tool window does not appear in the task bar or in the window that appears when the user presses ALT+TAB.
--------------------------------->>
//在任务条上不显示图标
先从CWinApp继承类中建立一个不显示的顶级窗口. CFrameWnd *abc=new CFrameWnd();
abc->Create(0,0,WS_OVERLAPPEDWINDOW);
CNoTaskBarIconDlg dlg(abc);
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
}
else if (nResponse == IDCANCEL)
{
}
delete abc;在 OnInitDialog中修改显示风格 WS_EX_APPWINDOW.BOOL CNoTaskBarIconDlg::OnInitDialog()
{
CDialog::OnInitDialog();
ModifyStyleEx(WS_EX_APPWINDOW,0); SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
{
.................
//m_pMainWnd->ShowWindow(SW_SHOW); //原来的语句
m_pMainWnd->ShowWindow(SW_HIDE); //修改后的语句 ................
}
BOOL CAaaDlg::OnInitDialog()
{
CDialog::OnInitDialog();
ModifyStyleEx(WS_EX_APPWINDOW,0);
return TRUE;
}
http://www.csdn.net/develop/Read_Article.asp?Id=17482