[主程式入口.cpp]#include #include #include "resource.h"
//這個還沒用到,就先注釋起來
//hinstance m_hinstance;
hwnd m_hwnd;
int winapi winmain(_in_ hinstance hinstance, _in_opt_ hinstance hprevinstance, _in_ lpstr lpcmdline, _in_ int nshowcmd)
//對話方塊父類的宣告.h
[cwindialog.h]
#pragma once
#include #include class cwindialog
;// 對話方塊父類的實現.cpp
[cwindialog.cpp]
#include "cwindialog.h"
cwindialog::cwindialog(dword _idd)
cwindialog::~cwindialog()
//建立和顯示對話方塊
hwnd cwindialog::showdialog()
return m_hwnd;
}int_ptr callback cwindialog::windlgprce(hwnd hwnd, uint umsg, wparam wparam, lparam lparam)
//就是用這種另外寫乙個成員的**函式,所有的訊息函式都寫在這裡面
//原來的**函式只相當於傀儡.
int_ptr callback cwindialog::mywindlgprce(hwnd hwnd, uint umsg, wparam wparam, lparam lparam)
case wm_close:
destroywindow(hwnd);
return 0;
case wm_destroy:
postquitmessage(0);
return 0;
case wm_contextmenu:
onrclick(wparam,lparam);
return 1; }
return defwindowproc(hwnd, umsg, wparam, lparam);
}bool cwindialog::oninitdlg()
bool cwindialog::onrclick(wparam wparam, lparam lparam)
bool cwindialog::oncommand(wparam wparam, lparam lparam)
//子類的宣告檔案.h
#pragma once
#include "cwindialog.h"
#include "resource.h"
public cwindialog
;//子類的實現
; col.cchtextmax = 256;
col.mask = lvcf_text | lvcf_width | lvcf_fmt;
col.fmt = lvcfmt_left;
col.cx = colwith;
col.psztext =(lptstr) colname;
col.isubitem = ncol;
return (int)sendmessage(hlist, lvm_insertcolumn, ncol, (lparam)&col);};
item.mask = lvcf_text | lvcf_fmt;
item.iitem = nitem;
item.isubitem = 0;
item.psztext = (lptstr)lpsztext;
return(int)sendmessage(hlist, lvm_insertitem, 0, (lparam)&item);};
lvi.isubitem = nsubitem;
lvi.psztext = (lptstr)lpsztext;
return (bool)sendmessage(hlist, lvm_setitemtext, nitem, (lparam)&lvi);
} return true;
} case i_popumenu_del: //選單刪除訊息
break:
//....其他選單命令訊息
Win32新增對話方塊
模態對話方塊 在要顯示對話方塊的地方 dialogbox hinstance,實力控制代碼 makeintresource idd dialog1 對話方塊資源id hwnd,父視窗控制代碼 dlgproc 處理的視窗過程函式 視窗處理過程函式 bool callback dlgproc hwnd ...
Win32 對話方塊 3
onctlcolor ctlcolor dlg hbrush cdemodlg onctlcolor cdc pdc,cwnd pwnd,uint nctlcolor return hbr 根據控制項id更改,這個事件一直觸發 hbrush cdemodlg onctlcolor cdc pdc,c...
Win32 對話方塊 2
修改樣式 調整屬性面板的border屬性 使用movewindow方法調整大小 void cdemodlg ontest else 設定視窗大小 movewindow rect 呼叫centerwindow方法 居中顯示視窗 centerwindow 這個是啥 不懂 就是隱藏窗體,但不是銷毀 voi...