如何隱藏顯示在工作列中的對話方塊程式

2021-05-02 11:23:21 字數 2281 閱讀 7073

用 ws_ex_toolwindow 可以建立乙個工具視窗,被作為浮動工具欄使用。工具視窗的標

題欄比常規標題欄短,並且使用的視窗字型更小。工具視窗不會出現在工作列裡;當使用者

按下 alt+tab 健後,也不會出現在任務表中......

// hidedlg.cpp 宣告部分

// #include "stdafx.h"

#include "resource.h"

#include "statlink.h"

#ifdef _debug

#define new debug_new

#undef this_file

static char this_file = __file__;

#endif

class cmainframe : public cframewnd

~cmainframe()

};class cmydlg : public cdialog ;

public:

virtual bool initinstance();

declare_message_map()

};//

// hidedlg.cpp 實現部分

////

// 建立不可見框架視窗:設定 ws_ex_toolwindow 式樣

bool cmainframe::precreatewindow(createstruct& cs)

return false;

*/ // 不設定 ws_ex_toolwindow 擴充套件式樣

return cframewnd::precreatewindow(cs);

}end_message_map()

// initinstance: 建立對話方塊時,把它作為不可見主框架視窗的子視窗對待

// else if (nresponse == idcancel)

return false;

}class caboutdlg : public cdialog ;

protected:

cstaticlink m_wndlink1;

cstaticlink m_wndlink2;

cstaticlink m_wndlink3;

// implementation

protected:

//}afx_msg

declare_message_map()

};caboutdlg::caboutdlg() : cdialog(caboutdlg::idd)

begin_message_map(caboutdlg, cdialog)

end_message_map()

bool caboutdlg::oninitdialog()

cmydlg::cmydlg(cwnd* pparent /*=null*/)

: cdialog(idd_hidedlg, pparent)

begin_message_map(cmydlg, cdialog)

on_wm_syscommand()

on_wm_paint()

on_wm_querydragicon()

end_message_map()

bool cmydlg::oninitdialog()

} // 設定對話方塊圖示。

// 當應用程式的主視窗不是對話方塊時,框架會自動設定圖示。

seticon(m_hicon, true); // 設定大圖示

seticon(m_hicon, false); // 設定小圖示

return true; // return true unless you set the focus to a control

}void cmydlg::onsyscommand(uint nid, lparam lparam)

else

}// 如果在對話方塊上新增最小化按鈕,必須用cmydlg::onpaint() 繪製圖示,

// mfc 用文件/檢視模型,由框架自動處理。

void cmydlg::onpaint()

else

}// 當使用者要求最小化視窗時,系統呼叫此函式獲取要顯示的圖示。

hcursor cmydlg::onquerydragicon()

以上是主要的源**清單, 下面對關鍵部分作一說明:

如果在**中加上這行,那麼對話方塊無法隱藏。這一點是一般想不到的訣竅,在預設的情況下,vc++ 的 ide 在工程資源檔案中會有這樣一行式樣描述:

全屏顯示對話方塊,(隱藏工作列)

在oninitdialog 中加入,如下code 如果在建立的對話方塊帶有標題欄使用 cwnd pwnd pwnd getdesktopwindow 得到桌面視窗指標 crect rt pwnd getwindowrect rt modifystyle ws caption,0,0 setwindo...

MFC 讓對話方塊不顯示在工作列和桌面

工作列隱藏 或者 windowplacement wp wp.length sizeof windowplacement wp.flags wpf restoretomaximized wp.showcmd sw hide setwindowplacement wp 在ie版本為4.0以上的系統中有...

VC 隱藏工作列,實現對話方塊的全屏顯示

這裡我選用實現對話方塊的全屏的方案是 1 隱藏工作列 2 將對話方塊最大化顯示並且去掉標題欄 一 單獨隱藏工作列,很容易實現 缺陷 隱藏後工作列所佔據的空間還是沒有騰出來 如下 hwnd hwnd hwnd findwindow shell traywnd null showwindow hwnd,...