| 发表于:2007-08-23 09:02:567楼 得分:0 |
// dlg.cpp : defines the entry point for the application. // #include "stdafx.h " #include "resource.h " bool callback dlgfunc(hwnd, uint, wparam, lparam); lresult callback buttonproc(hwnd,uint,wparam,lparam); lresult callback editproc(hwnd,uint,wparam,lparam); hwnd hdlgmodeless; hinstance hins; wndproc oldbutton,oldedit ; int winapi winmain(hinstance hinstance, hinstance hprevinstance, lpstr lpcmdline, int ncmdshow) { hdlgmodeless=createdialog(hinstance,makeintresource(idd_dialog1),null,dlgfunc); showwindow (hdlgmodeless, sw_show) ; hins=hinstance; msg msg; while(getmessage(&msg,null,0,0)) { if(hdlgmodeless==0 ¦ ¦!isdialogmessage(hdlgmodeless,&msg)) { translatemessage(&msg); dispatchmessage(&msg); } } return msg.wparam; } bool callback dlgfunc(hwnd hwnd, uint message , wparam wparam, lparam lparam) { static hwnd hwndsmaller, hwndlarger ; static hwnd hedit; static hinstance hh; switch(message) { case wm_initdialog: hh = (hinstance) getwindowlong (hwnd, gwl_hinstance) ; hedit = createwindow (text ( "edit "), text ( "bianji "), ws_child ¦ ws_visible , 110, 50, 50, 30, hdlgmodeless, (hmenu) id_new_edit,hh, null) ; return true; case wm_command: switch(loword(wparam)) { case idcancel: hwndsmaller = createwindow (text ( "button "), text ( "pp "), ws_child ¦ ws_visible , 50, 50, 50, 30, hdlgmodeless, (hmenu) id_smaller, hins, null) ; oldbutton=(wndproc) setwindowlong(hwndsmaller,gwl_wndproc,(long)buttonproc); hedit = createwindow (text ( "edit "), text ( "bianji "), ws_child ¦ ws_visible , 110, 50, 50, 30, hdlgmodeless, (hmenu) id_new_edit, hins, null) ; oldedit=(wndproc) setwindowlong(hedit,gwl_wndproc,(long)editproc); return true; case idok: destroywindow(hdlgmodeless); hdlgmodeless=0; ::postquitmessage(0); return true; } } return false; } lresult callback buttonproc(hwnd hwnd,uint message,wparam wparam,lparam lparam) { // int id = getwindowlong (hwnd, gwl_id) ; switch (message) { case wm_lbuttondown : break ; case wm_rbuttondown : messagebox(hdlgmodeless, "右键按下 ", "鼠标右键 ",1); break ; } return callwindowproc (oldbutton, hwnd, message, wparam, lparam) ; // return 1; } lresult callback editproc(hwnd hwnd,uint message,wparam wparam,lparam lparam) { switch (message) { case wm_lbuttondown : break ; case wm_rbuttondown : messagebox(hdlgmodeless, "右键按下 ", "鼠标右键 ",1); break ; } return callwindowproc (oldedit, hwnd, message, wparam, lparam) ; // return 1; } 都在了,有什么不对的地方请指出?? | | |
|