任务栏和系统托盘显示问题

来源:百度知道 编辑:UC知道 时间:2024/06/04 15:41:15
怎么像QQ一样,在程序启动时,不在任务栏留下最下化的窗口,而只在系统托盘处显示一只企鹅。我建了个基于对话框的工程,在程序运行时,添加了系统图标,但是任务栏还是显示了最小化的窗口。这样很不爽,任务栏本来就只有那么宽。我的想法就是只给程序在托盘区加个图标,但是不让在任务栏显示,就像QQ一样。

新建一个win32对话框程序

BOOL CXXXXDlg::OnInitDialog()
{
..........
// TODO: Add extra initialization here
DWORD dwExStyle = WS_EX_TOOLWINDOW;
SetWindowLong( this->m_hWnd, GWL_EXSTYLE, dwExStyle );
SetWindowPos( NULL, 0, 0, 0, 0, SWP_HIDEWINDOW );

.............

}

这个最简单,3行代码

新建一个win32对话框程序,把其中的InitInstance 修改成如下这样

//
// FUNCTION: InitInstance(HANDLE, int)
//
// PURPOSE: Saves instance handle and creates main window
//
// COMMENTS:
//
// In this function, we save the instance handle in a global variable and
// create and display the main program window.
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;

hInst = hInstance; // Store instance handle in our global variable

hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_US