對話方塊上建立CWnd 視窗

2021-05-23 15:56:58 字數 664 閱讀 8862

先例項化個cwnd或

寫個類基於cwnd 再例項化;

class cmywnd:pubilc cwnd

在對話方塊檔案中加入

cwnd m_mywnd;

crect rc;

rc.setrect(0, 0, 290, 250);

dword dwstyle = ws_caption|ws_sysmenu|ws_visible|ws_child|ws_border;

bool b = m_mywnd.create(null, l"mywnd", dwstyle, rc, this, id_mywnd);

m_mywnd.showwindow(sw_show);

或crect rect;

rect.setrect(0, 0, 100, 20);

dword style = ws_child|ws_caption|ws_sysmenu|ws_visible|ws_child|ws_border;

cwnd * pwnd = new cwnd;

pwnd->create(l"button", l"hi", ws_child | ws_visible,

crect(0, 0, 100, 20), &m_mywnd, 1234);

pwnd->showwindow(sw_show); 

改變對話方塊上的字型顏色的大小

首先在類嚮導裡面,對映乙個成員變數,然後在該類的初始化函式中寫出以下 主要是建立乙個字型 然後用對映的成員變數呼叫setfont 就可以了。設定對話方塊上的字型 cfont f f new cfont f createfont 16,nheight 0,nwidth 0,nescapement 0,...

對話方塊上自定義繪製文字

以下 放置在onpaint 的else中,刪除原來else中的內容 文字 int itheight 200 文字高度 int itwidth 200 文字寬度 int ix 640 繪製區域的開始位置x int iy 150 繪製區域的開始位置y int icx ix itwidth 繪製區域的寬度...

MFC選單資源ID載入到對話方塊上

方法1 首先定位到顯示選單欄對話方塊的oninitdialog 函式處,在其函式體裡新增如下 cmenu menu menu.loadmenuw idr menu1 載入資源選單欄,idr menu1為資源檢視裡選單的id this setmenu menu 這個函式將當前選單設為指定的選單。它使視...