當前位置:編程學習大全網 - 網站源碼 - 求VC++中生成按鈕的源代碼

求VC++中生成按鈕的源代碼

// 動態構建按鈕代碼

CButton* pNewButton = new CButton();// 也可以定義為類的成員變量。

CRect rcButton( 10, 10, 50, 30); // 按鈕在對話框中的位置。

pNewButton->Create("按鈕", 0, rcButton, this, 10098);

pNewButton->ShowWindow(SW_SHOW);

// 添加按鈕消息代碼。

重載對話框的 WindowProc 消息處理函數

加如下代碼——這個要實現添加

if ( WM_COMMAND== message )

{

WORD wID = LOWORD(wParam);

if ( 10098 == wID)

{

CDC* pDC = GetDC();

pDC->TextOut( 100, 100, "文字");

ReleaseDC(pdc);

}

}

  • 上一篇:django的管理源代碼
  • 下一篇:魔法小天使 歌詞
  • copyright 2024編程學習大全網