iczelion tut32[6]

[入库:2005年8月19日] [更新:2007年3月24日]

本文简介:选择自 jimgreen 的 blog

i'll review the steps in creating an mdi application for you again below.

  1. register the window classes, both the frame window class and the mdi child window class
  2. create the frame window with createwindowex.
  3. within the message loop, call translatemdisysaccel to process the mdi-related accelerator keys
  4. within the window procedure of the frame window, call defframeproc to handle all messages unhandled by your code.
  5. create the client window by calling createwindowex using the name of the predefined window class, "mdiclient", passing the address of a clientcreatestruct structure in lparam. normally, you would create the client window within the wm_create handler of the frame window proc
  6. you can create an mdi child window by sending wm_mdicreate to the client window or, alternatively, by calling createmdiwindow.
  7. within the window proc of the mdi child window, pass all unhandled messages to defmdichildproc.
  8. use mdi version of the messages if it exists. for example, use wm_mdidestroy instead of calling destroywindow

example:

.386 
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\user32.inc include \masm32\include\kernel32.inc includelib \masm32\lib\user32.lib includelib \masm32\lib\kernel32.lib winmain proto :dword,:dword,:dword,:dword .const idr_mainmenu equ 101 idr_childmenu equ 102 idm_exit equ 40001 idm_tilehorz equ 40002 idm_tilevert equ 40003 idm_cascade equ 40004 idm_new equ 40005 idm_close equ 40006 .data classname db "mdiasmclass",0 mdiclientname db "mdiclient",0 mdichildclassname db "win32asmmdichild",0 mdichildtitle db "mdi child",0 appname db "win32asm mdi demo",0 closepromptmessage db "are you sure you want to close this window?",0 .data? hinstance dd ? hmainmenu dd ? hwndclient dd ? hchildmenu dd ? mdicreate mdicreatestruct <> hwndframe dd ? .code start: invoke getmodulehandle, null mov hinstance,eax invoke winmain, hinstance,null,null, sw_showdefault invoke exitprocess,eax winmain proc hinst:hinstance,hprevinst:hinstance,cmdline:lpstr,cmdshow:dword local wc:wndclassex local msg:msg ;============================================= ; register the frame window class ;============================================= mov wc.cbsize,sizeof wndclassex mov wc.style, cs_hredraw or cs_vredraw mov wc.lpfnwndproc,offset wndproc mov wc.cbclsextra,null mov wc.cbwndextra,null push hinstance pop wc.hinstance mov wc.hbrbackground,color_appworkspace mov wc.lpszmenuname,idr_mainmenu mov wc.lpszclassname,offset classname invoke loadicon,null,idi_application mov wc.hicon,eax mov wc.hiconsm,eax invoke loadcursor,null,idc_arrow mov wc.hcursor,eax invoke registerclassex, addr wc ;================================================ ; register the mdi child window class ;================================================ mov wc.lpfnwndproc,offset childproc mov wc.hbrbackground,color_window+1 mov wc.lpszclassname,offset mdichildclassname invoke registerclassex,addr wc invoke createwindowex,null,addr classname,addr appname,\ ws_overlappedwindow or ws_clipchildren,cw_usedefault,\ cw_usedefault,cw_usedefault,cw_usedefault,null,0,\ hinst,null mov hwndframe,eax invoke loadmenu,hinstance, idr_childmenu mov hchildmenu,eax invoke showwindow,hwndframe,sw_shownormal invoke updatewindow, hwndframe .while true invoke getmessage,addr msg,null,0,0 .break .if (!eax) invoke translatemdisysaccel,hwndclient,addr msg .if !eax invoke translatemessage, addr msg invoke dispatchmessage, addr msg .endif .endw invoke destroymenu, hchildmenu mov eax,msg.wparam ret winmain endp wndproc proc hwnd:hwnd, umsg:uint, wparam:wparam, lparam:lparam local clientstruct:clientcreatestruct .if umsg==wm_create invoke getmenu,hwnd mov hmainmenu,eax invoke getsubmenu,hmainmenu,1 mov clientstruct.hwindowmenu,eax mov clientstruct.idfirstchild,100 invoke createwindowex,null,addr mdiclientname,null,\ ws_child or ws_visibl

本文关键:iczelion asm
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top