³o¤@³¹ÁÙ¬O½Í¥\¯àªí¡A¦ý¬O§ï¥Î¥H©I¥s CreateMenu¡BInsertMenuItem¡BSetMenu µ¥ Win64 API ¨Ó«Ø¥ß¥D¥\¯àªí¡A¦Ó¤£¨Ï¥Î¸ê·½´yzÀɤ¤ªº MENU °Ï¶ô¡C¥H«eªÌ¤è¦¡«Ø¥ßªº¥\¯àªí¡A¸û¬°ÆF¬¡¡A¥i¥H¥´³y¨ã¦³«È»s¤Æ¯S¦âªº¥\¯àªí¡A¯ÊÂI¤]¬OÅã¦Ó©ö¨£ªº¡A¨º´N¬O½ÆÂø¡C¦b¶i¤J¥DÃD¤§«e¡A¥ý¤¶²Ð³o¤@³¹·|¥Î±o¨ìªº Win64 API¡C
CreateMenu ·|«Ø¥ß¤@Ó¥\¯àªí¡A¦¹¥\¯àªí³Ìªì¬OªÅªº¡A¤@µL©Ò¦³¡AÀ³¥Îµ{¦¡¥i¥H©I¥s InsertMenuItem¡BAppendMenu¡BInsertMenu ¦b³o·s«Øªº¥\¯àªí²K¥[¤À¹j½u¡B¿ï¶µ¡B¼u¥X¿ï¶µ¡CCreateMenu ¨S¦³°Ñ¼Æ¡A¨ä쫬¬O¡G
call CreateMenu
invoke °²«ü¥O¡]¹ï UASM ¦Ó¨¥¡^©Î¥¨¶°¡]¹ï MASM64 SDK ¦Ó¨¥¡^¬O¥Î¨Ó±N°Ñ¼Æ¦s¤J¼È¦s¾¹©Î°ïÅ|¤¤¡A³Ì«á¤@©w·|°õ¦æ CALL «ü¥O¡C©I¥s CreateMenu ®É¡A¦]¬°¨S¦³°Ñ¼Æ¡A©Ò¥H¥i¥Hª½±µ¨Ï¥Î CALL¡A·íµM¤]¥i¥H¨Ï¥Î invoke¡C¦pªG CreateMenu ¦¨¥\«Ø¥ß¥\¯àªí¡A¦^¶ÇȬO¨ä«Ø¥ß¦nªº¥\¯àªí¥N½X¡F¦pªG¥¢±Ñ¡A¦^¶ÇȬO¹s¡C
¦b¥\¯àªí¤¤¥[¤J·sªº¤À¹j½u¡B¿ï¶µ¡B¼u¥X¿ï¶µ¡C
invoke InsertMenuItem,\ hMenu,\ ; handle to menu to be changed uItem,\ ; identifier or position fByPosition,\ ; value specifying the meaning of uItem lpmii ; pointer to a MENUITEMINFO structure
¦pªG InsertMenuItem °õ¦æ¦¨¥\¡A¦^¶ÇȬ°«D¹s¡F¤Ï¤§¦^¶ÇȬ°¹s¡C©³¤U»¡©ú¦U¶µ°Ñ¼Æªº·N¸q¡G
°£¤F InsertMenuItem ¨Ï¥Î MENUITEMINFO µ²ºcÅ餧¥~¡AÁÙ¦³ GetMenuItemInfo »P SetMenuItemInfo ¤]¨Ï¥Î¡C©³¤U¬O MENUITEMINFO ¤ºªº¦UÄæ¦ì¡]µù¤@¡^¡G
MENUITEMINFO STRUCT cbSize DWORD ? ;MENUITEMINFO ªºªø«×¡A¥H¦ì¤¸²Õ³æ¦ì fMask DWORD ? ;ºX¼Ð¡A«ü©wn¦s¨ú MENUITEMINFO ¤¤ªºþ¤@Äæ fType DWORD ? ;¿ï¶µÃþ«¬ fState DWORD ? ;¿ï¶µª¬ºA wID DWORD 2 DUP(?) ;¿ï¶µÃѧO½X hSubMenu HMENU ? ;¤l¥\¯àªí¥N½X hbmpChecked HBITMAP ? ;¤Ä¿ï¤§¿ï¶µ«eªº¦ì¤¸¹Ï hbmpUnchecked HBITMAP ? ;¥¼¤Ä¿ï¤§¿ï¶µ«eªº¦ì¤¸¹Ï dwItemData ULONG_PTR ? ;À³¥Îµ{¦¡¦Û¦æ³]©wªº¸ê®Æ dwTypeData LPSTR ? ;¿ï¶µ¤å¦r©Î¹Ï¤ù cch DWORD 2 DUP (?) ;¿ï¶µ¦r¦êªø«× hbmpItem HBITMAP ? ;¥H¦ì¤¸¹Ï¥N´À¿ï¶µ¦r¦ê MENUITEMINFO ENDS
MENUITEMINFO µ²ºcÅé«Ü½ÆÂø¡A©³¤U»¡©ú¦UÄæ¦ìªº·N¸q¡C³Ì²³æªº¬O²Ä¤@ÓÄæ¦ì¡AcbSize¡A¬O«ü MENUITEMINFO µ²ºcÅé¤j¤p¡A³æ¦ì¬O¦ì¤¸²Õ¡A¦b©I¥s InsertMenuItem «e¥²¶·³]©w cbSize Äæ¦ì¡AWindows ¾a¦¹¼ÆȧPÂ_¨Ï¥ÎþÓª©¥»ªº API¡CY¨S³]¦n cbSize¡A´N·|µo¥Í¿ù»~¡C
²Ä¤GÓÄæ¦ì¡AfMask¡A¨M©w¤F InsertMenuItem¡BGetMenuItemInfo »P SetMenuItemInfo ·|¨Ï¥Î MENUITEMINFO ¤¤ªºþ¨ÇÄæ¦ì¡A¦Ó¨ä¥LÄæ¦ìµL¥Î¡C¨Ò¦p©I¥s InsertMenuItem ¤§«e¡A§â fMask ¬° MIIM_ID¡A¨º´N¥²¶·¦P®É§â wID Äæ¦ì³]¬°¿ï¶µÃѧO½X¡A³o¼Ë©I¥s¤§«á´N¯à§â·s¥[¤Jªº¿ï¶µ³]¦n¿ï¶µÃѧO½X¡F¦pªG©I¥s GetMenuItemInfo ¤§«e¡AfMask ¬° MIIM_ID¡A©I¥s«á¨t²Î·|§â¿ï¶µÃѧO½X¦s¤J¨ì wID Äæ¦ì¤¤¡C
©³¤U¬O fMask Äæ¦ì¥i¥H³]©wªº¼ÆÈ¡A¦pªGn¤@¦¸³]©w©Î¬O±o¨ì¬Y¿ï¶µªº¼ÆºØ¸ê®Æ¡A¥i¥H¥Î¡uOR¡v¹Bºâ¤l³s±µ¡A¦ý¦¹ OR ¨Ã«D x64 CPU «ü¥O¡A¦Ó¬O²ÕĶ¾¹°õ¦æªº¹Bºâ¤l¡C
fMask | À³³]©w©Î Àò¨úªºÄæ¦ì | »¡¡@©ú |
MIIM_BITMAP 80H | hbmpItem | ¦b¿ï¶µ¤¤Åã¥Ü¦ì¤¸¹Ï¡AnÅã¥Üªº¦ì¤¸¹Ï¥N½X¦s©ó hbmpItem Äæ¦ì¤¤¡A¦ì¤¸¹Ï¥N½X¥i¥H¥Ñ¸ê·½¤¤¸ü¤J¡A¤]¥i¥H¬O¤º«Øªº¦ì¤¸¹Ï¡A¨Ò¦p HBMMENU_MBAR_CLOSE¡BHBMMENU_MBAR_MINIMIZE¡A¤À§O¬OÃö³¬¡B³Ì¤p¤Æªº¦ì¤¸¹Ï¡A§ó¦hªº¤º«Ø¦ì¤¸¹Ï½Ð¬d¾\ MSDN¡ChbmpItem ¤]¥i¥H¬O HBMMENU_CALLBACK¡A¥Nªí¾Ö¦³ªÌø»s¿ï¶µ¡AÀ³¥Îµ{¦¡¥²¶·³B²z WM_MEASUREITEM ©Î WM_DRAWITEM °T®§¡C |
MIIM_CHECKMARKS 8H | hbmpChecked hbmpUnchecked |
MIIM_CHECKMARKS ¬O³]©w¤Ä¿ïªº©Î¥¼¤Ä¿ïªº¦ì¤¸¹Ï¡A¦¹¦ì¤¸¹Ï·|Åã¥Ü¦b¤Ä¿ïªº©Î¥¼¤Ä¿ïªº¿ï¶µ¤å¦r¤§«e¡ChbmpChecked «ü©w¤Ä¿ï®É©ÒÅã¥Üªº¦ì¤¸¹Ï¤§¥N½X¡FhbmpUnchecked «ü©w¥¼¤Ä¿ï®É©ÒÅã¥Üªº¦ì¤¸¹Ï¤§¥N½X¡C¦pªG¿ï¶µª¬ºA¬O¤Ä¿ï¡A·|Åã¥Ü hbmpChecked ©Ò«ü©wªº¦ì¤¸¹Ï¡A¦ý¦pªG hbmpChecked ¬°¹s¨º»ò´N·|Åã¥Ü¹w³]¹Ï¡]§Y✔¡^¡F¦pªG¿ï¶µª¬ºA¬O¥¼¤Ä¿ï¡A·|Åã¥Ü hbmpUnchecked ©Ò«ü©wªº¦ì¤¸¹Ï¡A¦ý¦pªG hbmpUnchecked ¬°¹s¨º»ò´N¤£Åã¥Ü¦ì¤¸¹Ï¡C |
MIIM_DATA 20H | dwItemData | Win64 ¨t²Î¤¤¡AdwItemData ªº¸ê®ÆÃþ«¬¬O ULONG_PTR¡Aªø«×¬O 64 ¦ì¤¸¡C³]©w MIIM_DATA ¤§«á¡AdwItemData ¥i³]¬°¬Y¨Ç¸ê®Æªº¦ì§}¡A·í WM_DRAWITEM °T®§¶Çµ¹µøµ¡¨ç¦¡®É¡AdwItemData ¤§È·|«O¦s©ó¦¹°T®§¤¤ lParam ©Ò«ü DRAWITEMSTRUCT µ²ºcÅ骺 itemData Äæ¦ì¤º¡A¥i©ó¾Ö¦³ªÌø»s¿ï¶µ®É¨Ï¥Î¨º¨Ç¸ê®Æ¡C |
MIIM_FTYPE 100H | fType | ·í fMask ³]¬° MIIM_FTYPE ®É¡A¶·©ó fType Äæ¦ì«ü©w©ÎªÌÀò¨ú¿ï¶µÃþ«¬¡A¿ï¶µÃþ«¬¥i¥H¬O¤U±¼ÆÈ¡A©Î¬O¬Û¤¬¶¡¥H OR ¹Bºâ¤l¹Bºâªºµ²ªG¡A¦ý¬O¤£¯à¦P®É«ü©w MFT_BITMAP¡BMFT_SEPARATOR¡BMFT_STRING¡C
|
MIIM_ID 2 | wID | ¦s¨ú wID Äæ¦ì¡C·í©I¥s InsertMenuItem¡BSetMenuItemInfo «e¡A¶·§â wID ³]©w¬°¿ï¶µÃѧO½X¡F©I¥s GetMenuItemInfo «á¡AwID ·|¦s¦³¿ï¶µÃѧO½X¡C |
MIIM_STATE 1 | fState | ¥u¦³·í fMask ³]¬° MIIM_STATE ®É¡A«ü©w¿ï¶µª¬ºA¡A¥Ñ fState Äæ¦ìªí¥Üª¬ºA¡A¥i¥H¬O¤U±¼ÆÈ¡G
|
MIIM_STRING 40H | dwTypeData | ¦b¿ï¶µ¤¤Åã¥Ü¤å¦r¦r¦ê¡A¸Ó¦r¦ê¶·¥H¹sµ²§À¡A¨ä¦ì§}¦s©ó dwTypeData¡Ccch ¬°¦r¦êªø«×¡CMIIM_STRING ¥i¥H¨ú¥N MFT_STRING¡C |
MIIM_SUBMENU 4 | hSubMenu | ±N¬Y¤@¿ï¶µ³]¬°¼u¥X¿ï¶µ¡A¯àÅã¥Ü¤l¥\¯àªí¡C·í fMask «ü©w¤F MIIM_SUBMENU ®É¡A¶·¦P®É©ó hSubMenu «ü©w¤l¥\¯àªí¤§¥N½X¡A±N¸Ó¤l¥\¯àªíªþ¦b InsertMenuItem¡BSetMenuItemInfo ªº²Ä¤@ӰѼơAhMenu¡A¤§¤U¡C |
MIIM_TYPE 10H | fType dwTypeData |
¥²¶·³]©w fType »P dwTypeData¡A°Ñ¦Ò MIIM_BITMAP¡BMIIM_FTYPE »P MIIM_STRING¡A¦]¬° MIIM_TYPE ±N³v¨B³Q«e¤TªÌ¨ú¥N¡C |
°²³]n¦b¬YÓ¥\¯àªí¤º·s²K¤@¿ï¶µ¡A³q±`·|¦P®É³]©w¿ï¶µ¤å¦r»P¿ï¶µÃѧO½X¡A¨º»ò´N·|¨Ï¥Î¤U±µ{¦¡½X¡G
mov mii.fMask,MIIM_STRING or MIIM_ID mov mii.wID,¿ï¶µÃѧO½X lea r10,¦r¦êÅÜ¼Æ mov mii.dwTypeData,r10 invoke InsertMenuItem,hMenu,0,TRUE,ADDR mii
¤W±²Ä¤@¦æµ{¦¡½X¤¤ªº MIIM_STRING ±`¼Æ¬° 40H¡A´«ºâ¬°¤G¶i¦ì¬O 0100 0000¡FMIIM_ID ¬° 2¡A¤G¶i¦ì¬O 0010¡A¸g¹L¡uOR¡v¹Bºâ¤§«á¬° 0100 0010¡A¸g¥Ñ MENUITEMINFO ±N¦¹¸ê®Æ¶Çµ¹ InsertMenuItem¡AInsertMenuItem ´N¯àª¾¹D¨Ï¥ÎªÌn·s²Kªº¿ï¶µ¨ã¦³þ¨Ç©Ê½è¡C¦b Windows µ{¦¡³]p¤¤¡A¦³³\¦hÃþ¦ü³o¼Ëªº±`¼Æ¡A³£ºÙ¤§¬°ºX¼Ð¡A¥¦Ì¥Nªí¤F¬YӦ줸¡AY¬°¤@ªí¥Ün¨M©w¤F¬YÓª«¥óªº©Ê½è¡AY¬°¹sªí¥Ü¨S¦³¦¹©Ê½è¡C
SetMenuItemInfo ¬O¥Î¨Ó§ïÅܿﶵ¬Y¨ÇÄÝ©Ê¡A¨ä쫬¬°¡G
invoke SetMenuItemInfo,\ hMenu,\ ; handle to menu to be changed uItem,\ ; identifier or position fByPosition,\ ; value specifying the meaning of uItem lpmii ; pointer to a MENUITEMINFO structure
SetMenuItemInfo ªº°Ñ¼Æ»P InsertMenuItem ¬Û¦P¡A·N¸q¤]³£¬Û¦P¡A®t§O¦b©ó«eªÌ¬O§ïÅܲ{¦³¿ï¶µªºÄÝ©Ê¡A«áªÌ¬O¨S¦³³oӿﶵ¦Ó·s¥[¤J³oӿﶵ¡A¶¶±a³]©w¦nÄÝ©Ê¡C©³¤U¬O³o¨Ç°Ñ¼Æªº»¡©ú¡G
¦pªG SetMenuItemInfo °õ¦æ¦¨¥\¡A¦^¶ÇȬ°«D¹s¡F¦pªG°õ¦æ¥¢±Ñ¡A¦^¶ÇȬ°¹s¡C·í©I¥s SetMenuItemInfo ¦¨¥\«á¡AÀ³©I¥s DrawMenuBar «·sø»s¥\¯àªí¡A¥HÅã¥Üקï¹Lªº¿ï¶µ¡C
DrawMenuBar ¥Î¨Ó«·sø»s¥\¯àªí¡A³q±`¬O²K¥[¡B§R°£©Î§ó§ï¥\¯àªíÄÝ©Ê¡]¦p±Ò¥Î©Î¸T¥Î¿ï¶µ¡^¡A¬Æ¦Ü¬O¤Á´«¤£¦P¥\¯àªí¡A¦Ó¨Ï±o¥\¯àªíµo¥ÍÅܤƪº®ÉÔ¡A¥²¶·©I¥s DrawMenuBar §ó·s¥\¯àªí¥~Æ[¡A§_«h¥i¯à¤£·|Åܧó¥\¯àªí¥~Æ[¡CDrawMenuBar ªºì«¬¬O¡G
invoke DrawMenuBar,\
hWnd ; handle to window with menu bar to redraw
hWnd ¬O»Ýn§ó·s¥\¯àªí¥~Æ[ªºµøµ¡¤§µøµ¡¥N½X¡C¦pªG DrawMenuBar ¦¨¥\°õ¦æ¡A¦^¶ÇȬ°«D¹s¡FY¥¢±Ñ¡A¦^¶ÇȬ°¹s¡C
³o¤@³¹ªº¨Ò¤l¬O DRAW5¡A¥¦ªº¥D¥\¯àªí¤£¨Ï¥Î¸ü¤J¸ê·½¤¤ªº MENU ¸ê·½¡A¦Ó§ï¥Î©I¥s CreateMenu¡BSetMenu¡BInsertMenuItem «Ø¥ß¡A¥¦¤]¬O¥H²Ä¤Q¤»³¹ªº DRAW2 ¶i¦æקï¦Ó¦¨¡C¥Ñ©ó¥uקﳡ¤À¤º®e¡A©Ò¥H DRAW5 »P DRAW2 ¤j¦P¤p²§¡A©³¤U¥u¦C¥X«n¥B¤£¦Pªº³¡¤À¡A§¹¾ãªºì©lÀɮ׽Шì³oùؤU¸ü¡C±N¨ä¤¤ªº DRAW5.ASM »P DRAW5.RC ©ñ¦b¦P¤@¤l¥Ø¿ý¡A²ÕĶ¤èªk»P²Ä¤Q¤»³¹ªº DRAW2 ¬Û¦P¡A¤£«½Æ±Ôz¡C
1 ⁝ 25 26 27
28 29 30 31 32
33 34 35 36 37
38 39 40 41 42
43 44 45 46 47
48 49 50 51 52
53 54 55 56 57
58 59 60 61 62
63 64 65 ⁝
201 202 203 204 205
206 207 208 209 210
211 212 213 214 215
216 217 218 219 220
221 222 223 224 225
226 227 228 229 230
231 232 233 234 235
236 237 238 239 240
241 242 243 244 245
246 247 248 249 250
251 252 253 254 255
256 257 258 259 260
261 262 263 264 265
266 267 268 269 270
271 272 273 274 275
276 277 278 279 280
281 282 283 284 285
286 287 288 289 290
291 ⁝ 363 364 |
;©I¥s CreateMenu¡BInsertMenuItem¡BSetMenu«Ø¥ß¥D¥\¯àªí¡A¤£¥ÎMENU°Ï¶ô
⁝
;©³¤U¬OWinInc¨S¦³«Å§iªº±`¼Æ¥H¤Î§ó¥¿«áMENUITEMINFOµ²ºcÅé
MIIM_STRING EQU 40H
MIIM_BITMAP EQU 80H
MIIM_FTYPE EQU 100H
MY_MENUITEMINFO STRUCT
cbSize DWORD ?
fMask DWORD ?
fType DWORD ?
fState DWORD ?
wID DWORD 2 DUP(?)
hSubMenu HMENU ?
hbmpChecked HBITMAP ?
hbmpUnchecked HBITMAP ?
dwItemData ULONG_PTR ?
dwTypeData LPSTR ?
cch DWORD 2 DUP (?)
hbmpItem HBITMAP ?
MY_MENUITEMINFO ENDS
;*****************************************************************************************
.CONST
szIconName LABEL BYTE
szClassName DB "DRAW5",0
szAppName DB "¶W²³æø¹Ï",0
szText DB "DRAW5¶È¯àø»s¾ò¶ê»P¤âø¹Ï",0dh,0ah,"¡A¥B¤£¯à¦sÀɤ]¤£¯à½s¿è¡C",0
szMouseFmt DB "(%03d,%03d)",0
szColor DB "¶Â¦â¬õ¦âºñ¦âÂŦâ"
szClear DB 5 DUP ("¡@")
szQuit DB "Â÷¶}",0
szView DB "À˵ø",0
szXy DB "®y¼Ð",0
szPenColor DB "µeµ§ÃC¦â",0
szDraw DB "ø¹Ï",0
szEllipse DB "¾ò¶ê",0
szTrace DB "¤âø¹Ï",0
szBlack DB "¶Â",0
szRed DB "¬õ",0
szGreen DB "ºñ",0
szBlue DB "ÂÅ",0
szHelp DB "À°§U",0
;*****************************************************************************************
⁝
.case WM_CREATE
;«Ø¥ß¥\¯àªí¡A¨Ã±N¨ä³]¬°¥D¿ï³æ
call CreateMenu
mov hMenu,rax
invoke SetMenu,hWnd,hMenu
;¦b¥D¥\¯àªí¤¤´¡¤J¡uÂ÷¶}¡v¿ï¶µ
mov mii.cbSize,SIZEOF mii
mov mii.fMask,MIIM_STRING or MIIM_ID
lea r10,szQuit
mov mii.wID,IDM_QUIT
mov mii.dwTypeData,r10
invoke InsertMenuItem,hMenu,0,TRUE,ADDR mii
;¦b¥D¥\¯àªí¤¤´¡¤J¡uÀ˵ø¡v¤l¥\¯àªí
call CreateMenu
mov hViewSubMenu,rax
mov mii.fMask,MIIM_SUBMENU or MIIM_STRING
lea r11,szView
mov mii.hSubMenu,rax
mov mii.dwTypeData,r11
invoke InsertMenuItem,hMenu,1,TRUE,ADDR mii
;¦b¥D¥\¯àªí¤¤´¡¤J¡uø¹Ï¡v¤l¥\¯àªí
call CreateMenu
mov hDrawSubMenu,rax
lea r10,szDraw
mov mii.hSubMenu,rax
mov mii.dwTypeData,r10
invoke InsertMenuItem,hMenu,2,TRUE,ADDR mii
;¦b¥D¥\¯àªí¤¤´¡¤J¡uÀ°§U¡v¿ï¶µ
mov mii.fMask,MIIM_TYPE or MIIM_ID
mov mii.fType,MFT_STRING or MFT_RIGHTJUSTIFY
lea r11,szHelp
mov mii.wID,IDM_HELP
mov mii.dwTypeData,r11
invoke InsertMenuItem,hMenu,3,TRUE,ADDR mii
;¦b¡uÀ˵ø¡v¤l¥\¯àªí¤¤´¡¤J¡u®y¼Ð¡v¿ï¶µ
mov mii.fMask,MIIM_STRING or MIIM_ID or MIIM_STATE
mov mii.fState,MFS_CHECKED
lea r10,szXy
mov mii.wID,IDM_XY
mov mii.dwTypeData,r10
invoke InsertMenuItem,hViewSubMenu,0,TRUE,ADDR mii
;¦b¡uÀ˵ø¡v¤l¥\¯àªí¤¤´¡¤J¡uµeµ§ÃC¦â¡v¿ï¶µ
lea r11,szPenColor
mov mii.wID,IDM_COLOR
mov mii.dwTypeData,r11
invoke InsertMenuItem,hViewSubMenu,1,TRUE,ADDR mii
;¦b¡uø¹Ï¡v¤l¥\¯àªí¤¤´¡¤J¡u¾ò¶ê¡v¿ï¶µ
mov mii.fMask,MIIM_STRING or MIIM_ID
lea r10,szEllipse
mov mii.wID,IDM_ELLIPSE
mov mii.dwTypeData,r10
invoke InsertMenuItem,hDrawSubMenu,0,TRUE,ADDR mii
;¦b¡uø¹Ï¡v¤l¥\¯àªí¤¤´¡¤J¡u¤âø¹Ï¡v¿ï¶µ
mov mii.fMask,MIIM_STRING or MIIM_ID or MIIM_STATE or MIIM_FTYPE
lea r11,szTrace
mov mii.wID,IDM_TRACE
mov mii.dwTypeData,r11
mov mii.fState,MFS_CHECKED
mov mii.fType,MFT_RADIOCHECK
mov mii.hbmpChecked,0
invoke InsertMenuItem,hDrawSubMenu,1,TRUE,ADDR mii
;¦b¡uø¹Ï¡v¤l¥\¯àªí¤¤´¡¤J¤À¹j½u
mov mii.fMask,MIIM_FTYPE
mov mii.fType,MFT_SEPARATOR
invoke InsertMenuItem,hDrawSubMenu,2,TRUE,ADDR mii
;¦b¡uø¹Ï¡v¤l¥\¯àªí¤¤´¡¤J¡u¶Â¡v¿ï¶µ
mov mii.fMask,MIIM_STRING or MIIM_ID or MIIM_STATE or MIIM_FTYPE
lea r10,szBlack
mov mii.wID,IDM_BLACK
mov mii.dwTypeData,r10
mov mii.fState,MFS_CHECKED
mov mii.fType,MFT_RADIOCHECK
invoke InsertMenuItem,hDrawSubMenu,3,TRUE,ADDR mii
;¦b¡uø¹Ï¡v¤l¥\¯àªí¤¤´¡¤J¡u¬õ¡v¿ï¶µ
mov mii.fMask,MIIM_STRING or MIIM_ID
lea r11,szRed
mov mii.wID,IDM_RED
mov mii.dwTypeData,r11
invoke InsertMenuItem,hDrawSubMenu,4,TRUE,ADDR mii
;¦b¡uø¹Ï¡v¤l¥\¯àªí¤¤´¡¤J¡uºñ¡v¿ï¶µ
lea r10,szGreen
mov mii.wID,IDM_GREEN
mov mii.dwTypeData,r10
invoke InsertMenuItem,hDrawSubMenu,5,TRUE,ADDR mii
;¦b¡uø¹Ï¡v¤l¥\¯àªí¤¤´¡¤J¡uÂÅ¡v¿ï¶µ
lea r11,szBlue
mov mii.wID,IDM_BLUE
mov mii.dwTypeData,r11
invoke InsertMenuItem,hDrawSubMenu,6,TRUE,ADDR mii
;§ó·s¥D¿ï³æ¥~Æ[
invoke DrawMenuBar,hWnd
⁝
;*****************************************************************************************
END main |
DRAW5.ASM ²Ä 27¡ã29 ¦æ¡A«Å§i¤F¤TÓ±`¼Æ MIIM_STRING¡BMIIM_BITMAP¡BMIIM_FTYPE¡A¨ä¹ê¦b winuser.inc ¤¤¦³«Å§i³o¤TÓ±`¼Æ¡A¦ý¬O¦³±ø¥ó¡C¦b winuser.inc ¤¤«Å§i³o¤TÓ±`¼Æªºµ{¦¡¬O¡G
if (WINVER ge 0500h) MIIM_STRING EQU 00000040h MIIM_BITMAP EQU 00000080h MIIM_FTYPE EQU 00000100h ⁝ endif
¦]¦¹¡A¦pªG DRAW5.ASM ¤¤¡A¦b¡uINCLUDE WINDOWS.INC¡v¤§«e¡A¦³«Å§i¡uWINVER EQU 500H¡v©Î¤j©ó 500H¡A¨º»ò´N¥i¥H¬Ù²¤²Ä 27¡ã29 ¦æ¡C¨Æ¹ê¤W¡AWINVER ¥Nªí Windows ª©¥»¡AWINVER ¬° 500H¡A5 ¬O¥Dnª©¥»¡A00 ¬O¦¸nª©¥»¡A¥i¥H¬Ý¦¨ 5.00 ª©¡A³o¬O¦è¤¸ 2000 ¦~µo°âªº Windows 2000 ªº¤º³¡ª©¥»¡C¤]´N¬O»¡¡A³o¤TÓ±`¼Æ¦b Windows 2000 ¤§«á¤~¦³¤ä´©¡C¦Ü©ó MENUITEMINFO µ²ºcÅ骺¿ù»~½Ð°Ñ¦Òµù¤@¡C
±µ¤U¨Ó¬Ý©³¤Uªº²Ä 202¡ã205 ¦æ¡A³o¥|¦æ«ü¥O¬O©I¥s CreateMenu «Ø¥ßªÅªº¥\¯àªí¡A¦A©I¥s SetMenu ³]©w DRAW5 µøµ¡ªº¥\¯àªí¬°èè«Ø¥ßªº¥\¯àªí¡Cµ{¦¡¦p¤U¡G
;«Ø¥ß¥\¯àªí¡A¨Ã±N¨ä³]¬°¥D¿ï³æ
call CreateMenu
mov hMenu,rax
invoke SetMenu,hWnd,hMenu
±µ¤U¨Ó¬O¦b³o·s«Øªº¥\¯àªí¤¤¡A²K¥[¿ï¶µ¡B¼u¥X¿ï¶µ¡C³oùØȱo¤@´£ªº¬O¡A¦pªG«Ø¥ß¥\¯àªí¤§«á¡A¥ý¦bªÅªº¥\¯àªí²K¥[¿ï¶µ¡B¼u¥X¿ï¶µ¡A¦A©I¥s SetMenu ³]©w¥\¯àªí¤]¥i¥H¡C
DRAW5 ªº¥D¥\¯àªí¦³¨âӿﶵ¡B¨âÓ¼u¥X¿ï¶µ¡A¨Ï¥ÎªÌÂI¿ï¼u¥X¿ï¶µ·|¥X²{¤l¥\¯àªí¡A¦Ó³o¨Ç¤l¥\¯àªí¦³¨Ç¨ã✔ªº¤Ä¿ïª¬ºA¡A¦³¨Ç¨ã¦³●ªº¤Ä¿ïª¬ºA¡C©³¤U±N°w¹ï³o¨Ç¤£¦Pªºª¬ªp»¡©ú¦p¦ó©I¥s InsertMenuItem¡A§â¥¦Ì¥[¤J¿ï³æ¤º¡C¥ý»¡©ú³Ì²³æªº±¡ªp¡A¨S¦³¤Ä¿ïª¬ºAªº¿ï¶µ¡C
¨S¦³¤Ä¿ïª¬ºAªº¿ï¶µ³Ì³æ¯Â¡A¥¦³Ì«nªºÄݩʬO¦WºÙ»PÃѧO½X¡A¦WºÙ¬O¥H¹sµ²§Àªº¦r¦ê¡AÃѧO½X«h¬O¤Q¤»¦ì¤¸ªºµL¸¹¼Æ¡An³]©w³o¨âºØÄÝ©Ê¡A±N MENUITEMINFO ªº fMask ³]¬° MIIM_STRING or MIIM_ID¡CMIIM_STRING¡BMIIM_ID ¤§È¤À§O¬O 40H¡B2¡A´«ºâ¦¨¤G¶i¦ì¬O 0100 0000¡B0010¡A¥¦Ì¨ä¹ê³£¬OºX¼Ð¡CInsertMenuItem Àˬd fMask ªº¦U¦ì¤¸¡Aµo²{²Ä¤@Ӧ줸¬°¤@¡A´Nª¾¹DÀ³¥Îµ{¦¡·QÅý¿ï¶µ¦³¿ï¶µÃѧO½X¡Fµo²{²Ä¤»Ó¦ì¤¸¬°¤@¡A´Nª¾¹Dn¦³¿ï¶µ¤å¦r¡C¦]¦¹n¦P®É³]©w¦n¿ï¶µÃѧO½X¤Î¤å¦r¡A¥i¥H¥Î¡uOR¡v¹Bºâ¤l¨Ï MIIM_STRING¡BMIIM_ID ¬Û³s¡C
³]¦n fMask Äæ¦ì¤§«á¡A¦]¬°¦³ MIIM_STRING ©Ò¥HÁÙn§â dwTypeData ³]¬°¿ï¶µ¦WºÙ¦r¦êªº¦ì§}¡A¦]¬°¦³ MIIM_ID ©Ò¥Hn§â wID ³]¬°¿ï¶µÃѧO½X¡C¹³³o¼Ë¥u²K¥[¿ï¶µ¤å¦r»P¿ï¶µÃѧO½X¬O³Ì³æ¯Âªº¤F¡A©Ò¥HºÙ¤§¬°¡u¶§¬Kªº¿ï¶µ¡v¡C¨£²Ä 206¡ã212 ¦æ¡A©Î¤U±µ{¦¡½X¡G
;¦b¥D¥\¯àªí¤¤´¡¤J¡uÂ÷¶}¡v¿ï¶µ
mov mii.cbSize,SIZEOF mii
mov mii.fMask,MIIM_STRING or MIIM_ID
lea r10,szQuit
mov mii.wID,IDM_QUIT
mov mii.dwTypeData,r10
invoke InsertMenuItem,hMenu,0,TRUE,ADDR mii
º¥ýn»¡©úªº¬O¡Amii.cbSize ¥²¶·¬O InsertMenuItem ¯à°÷±µ¦¬ªº¼ÆÈ¡A¦¹¼ÆÈ»P Windows ª©¥»¦³Ãö¡C¦pªG¨S³]©w¦¹¼Æ©Î³]©w¿ù»~¡AInsertMenuItem ´N·|°õ¦æ¿ù»~¡C·íªì¤p¤ì°¸¦b´ú¸Õ®É¡A¦]¬° MASM64 SDK »P WinInc ³£©w¸q¿ù¤F¡Aªá¤F³\¦h®É¶¡¨«¤F«Ü¦hÞªP¸ô¡A©¯¦n³Ì«á¤ñ¹ï¥¦Ì¤£¦P¤§³B¤~§ä¨ì¿ù»~¡A¨£µù¤@¡C
°²¦p¤£¦P®É³]¦n³o¨âÓÄÝ©Ê¡A¤]¬O¥i¥Hªº¡C¨Ò¦p¥ý¤£³]©w¿ï¶µÃѧO½X¡Aµ¥´¡¤J¿ï¶µ¤§«á¦A³]¡A¦p¤U±ªºµ{¦¡½X¡G
mov mii.cbSize,SIZEOF mii mov mii.fMask,MIIM_STRING lea r10,szQuit mov mii.dwTypeData,r10 invoke InsertMenuItem,hMenu,0,TRUE,ADDR mii mov mii.fMask,MIIM_ID mov mii.wID,IDM_QUIT invoke SetMenuItemInfo,hMenu,0,TRUE,ADDR mii
¦ý¬O¡A¦pªG¤Ï¹L¨Ó¡A¥ý©I¥s InsertMenuItem ®É¤w³]¦nÃѧO½X¡A¦A©I¥s SetMenuItemInfo ³]©w¿ï¶µ¦WºÙ¡A¸Ó¿ï¶µ¤£¯à¥¿±`¹B§@¡C¤p¤ì°¸¤£ª¾¹D½T¤Áªºì¦]¡A±À´ú¬O¿ï¶µ¦WºÙ¬O¿ï¶µ¤¤³Ì«nªº³¡¤À¡A¥²¶·¥ý½T¥ß¦WºÙ¤§«á¡A¦A¹ï¿ï¶µ×¹¢¡C
·s²K¤Wzªº¿ï¶µÁÙ¦³¥t¤@ºØ¤è¦¡¡AÁöµM³o¬OÂ¥Ϊk¡A¦ýÁÙ¬O»¡¤@»¡¡C§â fMask ³]¬° MIIM_TYPE or MIIM_ID¡A¦A¶i¤@¨B§â fType ³]¬° MFT_STRING¡A³Ì«á©ó dwTypeData ³]©w¦r¦êªº¦ì§}¡A¨£²Ä 228¡ã234 ¦æ¡C§A·|µo²{¨Ï¥Î¤èªkn¤T¨BÆJ¡F¦Ó¤W¤@ºØ¤èªk¶È¨â¨BÆJ¡C
¦p¦ó¥H InsertMenuItem ²K¥[¼u¥X¿ï¶µ©O¡H¼u¥X¿ï¶µ¨S¦³¿ï¶µÃѧO½X¡A¦ý¥²¶·¦³¦WºÙ»P¤l¥\¯àªí¥N½X¡A³oùتº¤l¥\¯àªí¬O¨Ï¥ÎªÌÂI¿ï¦¹¼u¥X¿ï¶µ«á¥X²{ªº¡C¦]¬°¼u¥X¿ï¶µ¦³¤l¥\¯àªí¡A©Ò¥H¥²¶·¥ý©I¥s CreateMenu «Ø¥ß¤@¥\¯àªí¡A¦A§â fMask ³]¬° MIIM_SUBMENU or MIIM_STRING¡A±µµÛ±N MENUITEMINFO ¤¤ªº hSubMenu Äæ¦ì³]¬° CreateMenu «Ø¥ßªº¥\¯àªí¥N½X¡C³Ì«á±N dwTypeData ³]¬°¤@Ó¥H¹sµ²§Àªº¦r¦ê¤§¦ì§}¡A¦¹¦r¦ê´N¬O¼u¥X¿ï¶µªº¦WºÙ¡C¨£ DRAW5.ASM ²Ä 213¡ã220 ¦æ¡C
¦p¦ó²K¥[¨ã¦³✔¤Ä¿ïª¬ºAªº¿ï¶µ©O¡H¨ä¹ê¤£Ãø¡A¸ò«e±³]©w¤£¨ã¤Ä¿ï¿ï¶µÃþ¦ü¡A¥u¬O¦h¤Fn±N¨ä³]¬°¤Ä¿ïª¬ºA¡C¸Ô²Óªº»¡´N¬O¥ý§â MENUITEMINFO ªº fMask ³]¬° MIIM_STRING or MIIM_ID or MIIM_STATE¡A±µ¤U¨Ó¿ï¶µ¦WºÙ»PÃѧO½X¸ò«e±¬Û¦P¡A¦ý¦h¤F¤@¨B§â MENUITEMINFO ªº fState Äæ¦ì³]¬° MFS_CHECKED¡C¨£²Ä 235¡ã241 ¦æ¡C
;¦b¡uÀ˵ø¡v¤l¥\¯àªí¤¤´¡¤J¡u®y¼Ð¡v¿ï¶µ
mov mii.fMask,MIIM_STRING or MIIM_ID or MIIM_STATE
mov mii.fState,MFS_CHECKED
lea r10,szXy
mov mii.wID,IDM_XY
mov mii.dwTypeData,r10
invoke InsertMenuItem,hViewSubMenu,0,TRUE,ADDR mii
¦p¦ó²K¥[¨ã¦³●¤Ä¿ïª¬ºAªº¿ï¶µ©O¡H¨ã¦³●¤Ä¿ïª¬ºA¡A¥²¶·¥ý³]¨ä¬°¤Ä¿ïª¬ºA¡AµM«á¤~¯à±N¨ä¶i¤@¨B³]¬°●ªºª¬ºA¡C©Ò¥H¥ý§â MENUITEMINFO ªº fMask ³]¬° MIIM_STRING or MIIM_ID or MIIM_STATE or MIIM_FTYPE¡A«e±¤w¸g¸ÑÄÀ¹L«e¤TºØ¡A³Ì«á¤@Ó MIIM_FTYPE¡A¥²¶·§â fType ³]¬° MFT_RADIOCHECK¡C¨£²Ä 253¡ã261 ¦æ¡C
³Ì«á¤@ºØ¡A¦p¦ó³]©w¤À¹j½u©O¡Hº¥ý±N fMask Äæ¦ì³]¬° MIIM_FTYPE¡AµM«á¦A§â fType ³]¬° MFT_SEPARATOR¡C¨£²Ä 262¡ã265 ¦æ¡C
DRAW5 ²K¥[¤F³\¦h¿ï¶µ¡A¤]Åܧó¤F¦³¨Ç¿ï¶µªºÄÝ©Ê¡A¨Ã¤£»Ýn¨C¦¸Åܧó´N©I¥s DrawMenuBar¡Aµ¥³Ì«á¥þ³¡§¹¦¨¦A¤@¦¸©I¥s DrawMenuBar §Y¥i¡C
¡u¾Ö¦³ªÌø»sªº¿ï¶µ¡v·N«ä¬O«ü¥ÑÀ³¥Îµ{¦¡³B²z¦³Ãö¿ï¶µªº´X¥G©Ò¦³¤u§@¡A¥]§tø»s¿ï¶µ¤å¦r©Î¬OI´º¹Ï¤ù¡B³B²z³Q¿ï¾Ü¿ï¶µªº°ª«G«×¥ú´Î¡K¡Kµ¥ì¥»¥Ñ¨t²Î³B²zªº¤u§@¡C¥¿¦]¬°¨t²Î§â³o¨Ç¤u§@¶}©ñµ¹À³¥Îµ{¦¡¡A©Ò¥H¥i¥H°µ¦¨³\¦h»Å¬¯ªº®ÄªG¡C¤@¦p¬J©¹¡A¥ý¤¶²Ðì²z¤Î©Ò¨Ï¥Î¨ìªº Win64 API¡A¦A¦õ¥H¨Ò¤l»¡©ú¡C
n»s§@¾Ö¦³ªÌø»sªº¿ï¶µ¡A¥²¶·¥ý©I¥s CreateMenu ²£¥Í¤@ӪŪº¿ï¶µ¡A¦AÂǥѳ]©w¾A·íªº°Ñ¼Æ©I¥s InsertMenuItem ¤~¯à«Ø¥ß¾Ö¦³ªÌø»sªº¿ï¶µ¡C
¨ä¹ê¥un°Ñ¦Ò¤W± InsertMenuItem ªº»¡©ú¡AÀ³¸Ó´N¯à°÷»s§@¥X¨Ó¡C¥Dn´N¬O¦b fMask ¤¤§t¦³ MIIM_FTYPE ºX¼Ð¡A¨Ã¦b fType ¤¤³]©w MFT_OWNERDRAW ºX¼Ð¡C¨Ò¦p©³¤Uªºµ{¦¡½X¡G
mii MENUITEMINFO <?> ⁝ call CreateMenu mov hMenu,rax mov mii.cbSize,SIZEOF MENUITEMINFO ;³]©wMENUITEMINFOµ²ºcÅé¤j¤p mov mii.fMask,MIIM_ID or MIIM_FTYPE ;©I¥sInsertMenuItem®É¡A³]©w¿ï¶µÃѧO½X¤Î¿ï¶µÃþ«¬ mov mii.fType,MFT_OWNERDRAW ;³]©w¿ï¶µÃþ«¬¬°¾Ö¦³ªÌø»s mov mii.wID,2000 ;¿ï¶µÃѧO½X¬°2000 invoke InsertMenuItem,hMenu,0,TRUE,ADDR mii ;©óhMenu¥\¯àªí¤¤²K¥[¿ï¶µÃѧO½X¬°2000ªº¿ï¶µ
³o¼Ë³]©w¦n¤§«á¡A¦pªG°õ¦æ·|¬Ý¨£¤@ӪŪŦp¤]ªº¿ï¶µ¡A¬Æ¦Ü¿ï¶µ½d³òªº¤j¤p¤]¤£¤j¡A¦Ó¥Bùر¤°»ò¤]¨S¦³¡A³o´N¬O¡u¾Ö¦³ªÌø»sªº¿ï¶µ¡v¡C¨º»òn¦p¦ó±N³oÓ¾Ö¦³ªÌø»s¿ï¶µ×§ï¦¨§ÚÌ·Qnªº¼Ë¤l©O¡Hº¥ýnקï¿ï¶µ½d³òªº¤j¤p¡C
·í«Ø¥ß¾Ö¦³ªÌø»sªº¿ï¶µ©Î¬Y¨Ç±±¨î¶µ®É¡A¨t²Î·|§â WM_MEASUREITEM °T®§¶Ç°e¨ì¾Ö¦³¸Ó¥\¯àªí©Î±±¨î¶µªºµøµ¡¨ç¦¡¤§¤¤¡CÀ³¥Îµ{¦¡ÂǥѦ¹°T®§³]©w¿ï¶µ©Î±±¨î¶µªº¤Ø¤o¡C·í¨t²Î¶Ç¨Ó WM_MEASUREITEM °T®§®É¡A¨ä¤¤ wParam ¦³¨âºØ±¡§Î¡G①¦pªG¬O¦]¥\¯àªí¦Ó¶Ç¨Óªº¡AwParam ¬°¹s¡F②¦pªG¬O¦]±±¨î¶µ¦Ó¶Ç¨Óªº¡AwParam ¬°±±¨î¶µÃѧO½X¡C
¾Ö¦³ªÌø»sªºª«¥ó¦³¨âÃþ¡G¿ï¶µ©M±±¨î¶µ¡A±±¨î¶µ¦³«Ü¦hºØ¡A±`¨£ªº¦³«ö¶s¡]button¡^¡B²M³æ¡]list¡^¡B½s¿è®Ø¡]edit¡^¡K¡Kµ¥³o¨Çª«¥ó¡A¥H«á¦A»¡©ú¡C¦ý¬O¦]¬°«Ø¥ß¤F¾Ö¦³ªÌø»sªº±±¨î¶µ¤]·|µo°e WM_MEASUREITEM °T®§¡A©Ò¥H¦b¦¹²¤¬°´£¤@´£¡C
WM_MEASUREITEM °T®§ªº lParam «h¬O¤@Ó«ü¼Ð¡A«ü¦Vµ²ºcÅé MEASUREITEMSTRUCT ©Ò¦bªº¦ì§}¡CMEASUREITEMSTRUCT ªº¦UÄæ¦ì¦p¤U¡G
MEASUREITEMSTRUCT STRUCT CtlType DWORD ? ;Ãþ«¬ CtlID DWORD ? ;±±¨î¶µÃѧO½X¡A¥\¯àªí¤£¥Î¦¹Äæ itemID DWORD ? ;¹ï±±¨î¶µ¦Ó¨¥¬O¶µ¥Ø¦ì¸m¡F¹ï¥\¯àªí¦Ó¨¥¬O¿ï¶µÃѧO½X itemWidth DWORD ? ;¥\¯àªí¿ï¶µ¼e«×¡A³æ¦ì¬O¹³¯À itemHeight DWORD ? ;¥\¯àªí¿ï¹³°ª«×¡A©Î²M³æ±±¨î¶µ¤¤¬Yӿﶵªº°ª«× DWORD ? ;¬°¤F¯à¹ï»ô¥|¦r²Õ¦Ó¦h¥[ªºªÅÄæ¦ì¡A¦bWinIncªºwinuser.inc¤¤¦¹³B¤]µo¥Í¿ù»~ itemData QWORD ? ;À³¥Îµ{¦¡¦Û¦æ¥[¤Jªº¸ê®Æ MEASUREITEMSTRUCT ENDS
¦UÄæ¦ìªº»¡©ú¦p¤U¡G
CtlType | ¼ÆÈ | »¡©ú |
ODT_MENU | 1 | ¾Ö¦³ªÌø»sªº¥\¯àªí |
ODT_LISTBOX | 2 | ¾Ö¦³ªÌø»sªº²M³æ±±¨î¶µ |
ODT_COMBOBOX | 3 | ¾Ö¦³ªÌø»sªº¤U©Ô¦¡¤è¶ô±±¨î¶µ |
ODT_BUTTON | 4 | ¾Ö¦³ªÌø»sªº«ö¶s±±¨î¶µ |
ODT_STATIC | 5 | ¾Ö¦³ªÌø»sªºÀRºA±±¨î¶µ |
ODT_TAB | 101 | ¾Ö¦³ªÌø»sªº¼ÐÅÒ¶±±¨î¶µ |
ODT_LISTVIEW | 102 | ¾Ö¦³ªÌø»sªº²M³æÀ˵ø±±¨î¶µ |
¨t²Î±N WM_MEASUREITEM °T®§¶Ç°e¨ì¨ã¦³¾Ö¦³ªÌø»s¤§¥\¯àªí©Î±±¨î¶µªºµøµ¡¨ç¦¡®É¡A°£¤F itemWidth¡BitemHeight ¤§¥~¡A¨t²Î§¡¤w¶ñ¦n¾A·íÈ¡F¦Ó itemWidth¡BitemHeight ³o¨âÄæ¦ì¡A¥²¶·¥ÑÀ³¥Îµ{¦¡¦Û¦æ¶ñ¤J¡A·íªð¦^¨t²Î«á¡A¨t²Î·|®Ú¾Ú³o¨âÄæ³]©w¦n¸Ó¶µ¥Ø¤Ø¤o¡C¥Ñ WM_MEASUREITEM ªð¦^®É¡A¥²¶·±N RAX ³]¬°¤@¡A¤]´N¬O±N¦^¶Çȳ]¬°¤@¡AÅý¨t²Îª¾¹D¤w³B²z§¹¦¹°T®§¡C
·í¾Ö¦³ªÌø»sªº¥\¯àªí©Î±±¨î¶µ§ïÅÜ¥~Æ[®É¡A¨t²Î·|±N WM_DRAWITEM °T®§µo°e¨ì¾Ö¦³¸Ó¥\¯àªí©Î±±¨î¶µªºµøµ¡¨ç¦¡¤¤¡C¨ä¤¤ªº wParam ¦³¨âºØ±¡§Î¡G①¦pªG¬O¦]¥\¯àªí¦Ó¶Ç¨Óªº¡AwParam ¬°¹s¡C②¦pªG¬O¦]±±¨î¶µ¦Ó¶Ç¨Óªº¡AwParam ¬°±±¨î¶µÃѧO½X¡C
WM_DRAWITEM °T®§ªº lParam «h¬O¤@Ó«ü¼Ð¡A«ü¦Vµ²ºcÅé DRAWITEMSTRUCT ©Ò¦bªº¦ì§}¡A¦¹µ²ºcÅ骺Äæ¦ì¦p¤U¡G
DRAWITEMSTRUCT STRUCT CtlType DWORD ? ;Ãþ«¬ CtlID DWORD ? ;±±¨î¶µÃѧO½X¡A¥\¯àªí¤£¥Î¦¹Äæ itemID DWORD ? ;¹ï±±¨î¶µ¦Ó¨¥¬O¶µ¥Ø¦ì¸m¡F¹ï¥\¯àªí¦Ó¨¥¬O¿ï¶µÃѧO½X itemAction DWORD ? ;¦ó®É¶·Ã¸»s itemState DWORD ? ;ø»s§¹¦¨«á¶µ¥Øªºª¬ºA DWORD ? ;¬°¨ÏÄæ¦ì¹ï»ô¡A¦bWinIncªºwinuser.inc¤¤¦¹³B¤]µo¥Í¿ù»~ hwndItem HWND ? ;¥\¯àªí¥N½X©Î±±¨î¶µ¥N½X hDC HDC ? ;¸Ë¸m¤º®e¥N½X rcItem RECT <> ;ø»s½d³ò itemData QWORD ? ;À³¥Îµ{¦¡¦Û¦æ©w¸qªº¸ê®Æ DRAWITEMSTRUCT ENDS
¦pªG¥Î WinInc ¥]§tÀÉ¡A¨º»ò¦b winuser.inc ¥]§tÀɤº¡ADRAWITEMSTRUCT ªº©w¸q¬O¿ù»~ªº¡A¦]¬°¤Ö¤F¦b itemState ¤§«á¨S¦³©w¸q¦WºÙ¥Bªø¬° DWORD ªºÄæ¦ì¡A½Ð¦Û¦æ§ó¥¿¬°¤W±¥¿½Tªº©w¸q¡C
DRAWITEMSTRUCT ¦UÄæ¦ìªº»¡©ú¦p¤U¡G
itemAction | ¼ÆÈ | »¡©ú |
ODA_DRAWENTIRE | 1 | ±±¨î¶µ»Ý¾ãÓø»s |
ODA_SELECT | 2 | ¿ï¾Üª¬ºAµo¥Í§ïÅÜ |
ODA_FOCUS | 4 | ±±¨î¶µÀò±o©Î¥¢¥h¿é¤JµJÂI |
itemAction | ¼ÆÈ | »¡©ú |
ODS_SELECTED | 1 | ¥\¯àªí¤¤ªº¶µ¥Ø¬O³Q¿ï¾Üªº |
ODS_GRAYED | 2 | ¥\¯àªí¤¤ªº¶µ¥Ø¬OµL®Äªº |
ODS_DISABLED | 4 | ¸T¥Îªº¶µ¥Ø |
ODS_CHECKED | 8 | ¥\¯àªí¤¤ªº¶µ¥Ø¬O³Q¤Ä¿ïªº |
ODS_FOCUS | 10H | ¦¹¶µ¥Ø¨ã¦³Áä½L¿é¤JµJÂI |
ODS_DEFAULT | 20H | ¦¹¶µ¥Ø¬O¹w³]ªº |
ODS_HOTLIGHT | 40H | ¦¹¶µ¥Ø°ª«G«×Åã¥Ü¡A¥ç§Y·í·Æ¹«°±¯d¦b¦¹¶µ¥Ø®É³Q¬ðÅã¥X¨Ó |
ODS_INACTIVE | 80H | ¸Ó¥\¯àªí¶µ¥Ø³B©ó«D¬¡°Êª¬ºA¡A¨Ã¥B¨ã¦³¸Ó¥\¯àªíªºµøµ¡¤]³B©ó«D¬¡°Êª¬ºA |
ODS_NOACCEL | 100H | ¦³¨Ç±±¨î¶µ·|¦b¤å¦r¤Uµe¦³©³½u¥H´£¥Ü§Ö±¶Áä¡A¦b ODS_NOACCEL ª¬ºA¤U«h¤£´£¥Ü |
ODS_NOFOCUSRECT | 200H | ±±¨î¶µÀò±oÁä½L¿é¤JµJÂI®É¡A©P³ò·|¥X²{µJÂI¯x§Î©Î°ª«G«×®ÄªG¡A¦¹¨è±±¨î¶µ¥i¥H¥ÎÁä½L¾Þ§@¡C¦ý¦pªG³B©ó ODS_NOFOCUSRECT ª¬ºA¡A«h¤£·|Åã¥ÜµJÂI¯x§Î©Î°ª«G«×®ÄªG |
ODS_COMBOBOXEDIT | 1000H | ø»s¤U©Ô¦¡¤è¶ô±±¨î¶µªº½s¿è®Ø |
WM_DRAWITEM ªð¦^®É¡A¥²¶·±N¦^¶Çȳ]¬°¤@¡AÅý¨t²Îª¾¹D¤w³B²z§¹ WM_DRAWITEM °T®§¡C
GetSysColor API ¥Î©ó¨ú±oÅã¥Ü¤¸¯À¡]display element¡^ªºÃC¦â¡AÅã¥Ü¤¸¯À¬O«ü¿Ã¹õ¤W©Îµøµ¡¤Wªº¬Y³¡¥÷¡C»yªk¦p¤U¡G
invoke GetSysColor,\
nIndex ; display element
nIndex ¬OÅã¥Ü¤¸¯À¡A©³¤Uªºªí¶È¦C¥X¤@¨Ç¡A¥i¥H¬d¾\ MSDN ±o¨ì§ó¸Ô²Óªº¸ê®Æ¡C
nIndex | ¼ÆÈ | »¡©ú |
COLOR_3DDKSHADOW | 21 | ¤TºûÅã¥Ü¤¸¯Àªº³±¼v³¡¤ÀªºÃC¦â |
COLOR_BACKGROUND | 1 | ®à±ªºÃC¦â |
COLOR_BTNFACE | 15 | ¤TºûÅã¥Ü¤¸¯Àªí±ªºÃC¦â©Î¹ï¸Ü®ØI´ºÃC¦â |
COLOR_BTNTEXT | 18 | «ö¶s¤Wªº¤å¦rÃC¦â |
COLOR_MENU | 4 | ¥\¯àªíI´º¦â |
COLOR_MENUTEXT | 7 | ¥\¯àªí¤å¦rªºÃC¦â |
COLOR_WINDOWTEXT | 8 | µøµ¡¤u§@°Ï¤å¦rªºÃC¦â |
¦pªG GetSysColor °õ¦æ¦¨¥\¡A¦^¶ÇȬ°ÃC¦âÈ¡F¦pªG°õ¦æ¥¢±Ñ¡A¦^¶ÇȬ°¹s¡A¦ý¬O¹s¤]¬OÃC¦âȪº¤@ºØ¡]¹s¥Nªí¶Â¦â¡^¡A¥i¥H¥Î GetSysColorBrush ½T»{¡A¦pªG GetSysColorBrush ¦^¶ÇȬ°¹s¥Nªí¤£¤ä´©¦¹°Ñ¼Æ¡C
GetSysColorBrush ¥Î¨Ó¨ú±o¶îº¡µøµ¡¬Y³¡¤Àªºµe¨ê¥N½X¡A»yªk¦p¤U¡A°Ñ¼Æ nIndex ¬°Åã¥Ü¤¸¯À¡A¤]´N¬O¤Wªí¡C
invoke GetSysColorBrush,\
nIndex ; system color index
¦pªG GetSysColorBrush °õ¦æ¦¨¥\¡A¦^¶ÇȬOµe¨ê¥N½X¡F¦pªG°õ¦æ¥¢±Ñ¡A¦^¶ÇȬ°¹s¡C¸g¥Ñ©I¥s GetSysColorBrush ¦Ó±o¨ìªºµe¨ê¬O¥Î¨Ó¶îº¡ Windows ¨t²Îªº¬Y³¡¤À¤¸¥ó¡AºÙ¬°¨t²Îµe¨ê¡]system color brush¡^¡A¤£»Ýn¾P·´¡C
CreateFont ¬O¥Î¨Ó«Ø¥ßÅÞ¿è¦r§Îªº¡C¦pªGŪªÌ´¿¥Î¹L Lotus SmartSuite Word Pro¡BMS Word µ¥¤å®Ñ³nÅé¡A¥¦Ì³£¯àÅý¨Ï¥ÎªÌ¨Ï¥Î¦UºØ¤£¦Pªº¦r§Î¡A¨Ã¥BÅã¥Ü¥X¨Ó¡CÀ³¥Îµ{¦¡nÅã¥Ü¤£¦Pªº¦r§Î¡A±o¥ý«Ø¥ßÅÞ¿è¦r§Î¡A©³¤U¨Ó¬Ý¬Ý CreateFont ªºì«¬¡G
invoke CreateFont,\ nHeight,\ ; height of font nWidth,\ ; average character width nEscapement,\ ; angle of escapement nOrientation,\ ; base-line orientation angle fnWeight,\ ; font weight fdwItalic,\ ; italic attribute option fdwUnderline,\ ; underline attribute option fdwStrikeOut,\ ; strikeout attribute option fdwCharSet,\ ; character set identifier fdwOutputPrecision,\ ; output precision fdwClipPrecision,\ ; clipping precision fdwQuality,\ ; output quality fdwPitchAndFamily,\ ; pitch and family lpszFace ; typeface name
©³¤U¬O³o¨Ç°Ñ¼Æªº»¡©ú¡G
¹Ï§Î¼Ò¦¡ | GM_COMPATIBLE | GM_ADVANCED | ||
nEscapement | 0 | 300 | 0 | 300 |
nOrientation | 300 | 0 | 300 | 0 |
µ²ªG |
szMsJhengHei DB "·L³n¥¿¶ÂÅé",0 szText DB "®LÂ͸³·¡A½ü°j¤£¹L¤@¿h¡C",0 ⁝ .switch uMsg .case WM_PAINT invoke BeginPaint,hWnd,ADDR ps invoke SetGraphicsMode,ps.hdc,¹Ï§Î¼Ò¦¡ invoke GetClientRect,hWnd,ADDR rect invoke FillRect,ps.hdc,ADDR rect,hbrBlack invoke SetTextColor,ps.hdc,0ffffffh invoke SetBkColor,ps.hdc,0 invoke SelectObject,ps.hdc,hFont invoke DeleteObject,rax invoke DrawText,ps.hdc,OFFSET szText,-1,ADDR rect,DT_SINGLELINE or DT_CENTER or DT_VCENTER invoke EndPaint,hWnd,ADDR ps .case WM_CREATE invoke CreateFont,30,0,nEscapement,nOrientation,FW_BOLD,0,0,0,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,\ CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH or FF_DONTCARE,OFFSET szMsJhengHei mov hFont,rax invoke CreateSolidBrush,0 mov hbrBlack,raxµ{¦¡¤¤ªº¹Ï§Î¼Ò¦¡¥i¥ÎGM_COMPATIBLE ©Î GM_ADVANCED ¥N¤J¡AnEscapement¡BnOrientation ¥i¥Î 0 ©Î 300 ¥N¤J¡C300 ¥Nªí 30 «×¨¤¡C
fdwCharSet | ¼ÆÈ | »¡©ú |
ANSI_CHARSET | 0 | ¬ü°ê¤Î¦è¼Ú±`¨Ï¥Îªº¦r¤¸¶° |
DEFAULT_CHARSET | 1 | °õ¦æÀ³¥Îµ{¦¡ªº¹q¸£¤W¡A¨t²Î¤º©wªº¦r¤¸¶° |
SHIFTJIS_CHARSET | 128 | ¤é¤å¦r¤¸¶° |
GB2312_CHARSET | 134 | ²Å餤¤å¦r¤¸¶° |
CHINESEBIG5_CHARSET | 136 | ¥¿Å餤¤å¦r¤¸¶° |
fdwOutputPrecision | ¼ÆÈ | »¡©ú |
OUT_CHARACTER_PRECIS | 2 | ¤£¨Ï¥Î¿é¥Xºë½T«× |
OUT_DEFAULT_PRECIS | 0 | ¨Ï¥Î¤º©wªº¿é¥Xºë½T«× |
OUT_DEVICE_PRECIS | 5 | ¨Ï¥Î¸Ë¸m¦r§Î¿é¥Xºë½T«×¡A¸Ë¸m¦r§Î¬O¦b¨ä¥L©PÃä³]³Æ¤º«Øªº¦r§Î¡A¨Ò¦p¦³¨Ç¦Lªí¾÷´N¦³¤º«Ø¦r§Î |
OUT_OUTLINE_PRECIS | 8 | ¨Ï¥Î TrueType ¦r§Î©M¨ä¥L´yÃä¦r§Î¿é¥Xºë½T«× |
OUT_PS_ONLY_PRECIS | 10 | ¥u¦b PostScript ¦r§Î¤¤¿ï¾Ü¡C¦pªG¨t²Î¤¤¨S¦³¦w¸Ë PostScript ¦r§Î¡A«h¨Ï¥Î¤º©wÈ |
OUT_RASTER_PRECIS | 6 | ·í¨t²Î¥]§t¦hÓ¬Û¦P¦WºÙªº¦r§Î®É¡A¿ï¾ÜÂI°}¦r§Î |
OUT_SCREEN_OUTLINE_ PRECIS | 9 | ¨Ï¥Î¿Ã¹õÅã¥Üªº´yÃä¦r§Îªº¿é¥Xºë«×¡A¦b¿Ã¹õ¤W¯à«OÃҳ̨ÎÅã¥Ü®ÄªG |
OUT_STRING_PRECIS | 1 | ³oÓȤ£¬O«ü©w¦r§Î¦ÓÅýÀ³µ{¦¡¨Ï¥Î¡A¦CÁ|ÂI°}¦r§Î |
OUT_STROKE_PRECIS | 3 | ³oÓȤ£¬O«ü©w¦r§Î¦ÓÅýÀ³µ{¦¡¨Ï¥Î¡A¦CÁ| TrueType ¦r§Î©Î¨ä¥L¦V¶q¦r§Î |
OUT_TT_ONLY_PRECIS | 7 | ¥u¦b TrueType ¦r§Î¤¤¿ï¾Ü¡C¦pªG¨t²Î¤¤¨S¦³¦w¸Ë TrueType ¦r§Î¡A«h¨Ï¥Î¤º©wÈ |
OUT_TT_PRECIS | 4 | ·í¨t²Î¥]§t¦hÓ¬Û¦P¦WºÙªº¦r§Î®É¡A¿ï¾Ü TrueType ¦r§Î |
fdwClipPrecision | ¼ÆÈ | »¡©ú |
CLIP_DEFAULT_PRECIS | 0 | ¨Ï¥Î¤º©wµô°Åºë½T«× |
CLIP_CHARACTER_PRECIS | 1 | ¤£¨Ï¥Îµô°Åºë½T«× |
CLIP_STROKE_PRECIS | 2 | ³oÓȤ£¬O«ü©w¦r§Î¦ÓÅýÀ³µ{¦¡¨Ï¥Î¡A¦Ó¬O¦CÁ|ÂI°}¡B¦V¶q©Î TrueType ¦r§Î |
fdwQuality | ¼ÆÈ | »¡©ú |
DEFAULT_QUALITY | 0 | ¥H¨t²Î¹w³]ȳB²z¦r§Î¥~Æ[¡A¦Ó¤£¯S§O¥[±j³B²z |
DRAFT_QUALITY | 1 | ¦r§Îªº«~½è¸û¤£«n |
PROOF_QUALITY | 2 | ¦r§Îªº«~½è¡]¥·Æ«×¡B²M´·«×¡^¤ñ¸û«n¡A§Y¨Ï¦r§Î¤j¤p¤£¯à»P©Ò«ü©wªº¤Ç°t |
NONANTIALIASED_QUALITY | 3 | ¤£¶i¦æ¤Ï¿÷¾¦³B²z |
ANTIALIASED_QUALITY | 4 | ¦r§Î¬°¥·Æªº¡A¤]´N¬O¤Ï¿÷¾¦ |
CLEARTYPE_QUALITY | 5 | ¥H ClearType ¤è¦¡¤Ï¿÷¾¦ |
CreateFont ªº°Ñ¼Æ«Ü¦h¡A¦@¤Q¥|Ó¡A³£¬O´yzÅÞ¿è¦r§Îªº©Ê½è¡A¥i²Ê¤À¦¨¤TºØ¡G¦r§Î¦WºÙ¡]lpszFace¡^¡B¦r§Î¤j¤p¡]nHeight¡BnWidth¡^¡B¦r§Î·®æ»Pºë±K«×¡C¤@¯ë©I¥s CreateFont ®É¡A³Ì«nªº¬O lpszFace¡A¨M©w¦r§Î¦WºÙ¡A¨Ò¦p¡uCourier New¡v¡B¡u·s²Ó©úÅé¡v¡K¡Kµ¥¡A¦ýª`·N¥²¶·¥H¹s¬°µ²§Àªº¦r¦ê¡C¦pªG¤£ª¾¹D¦r§Î¦WºÙ¡A¥i¥H¶}±Ò MS WORD¡AÂI¿ï¦r§Î¤U©Ô¦¡¤è¶ô±±¨î¶µÆ[¹î¡C
¨M©w¦r§Î¦WºÙ¤§«á¡A¨ä¦¸«nªº¬O¦r§Î¤j¤p¡A¤]´N¬O²Ä¤@ӰѼơAnHeight¡A¨ä³æ¦ì¬OÅÞ¿è³æ¦ì¡C¦pªG¨S¦³§ïÅܬM®g¼Ò¦¡¡A¹w©wªºÅÞ¿è³æ¦ì´N¬O¹³¯À¡C¤j³¡¤Àªº±¡ªp¡A³£·|§â nHeight ³]¬°¥¿È¡A³o¼Ë´N¬O¤W¹Ï¤¤ªº Height¡C
³Ì«á¦r§Î·®æ»Pºë±K«×¡A¦ýY¤£¯S§OÁ¿¨s¨Ï¥Î¹w³]ȧY¥i¡C¤]´N¬O°£¤F²Ä¤@ӰѼơAnHeight¡A©M³Ì«á¤@ӰѼơAlpszFace¡A¤§¥~ªº¨ä¥L 12 ӰѼơA³£¥i¥H³]¬°¤º©wÈ¡A¥Ñ¨t²Î¦Û¦æ¨M©w¡C³o¼Ë´N«Ü²³æ¤F¡C
¦pªGÀ³¥Îµ{¦¡nÅã¥Ü¤£¦Pªº¦r§Î¡A±o¥ý«Ø¥ßÅÞ¿è¦r§Î¡A§Y¨ÏnÅã¥Üªº¦r§Î³£¬O¦W¬°¡uTimes New Roman¡v¡A¦ý¤@¬O±×Åé¡B¤@¬O§t¦³©³½u¡A¨º»ò¤]»Ý«Ø¥ß¨âÓÅÞ¿è¦r§Î¡AµM«á¦bø»s¥X¦r¦ê¤§«e¡A¥Î SelectObject ¿ï¾Ü¤£¦PªºÅÞ¿è¦r§Î¡A¦A©I¥s DrawText ©Î TextOut µe¥X¡C
CreateFont ¦pªG°õ¦æ¦¨¥\¡A¦^¶ÇȬOÅÞ¿è¦r§Î¥N½X¡F¦pªG°õ¦æ¥¢±Ñ¡A¦^¶ÇȬO¹s¡CÅÞ¿è¦r§Î¤£¦A¨Ï¥Î®É¡AÀ³¸Ó¥Î DeleteObject ±N¨ä§R°£¡A¥H§K¯Ó¶O¹L¦h¸ê·½¡C¤@¯ë¨Ó»¡¡A·í¿ï¥Î¤@Ó·sªºÅÞ¿è¦r§Î®É¡AªºÅÞ¿è¦r§Î¤j·§´N¥Î¤£µÛ¤F¡A«ê¦n SelectObject ´N¬O¶Ç¦^ªºÅÞ¿è¦r§Î¡A¦]¦¹¥ß§Y´N±N¦^¶ÇªºÂÂÅÞ¿è¦r§Î§R°£¤F¡C
¸ÑÄÀ§¹»s§@¾Ö¦³ªÌø»s¿ï¶µªºì²z¤§«á¡A¹ê§@¤@Ó¨Ò¤l¡GONDMENU¡A°õ¦æµe±¦p¤U¡CONDMENU ªº¥D¥\¯àªí¦³¨âÓ¼u¥X¿ï¶µ¡GÀɮסB¦r§Î¡A¥H¤Î¤@ӿﶵ¡GÃö©ó¡C¦pªG¨Ï¥ÎªÌ¥H·Æ¹«ÂI¿ïÀÉ®×¼u¥X¿ï¶µ¡A²£¥ÍÀɮפl¥\¯àªí¡A¤º¦³¤Ó¿ï¶µ¡G«Ø·sÀɮסB¶}±ÒÂÂÀɮסBÀx¦sÀɮסB¤À¹j½u¡BÂ÷¶}¡A°£¤F¤À¹j½u¤§¥~¡A¨ä¾l¥|ӿﶵ³£¬O¾Ö¦³ªÌø»s¿ï¶µ¡A¨ä¤å¦r³£¬O©I¥s DrawText ø»sªº¡F¿ï¶µ«eªº¹Ï¤ù³£¬O¦ì¤¸¹Ï¡A³z¹L BitBlt ¶Ç¿é¨ì¤l¥\¯àªíªº¸Ë¸m¤º®e¦ÓÅã²{¡F³Q¿ï¾Ü¿ï¶µªº¬õ¦â¥ú´Î«h¬O³z¹L FillRect µe¥X¨Óªº¡C¦r§Î¼u¥X¿ï¶µ¯à²£¥Í¦r§Î¤l¥\¯àªí¡A¨ä¤º¤Ó¤]³£¬O¾Ö¦³ªÌø»s¿ï¶µ¡G¼Ð·¢Åé¡B·s²Ó©úÅé¡B¡uCourier New¡v¡B¡uTimes New Roman¡v¡B¡uMicrosoft Sans Serif¡v¡CI´º¹Ï¬O¤@±i¼µÛ¤jªø»Lªº¬ü¤k¹Ï¡A¬O³z¹L BitBlt ¶Ç¿é¨ì¤l¥\¯àªíªº¸Ë¸m¤º®e¦ÓÅã²{¡F¿ï¶µ¤å¦r¥Î¤£¦Pªº¦r§Îªí¥Ü¡A«h¬O¥H CreateFont¡BSelectObject ³]©w¨Ã©I¥s DrawText ø»sªº¡F¤Ä¿ïªº¥¿¤è§Î°O¸¹¡A«h¬O³z¹L BitBlt µe¦b¤l¥\¯àªíªº¸Ë¸m¤º®e¤W¡C³o¤Ó¦r§Îªº¿ï¶µ¬O¤¬¥¸ªº¡A¥u¯à¿ï¾Ü¤@Ó¡A¿ï¤F¤§«á¤u§@°Ï¤ºªº¦r§Î·|§ïÅÜ¡A¦P®É¿ï³æ¤º¤Ä¿ïªº¥¿¤è§Î°O¸¹¤]·|Åܦ¨¦bÂI¿ïªº¿ï¶µ¤§«e¡C
ONDMENU.RC ªº¤º®e¦p¤U¡G
1 2 3 4
5 6 7 |
ONDMENU ICON MENU.ico
N1W BITMAP NEW.bmp
OPN BITMAP OPEN.bmp
SAV BITMAP SAVE.bmp
EIT BITMAP EXIT.bmp
BTY BITMAP BEAUTY.bmp
CHK BITMAP CHECKED.bmp |
ª`·N¨ì¡A¤p¤ì°¸§â¤»Ó¦ì¤¸¹Ïªº¦WºÙ³£¥H¤TÓ¦r¥Àªí¥Ü¡A³o¬O¯S§Oºâpªº¡C¦]¬°¦b²Õ¦X»y¨¥ì©lµ{¦¡¤¤¡A¦ì¤¸¹Ï¦WºÙ¥²¶·¥H¹sµ²§À¡A¦A¥[¤W¤TÓ^¤å¦r¥À¡AÁ`¦@¥|Ӧ줸²Õ¡A³o¼Ë´N¥i¥H«Ü®e©ö¦b¦ì¤¸¹Ï¦WºÙªº°}¦C¤¤pºâ¥X¦ì§}¡C¨Ò¦p©³¤Uªº szBmpName °}¦C¦³¤»Ó¤¸¯À¡A¨CÓ¤¸¯À³£¬O¥Nªí¦ì¤¸¹Ïªº¦WºÙ¤TÓ¦r¥À¤Î¤@Ó 0 ²Õ¦¨¡A¦b WM_CREATE °T®§¤¤¡A«Ü®e©ö¥Î szBmpName[4¡Ñn] ¨ú±o¨ä¦ì§}¡An ¬°²Ä´XÓ¤¸¯À¡A±q 0 ¨ì 5¡G
szBmpName DB "N1W",0,"OPN",0,"SAV",0,"EIT",0,"BTY",0,"CHK",0
¥t¥~ÁÙ¦³¤@Ó§ó²³æªº¤èªk¡C²Ä¤Q¥|³¹´£¹L¡A¸ê·½´yzÀɤ¤ªº¹Ï¥Ü¦WºÙ¥i¥H¬O¦r¦ê¡A¤]¥i¥H¬O¤Q¤»¦ì¤¸ªºµL¸¹¼Æ¡A¦ì¤¸¹Ï¦WºÙ¤]¬O¦p¦¹¡C©Ò¥H¥i¥H¥Î³sÄòªº¤Q¤»¦ì¤¸µL¸¹¼Æ¡A¨Óªí¥Ü³o¨Ç¦ì¤¸¹Ï¡A³o¼Ë·|¤ñ¤Wz¤èªk§ó²³æ¡AŪªÌ¥i¥H¦Û¦æ½m²ß¡C
ÁöµM ONDMENU.RC ¶È¶È¤C¦æ¡A¦ý¬O¥t¥~¦³¤»±i BMP ¹Ï®×ÀÉ¡B¤@ӹϥÜÀɮסA¦Ó²Õ¦X»y¨¥ì©lÀÉ ONDMENU.ASM ¬ù¤T¦Ê¤»¤Q¦h¦æ¡A©Ò¥H¤£¦b³oùئC¥X¨Ó¡A½Ð¨ì³oùؤU¸ü¡C¦b ONDMENU.ASM ªº«e´X¦æ¡A¦³²ÕĶ»P³sµ²¨BÆJ¡C
«e±´£¹L¡AONDMENU ªº¥\¯àªí¤¤¡AÀɮפl¥\¯àªí¦³¥|Ó¾Ö¦³ªÌø»sªº¿ï¶µ¡A¦Ó¦r§Î¤l¥\¯àªí¦³¤Ó¾Ö¦³ªÌø»sªº¿ï¶µ¡AÁ`¦@¤EÓ¡C¨C«Ø¥ß¤@ӿﶵ¡A¨t²Î´N·|§â WM_MEASUREITEM °T®§¶Çµ¹µøµ¡¨ç¦¡¡A©Ò¥H ONDMENU ·|¦¬¨ì¤E«h WM_MEASUREITEM °T®§¡A¥²¶·¦b³o®ÉÔ¨M©w¦U¿ï¶µªº¤j¤p¡C¤£¹L¦]¬°«e¥|ӿﶵ»P«á¤Ó¿ï¶µ¤À§O¦b¤£¦Pªº¨âÓ¤l¥\¯àªí¤º¡A¨M©w¨ä¤j¤pªº¤è¦¡¤]´N¤À¬°¨âºØ¡C·íµM¡A¦b¦P¤@Ó¤l¥\¯àªí¤ºªº¿ï¶µ¤j¤p¥i¥H¤£¦P¡A¤£¹L ONDMENU ùجO¤@¼Ëªº¡C
①¡GONDMENU ³]©wÀɮפl¥\¯àªíªº¥|Ó¾Ö¦³ªÌø»sªº¿ï¶µ¼e«×»P°ª«×³£¬Û¦P¡A°ª«×¬° cyFileMenu¡A¨ä¤j¤p´N¬O¹w³]ªº¿ï¶µ°ª«×¡A¥i¥H¥Î SM_CYMENU ¬°°Ñ¼Æ©I¥s GetSystemMetrics ±o¨ì¡C¨Cӿﶵªº¼e«×«h¬O°ª«×ªº¤¿¡A¦A¥[¤W¦ì¤¸¹Ï¼e«×¡C¦ì¤¸¹Ï¼e«×«h¬O©I¥s GetObject ±o¨ì¡AGetObject ªº²Ä¤@ӰѼơA¬O¦ì¤¸¹Ï¥N½X¡CÀɮפl¥\¯àªíªº¥|Ó¾Ö¦³ªÌø»s¿ï¶µªº«e±¡A¦U¦Û¦³¦U¦Ûªº¦ì¤¸¹Ï¡AÁöµM¹Ï¤ù¤£¦P¡A¦ý¤j¤p§¡¬Û¦P¡A¦]¦¹¥u»Ýn±o¨ì¨ä¤¤¤@Ӧ줸¹Ïªº¼e«×§Y¥i¡C
②¡G¦r§Î¤l¥\¯àªíªº¥þ³¡¤j¤p¡A§Y¬° BEAUTY.bmp ¦ì¤¸¹Ïªº¤j¤p¡A¦Ó¦r§Î¤l¥\¯àªí¤º¦³¤Ó¿ï¶µ¡A¦]¦¹¨Cӿﶵªº°ª«×¬O BEAUTY.bmp °ª«×ªº¤¤À¤§¤@¡A¿ï¶µ¼e«×«h¬O BEAUTY.bmp ªº¼e«×¡C
©³¤U¬O³B²z WM_MEASUREITEM °T®§¥H¤Î»P¸Ó°T®§¬ÛÃöªºµ{¦¡½X¡C¦]¬°µøµ¡¨ç¦¡·|¦¬¨ì¤E«h WM_MEASUREITEM °T®§¡A¦pªG¨C¦¸³£n«·spºâ¿ï¶µªº¼e«×»P°ª«×¡A´N·|¦hpºâ¦n´X¦¸¦Ó¨Ï®Ä²vÅܧC¡]¹ê»Ú¤W¥H²{¤µ CPU ªº®Ä²v¡A³o¤@ÂI©µ¿ð¤HÃþ¬O·Pı¤£¥X¨Óªº¡^¡C°²¦p§â³opºâ¥æ¥Ñ³B²z WM_CREATE °T®§®É´Npºâ¦n¡A¨º¥unºâ¤@¦¸§Y¥i¡A®Ä²v¸û°ª¡C
.case WM_CREATE ;¸ü¤J«Ø·sÀɮסB¶}±ÒÂÂÀɮסBÀx¦sÀɮסBÂ÷¶}¥|ӿﶵ«eªº¦ì¤¸¹Ï¡A¤Î¬ü¤k¹Ï¡B¤Ä¿ï¥¿¤è§Î¹Ï invoke LoadBitmap,hInstance,OFFSET szBmpName mov hBmp,rax invoke LoadBitmap,hInstance,OFFSET szBmpName[4] mov hBmp[8],rax ⁝ invoke LoadBitmap,hInstance,OFFSET szBmpName[16] mov hBmp[32],rax ⁝ ;pºâÀÉ®×¥\¯àªí¦U¿ï¶µªº°ª«×¤Î¼e«×¡A°ª«×¡×¹w³]È¡A¼e«×¡×°ª«×¡Ñ5¡Ï¦ì¤¸¹Ï¼e«× invoke GetSystemMetrics,SM_CYMENU mov cyFileMenu,eax mov cxFileMenu,eax shl cxFileMenu,2 add eax,bmp.bmWidth add cxFileMenu,eax ;pºâ¦r§Î¥\¯àªíªº°ª«×¤Î¼e«×¡A°ª«×¡×BEAUTY.bmp°ª«×¡Ò5¡A¼e«×¡×BEAUTY.bmp¼e«× invoke GetObject,hBmp[32],SIZEOF BITMAP,ADDR bmp mov eax,bmp.bmHeight mov r11d,5 xor edx,edx div r11d mov r10d,bmp.bmWidth mov cyFontMenu,eax mov cxFontMenu,r10d .case WM_MEASUREITEM ASSUME r9:PTR MEASUREITEMSTRUCT mov r10d,cxFileMenu mov r11d,cyFileMenu cmp [r9].itemID,IDM_STDKAI ;Àˬd¿ï¶µÄÝ©óÀɮפl¥\¯àªíÁÙ¬O¦r§Î¤l¥\¯àªí jb @f ;¦pªG¬OÄÝ©óÀɮפl¥\¯àªí¡A¸õ¦Ü@@:³B mov r10d,cxFontMenu ;¦pªG¬OÄÝ©ó¦r§Î¤l¥\¯àªí¡A«³]R10D¡BR11D mov r11d,cyFontMenu @@: mov [r9].itemWidth,r10d mov [r9].itemHeight,r11d ASSUME r9:NOTHING mov rax,1 jmp return
¨ºn«ç»ò¼Ë¤~¯à§PÂ_¬O¦]¬°«Ø¥ß¤FÀɮפl¥\¯àªí¤¤ªº¿ï¶µ¡AÁÙ¬O«Ø¥ß¤F¦r§Î¤l¥\¯àªí¤¤ªº¿ï¶µ¤~¤Þµo WM_MEASUREITEM °T®§ªº©O¡H¨ä¹ê«Ü²³æ¡A¥unÀˬd MEASUREITEMSTRUCT µ²ºcÅ骺 itemID Äæ¦ì¬O§_¤p©ó IDM_STDKAI¡AIDM_STDKAI ¬O¡u¼Ð·¢Åé¡v¿ï¶µªºÃѧO½X¡C¦pªG itemID Äæ¦ì¤ñ IDM_STDKAI ¤p¡A¥Nªí¬O¦]¬°«Ø¥ß¤FÀɮפl¥\¯àªí¤¤ªº¿ï¶µ¡A§_«h´N¬O«Ø¥ß¦r§Î¤l¥\¯àªí¤¤ªº¿ï¶µ¡C
¦b³B²z WM_MEASUREITEM °T®§®É¡A¥ý°²³]¬O¦]¬°«Ø¥ß¤FÀɮפl¥\¯àªí¤¤ªº¿ï¶µ¡AR10D¡BR11D ¬°Àɮפl¥\¯àªí¿ï¶µªº¼e»P°ª¡C¦AÀˬd MEASUREITEMSTRUCT µ²ºcÅ骺 itemID Äæ¦ì¡A¨M©w¬O¦]¬°«Ø¥ß¤FþÓ¤l¥\¯àªí¤¤ªº¿ï¶µ¡A¦pªG°²³]¥¿½T´N¥iª½±µ±N R10D¡BR11D ¦s¤J MEASUREITEMSTRUCT µ²ºcÅ骺 itemWidth¡BitemHeight Äæ¦ìùØ¡AµM«áªð¦^¡C¦pªG°²³]¿ù¤F¡AÁÙ±o¥ý§â R10D¡BR11D «³]¬°¦r§Î¤l¥\¯àªí¿ï¶µªº¼e»P°ª¡AµM«á¦A¦s¤J itemWidth¡BitemHeight Äæ¦ìùØ¡C
¦b³o¸ÌÁÙ¦³¨â³Bȱo¤@´£¡C¤@¬O¥Ñ¤»Ó¤¸¯À²Õ¦¨ªº hBmp °}¦C¡A³oÓ°}¦C¬O¥Î¨Ó¨Ì§ÇÀx¦s¡u«Ø·sÀɮסv¡B¡u¶}±ÒÂÂÀɮסv¡B¡uÀx¦sÀɮסv¡B¡uÂ÷¶}¡v¥|ӿﶵ«eªº¦ì¤¸¹Ï¥N½X¡C¦Ó²Ä¥|Ó¤¸¯À¬O BEAUTY.bmp ªº¥N½X¡A²Ä¤Ó¤¸¯À¬O CHECKED.bmp ªº¥N½X¡A«eªÌ¬O¬ü¤k¹ÏÅã¥Ü©ó¦r§Î¤l¥\¯àªíªºI´º¡A«áªÌ¥Î©ó¦r§Î¤l¥\¯àªí¿ï¶µ«eªº¥¿¤è§Î¤Ä¿ï°O¸¹¡C¦ì¤¸¹Ï¥N½Xªº¸ê®ÆÃþ«¬¬O HBITMAP¡A¬O¤KӦ줸²Õªø¡A¦]¦¹©w¸q¬°¡G
hBmp HBITMAP 6 DUP (?)
©Ò¥Hn¦s¨ú hBmp °}¦Cªº¦ì¤¸¹Ï¥N½X¥i¥H¥Î hBmp[8¡Ñm]¡Am ¬O²Ä´XÓ¤¸¯À¡Am ¥Ñ 0 ¨ì 5¡CY m ¬° 4¡Apºâµ²ªG¬° hBmp[32]¡A´N¬O¬ü¤k¹Ï¥N½X¡C
²Ä¤GÓȱo¤@´£ªº¬O ASSUME »P PTR °²«ü¥O¡C
¦b²Ä¤G³¹®É¡A´¿¤¶²Ð¹L PTR ¹Bºâ¤l¡A¥¦¬O¥Î¨Ó±j¨î§ïÅܹBºâ¤¸ªº¸ê®ÆÃþ«¬¡C¨Ò¦p©³¤Uªº¨Ò¤l¡AÁöµM number ©w¸q¬°Âù¦r²Õ¡A¦ý¬O«o¥i¥Î PTR ±j¨îÅܬ°¦r²Õ¡A³Ì«á CX Åܬ°5678H¡G
number DD 12345678h ⁝ mov cx,WORD PTR number
¨Æ¹ê¤W¡APTR ¦³¨âºØ¥Îªk¡A³o¨àn¤¶²Ð²Ä¤GºØ¥Îªk¡C·í PTR «á±±µµÛªº¬Oµ²ºcÅé®É¡A²ÕĶ¾¹·|§â PTR ·í¦¨¬O«ü¦V¸Óµ²ºcÅ骺«ü¼Ð¡A³o»Ýn»P ASSUME °²«ü¥O°t¦X¡A½Ð¬Ý©³¤U ASSUME °²«ü¥Oªº»¡©ú¡C
ASSUME ªº¥Îªk¦³³\¦hºØ¡A¦¹³B¥u¦C¥X ONDMENU ¥Î¨ìªº¨âºØ¡G
ASSUME dataregister:qualifiedtype [[, dataregister:qualifiedtype]] ASSUME [[register:]]NOTHING [[, register:NOTHING]]
ASSUME ªº²Ä¤@ºØ¥Îªk¬O¨Ï¬YÓ³q¥Î¼È¦s¾¹¨ã¦³¯S©wªº¸ê®ÆÃþ«¬¡Cdataregister ¬O«ü³q¥Î¼È¦s¾¹¡A¥]§t RAX¡BRBX¡K¡K¡BR8¡BR9¡K¡Kµ¥¤»¤Q¥|¦ì¤¸ªº¼È¦s¾¹¡A©Î¬O«ez¼È¦s¾¹§ó¤p¦ì¤¸ªº¼È¦s¾¹¡A¨Ò¦p EAX¡BAX¡BAL¡K¡Kµ¥¼È¦s¾¹¡Fqualifiedtype ¬O¸ê®ÆÃþ«¬¡A¥i¥H¬O QWORD¡BDWORD¡BWORD¡K¡Kµ¥¡A¤]¥i¥H¬Oµ²ºcÅé¡]¨Æ¹ê¤W¡Aµ²ºcÅé¬OÀ³¥Îµ{¦¡¦Û¦æ«Å§iªº¸ê®ÆÃþ«¬¡^¡C¨Ò¦p©³¤Uªº¨Ò¤l§â BX ³]©w¬° WORD ¸ê®ÆÃþ«¬¡G
ASSUME bx:WORD
¨ä¹ê³o¬O¦h¦¹¤@Á|¡A¦]¬° BX ¥»´N¬O¤Q¤»¦ì¤¸¡Aªø«×¥»´N¬O¤@Ó¦r²Õ¡C¨Æ¹ê¤W¡A¦pªG dataregister »P qualifiedtype ªø«×¤£¬Û²Å¡AÁÙ·|¾ÉP¿ù»~¦ÓµLªk²ÕĶ¡C¡uASSUME dataregister:qualifiedtype¡v¤ñ¸û±`¨£ªº¥Îªk¬O¥Î¦bµ²ºcÅé¤W¡A¤×¨ä¬Oµ²ºcÅ骺«ü¼Ð¤W¡C¨Ò¦p¡G
ASSUME r9:PTR MEASUREITEMSTRUCT
¡uPTR MEASUREITEMSTRUCT¡vªº¹Bºâµ²ªG¬O±o¨ì MEASUREITEMSTRUCT µ²ºcÅ骺«ü¼Ð¡A©Ò¥H¤W±ªºµ{¦¡¬O§i¶D²ÕĶ¾¹¡AR9 ¬O«ü¦V MEASUREITEMSTRUCT µ²ºcÅ骺«ü¼Ð¡C¦pªGn¦s¨ú¸Óµ²ºcÅ餺ªºÄæ¦ì¡A¥un¦A¥[¤W¸ÓÄæ¦ìªº°¾²¾¦ì§}§Y¥i¡C¨Ò¦pn§â itemID Äæ¦ì¤ºªº¸ê®Æ¦s¤J EAX ¼È¦s¾¹¤º¡A¥i¥H¥Î¥H¤Uµ{¦¡¡G
msi MEASUREITEMSTRUCT <?> ⁝ lea r9,msi ASSUME r9:PTR MEASUREITEMSTRUCT mov eax,[r9].itemID
©Î³\¦³ÅªªÌ·|°Ý¡A¥i¤£¥i¥H¨Ï¥Î¡uASSUME r9:MEASUREITEMSTRUCT¡v©O¡Hµª®×¬O¤£¥i¥H¡A³o¼Ëªº¸Ü´N¬O¨Ï R9 Åܬ° MEASUREITEMSTRUCT ¸ê®ÆÃþ«¬¡A³o¨âªÌªø«×ÅãµM¬O¤£²Å¦X¡A·|µo¥Í¿ù»~¡C
ASSUME ªº²Ä¤GºØ¥Îªk¬O¡uASSUME register : NOTHING¡v¡A¨ú®ø¹ï register ªº°²³]¡A¥HÁקK«áÄòµ{¦¡¤¤¹ï register ¿ù»~ªº¸ÑÄÀ¡C
·ínÅã¥Ü¾Ö¦³ªÌø»s¿ï¶µ®É¡A¨t²Î·|§â WM_DRAWITEM °T®§¶Çµ¹µøµ¡¨ç¦¡¡AlParam ¬O DRAWITEMSTRUCT µ²ºcÅ骺¦ì§}¡A¨Ã¥B lParam ¤§È·|¦s¤J R9 ¼È¦s¾¹¤º¡A¦bø»s¿ï¶µ®É¡A¤Ö¤£¤F±oŪ¨ú¦¹µ²ºcÅ餺ªº¸ê®Æ¡C¥»¨Ó¥i¥H¸ò³B²z WM_MEASUREITEM ªº¤è¦¡¤@¼Ë¡A°²³]¡uASSUME R9:PTR DRAWITEMSTRUCT¡vª½±µ¦s¨ú lParam ©Ò«üªº¸ê®Æ¡A¦ý¬O¨C¦¸©I¥s Win64 API ¤§«á¡AR9 ¤§È·|§ïÅÜ¡A©Ò¥H¥²¶·¥t°_Äl¨_¤~¦æ¡C¦³¨âºØ¤èªk¡G
①¡G¥t¥~§ä¤@Ó¤£·|¦]¬°©I¥s Win64 API ¦Ó§ïÅܪº¼È¦s¾¹¡A¨ä¹ê¤£Åܪº¼È¦s¾¹³£¥i¥H¡A¨Ò¦p RBX¡BRSI µ¥¡C
②¡G§â R9 ©Ò«ü¦ì§}ªº DRAWITEMSTRUCT µ²ºcÅé¦s¤J¥t¤@Óµ²ºcÅ餺¡CONDMENU ±Ä¥Î³oºØ¤èªk¡A¨Ã§â«áªÌ©w¸q¦b dis °Ï°ìÅܼƤ¤¡C¤]´N¬O¶}©l³B²z WM_DRAWITEM °T®§ªº«e´X¦æ«ü¥O¡G
.case WM_DRAWITEM
;§âlParam«ü¦VªºDRAWITEMSTRUCT¤º¸ê®Æ½Æ»s¨ìdis°Ï°ìÅܼƤº
mov rcx,SIZEOF DRAWITEMSTRUCT
lea rdi,dis
mov rsi,r9
rep movsb
⁝
³B²z WM_DRAWITEM °T®§¤]¤À¦¨¨â³¡¤À¡A¤@¬O³B²zÀɮפl¥\¯àªí¡A¤G¬O³B²z¦r§Î¤l¥\¯àªí¡C¦ý¦b¤À¶}³B²z¤§«e¡AÁÙ¦³¤T¥ó¨Æ¬O³B²z¨âÓ¤l¥\¯àªí³£·|°µªº¨Æ¡G
⑵¡B«Ø¥ß¬Û®e©ó dis.hdc ªº°O¾ÐÅé¸Ë¸m¤º®e¡C¦bø»sÀɮפl¥\¯àªí»P¦r§Î¤l¥\¯àªíªº®ÉÔ¡A³£·|n§â¦ì¤¸¹ÏÅã¥Ü¦b¤l¥\¯àªíªº¸Ë¸m¤º®e¤¤¡A«eªÌnµe¥X¥|ӿﶵ¤å¦r«eªº¦ì¤¸¹Ï¡A«áªÌnµe¥X¬ü¤kI´º¹Ï¡C³o®É¶·©I¥s BitBlt¡A¦]¦¹©I¥s CreateCompatibleDC «Ø¥ß°O¾ÐÅé¸Ë¸m¤º®e¡C
;³]©w¿ï¶µ¤å¦rÃC¦â¡A¿ï¾Üªº¥Î¥Õ¦â¡A¥¼¿ï¾Üªº¥Î¹w³]ªº¿ï¶µ¤å¦rÃC¦â
mov edx,clrMenuText
test dis.itemState,ODS_SELECTED
jz @f
mov edx,0ffffffh
³B²z¦n¨âÓ¤l¥\¯àªí¬Û¦Pªº¤T¥ó¨Æ¤§«á¡A´N±o§PÂ_ dis.itemID ¬O§_¤p©ó IDM_STDKAI¡A¨Ó°Ï¤À⑴³B²zÀɮפl¥\¯àªíÁÙ¬O³B²z⑵¦r§Î¤l¥\¯àªí¤ºªº¿ï¶µ¡C¥ý¨Ó¬Ý¬Ý¦p¦ó³B²zø»sÀɮפl¥\¯àªí¤ºªº¿ï¶µ¡C
¥ý»¡©ú⒜¤¤ªº¬õ¦â¥ú´Î©MI´º¦â¦p¦óø»s¡C¨ä¹ê«Ü²³æ¡A¥u¬O©I¥s FillRect §Y¥i¡A³Q¿ï¾Üªº¿ï¶µ°Ñ¼Æµe¨ê¬°¬õ¦âµe¨ê¡A¥¼³Q¿ï¾Üªº¿ï¶µ°Ñ¼Æµe¨ê¬°¥\¯àªí¹w³]I´ºµe¨ê¡A¾ã¬qµ{¦¡¦p¤U¡G
;ø»s¿ï¶µªºI´º¦â¡A¿ï¾Üªº¬°¬õ¦â¡A¥¼¿ï¾Üªº¬°¹w³]È
mov r8,hbrMenuBk
test dis.itemState,ODS_SELECTED
jz @f
mov r8,hbrRed
@@: invoke FillRect,dis.hDC,ADDR dis.rcItem,r8
¦bÀˬd¬O§_¬°³Q¿ï¾Üªº¿ï¶µ®É¡A¨Ï¥Î TEST «ü¥O¡A¦Ó¤£¬O CMP «ü¥O¡A¬O¦]¬°¿ï¶µªºª¬ºA°£¤F³Q¿ï¾Ü¡þ¥¼³Q¿ï¾Ü¡AÁÙ¦³³\¦hºØ¨Ò¦p¤Ä¿ï¡þ¥¼¤Ä¿ïµ¥µ¥¡C¨CºØª¬ºA³£¥Î¤@Ӧ줸ªí¥Ü¡A¦]¦¹¦³³\¦hºØ²Õ¦X¡A¨Ï¥Î TEST Àˬd ODS_SELECTED ¥Nªíªº¦ì¤¸¬O³Ì²³æªº¤@ºØ¤è¦¡¡C
è´£¹L¡A¨C¦¸§ó·s¿ï¶µ¨t²Î´N·|§â WM_DRAWITEM °T®§¶Çµ¹µøµ¡¨ç¦¡¡A¸ò WM_MEASUREITEM °T®§¤@¼Ë¡Aµøµ¡¨ç¦¡¶È»Ý°w¹ï¸Ó¿ï¶µ³B²z§Y¥i¡C·N«ä¬O»¡¦b³B²z WM_DRAWITEM ®É¡A©Òø»sªº¤å¦r©Î¹Ï®×¤£À³¶W¹L DRAWITEMSTRUCT ¤¤ rcItem Äæ¦ìªº¯x§Î½d³ò¡A¦ý³o¨S¦³±j¨î³W©w¡C¥t¥~¡ArcItem ¯x§Î¥ª¤W¨¤®y¼ÐªºìÂI«o¬O¦ì©ó¾ãÓ¤l¥\¯àªí²Ä¹sӿﶵªº¥ª¤W¨¤¡A°Ñ¦Ò¤U¹Ï¡G °²¦p¤@ӿﶵªº°ª«×¬O 20 Ó¹³¯À¡A¥ç§Y cyFileMenu µ¥©ó 20¡A¨º»ò±Nnø»s²Ä¹sӿﶵ®É rcItem ¥ª¤W¨¤®y¼Ð¬O ( 0,0 )¡A±Nnø»s²Ä¤@ӿﶵ®É rcItem ¥ª¤W¨¤®y¼Ð¬O ( 0,20 )¡K¡K¨Ì¦¹Ãþ±À¡C
°ò©ó¤Wzì¦]¡A¦pªGn§â¿ï¶µ¤å¦r¤§«eªº¦ì¤¸¹Ï¹]Áè¸m¤¤ªº¸Ü¡A¥²¶·§â cyFileMenu ´î¥h cyBmFile¡]¦¹¬°¦ì¤¸¹Ï°ª«×¡^¡AµM«á°£¥H¤G¡A³Ì«á¥[¤W rcItem ¥ª¤W¨¤ªº Y ®y¼Ð¡Cµ{¦¡½X¦p¤U¡G
;§â°O¾ÐÅé¸Ë¸m¤º®eªº¦ì¤¸¹Ï½Æ»s¨ìÀɮפl¥\¯àªíªº¸Ë¸m¤º®e¤¤ mov edx,cxBmFile ;¦ì¤¸¹ÏÅã¥Ü¦b¤l¥\¯àªíªº¸Ë¸m¤º®e¡AX®y¼Ð¥Ñ¥ª½t¶} shr edx,1 ;©l¥bӦ줸¹Ï¼eªº¦a¤è mov r8d,cyFileMenu ;Y®y¼Ð¦b¹]Áè¸m¤¤³B¡A¦ý¦ì¸m¤@¡B¤G¡B¤T¡K¡KÁÙn¥[¤W sub r8d,cyBmFile ;¹]Áè°ª«×¶ZÂ÷¤l¥\¯àªí¦h»· shr r8d,1 add r8d,dis.rcItem.top invoke BitBlt,dis.hDC,edx,r8d,cxBmFile,cyBmFile,hdcMem,0,0,SRCCOPY
⒜¡B©Î³\¦³¨ÇŪªÌ·|¦³ºÃ°Ý¡A¤W±ªº¨BÆJ«ç»ò¨S¦³Ã¸»s¬õ¦â¥ú´Îªº¨BÆJ©O¡HONDMENU ¬O¥Î¥©§®ªº¤èªk§â¬õ¦â¥ú´Îø»s¥X¨Ó¡A²³æªº»¡¬O§Q¥Î BitBlt ³Ì«á¤@ӰѼƪº¯S©Ê¡AdwRop ¦³³\¦hºØ¡A¨ä¤¤ªº MERGECOPY ¥i¥H¨Ï¸Ë¸m¤º®eªºµe¨ê»P¨Ó·½¦ì¤¸¶i¦æ AND ¹Bºâ¡A³o¼Ë´N¯à±N¬õ¦â¥ú´Îªí²{¥X¨Ó¤F¡Aµ{¦¡½X¦p¤U¡G
invoke SelectObject,hdcMem,hBmp[32] ;±NBEAUTY.bmp¿ï¤J°O¾ÐÅé¸Ë¸m¤º®e invoke SelectObject,dis.hDC,hbrRed ;±N¬õ¦âµe¨ê¿ï¤J¥\¯àªíªº¸Ë¸m¤º®e mov r11,SRCCOPY ;¦pªG¿ï¶µ¬O¥¼³Q¿ï¾Üªº¡A¥ÎSRCCOPY test dis.itemState,ODS_SELECTED ;¦pªG¿ï¶µ¬O³Q¿ï¾Üªº¡A¥ÎMERGECOPY jz @f mov r11,MERGECOPY @@: invoke BitBlt,dis.hDC,dis.rcItem.left,dis.rcItem.top,cxFontMenu,\ cyFontMenu,hdcMem,dis.rcItem.left,dis.rcItem.top,r11d
⒝¡B©I¥s CreateFont «Ø¥ßÅÞ¿è¦r§Î®É¡A³Ì«nªº¤TӰѼƬO nHeight¡BfdwCharSet¡BlpszFace¡A¦b ONDMENU ¤¤ nHeight ¬O¿ï¶µ°ª«×´î¥|¡A³o¼Ë¥i¥HÅý¿ï¶µ¤å¦r¦b¿ï¶µ¤º¹]Áè¸m¤¤¡CfdwCharSet ¨Ï¥Î¨t²Î¤º©wªº¦r¤¸¶°¡ADEFAULT_CHARSET¡A§Y¥i¡C³Ì³Â·Ðªº¬O lpszFace¡A¦r§Î¦WºÙ¡A¦b .CONST °Ï¬q¤º¦³¥H¤Uªº©w¸q¡G
szStdKai DB "¼Ð·¢Åé",0 szNewMing DB "·s²Ó©úÅé",0 szCourierNew DB "Courier New",0 szTimesNewRoman DB "Times New Roman",0 szMSSansSerif DB "Microsoft Sans Serif",0 ALIGN 8 paryFont LPSTR OFFSET szStdKai,OFFSET szNewMing,OFFSET szCourierNew LPSTR OFFSET szTimesNewRoman,OFFSET szMSSansSerif
paryFont ªº¦WºÙ¦³ p ¥Nªí«ü¼Ð¤]´N¬O¦ì§}¡Aary ªí¥Ü°}¦C¡A´«¥y¸Ü»¡ paryFont ¬O¥Ñ¦ì§}²Õ¦¨ªº°}¦C¡A³o¨Ç¦ì§}¨ä¹ê´N¬O¤ºØ¦r§Î¦WºÙªº¦ì§}¡C¤U¹Ï¬O¬Y¦¸¥H x64dbg ¹ï ONDMENU.EXE °£¿ù®É¡A°O¾ÐÅ餤ªº¤º®e¡C¦b¦ì§} 564060H ³Bªº¼ÆȬO 0C0H¡A¦b¦ì§} 564061H ³Bªº¼ÆȬO 0C9H¡A¦Ó¤@Ó¤¤¤å¦r¥Î¨âӦ줸²Õªí¥Ü¡A0C0C9H ´N¥Nªí¡uÀÉ¡v¦r¡C¤U¹Ïªº¸ÑŪ¤è¦¡´N¸ò x64dbg ªº¸ê®ÆÅã¥Ü°Ï¤@¼Ë¡C
¹ï·Ó¤W±µ{¦¡¡AparyFont ªº¦ì§}¥»À³¸Ó¦b szMSSansSerif ¤§«áªº 5640ABH ³B¡A¦ý¦]¬°¡uALIGN¡v°²«ü¥O¡]°Ñ¦Òµù¤G¡^¡A²ÕĶ¾¹´¡¤J¤Ó¦ì¤¸²Õªº¹s¡]¥H¶À¦â®Ø³ò¦í¡^¨Ã¨Ï¨ä²¾¦Ü¦ì§} 5640B0H ³B¡]¾í¦â½bÀY©Ò«ü³B¡^¡A¸Ó¦ì§}¤]¬O²Ä¹sÓ¤¸¯Àªº¦ì§}¡A²Ä¹sÓ¤¸¯À¤º®e¬O 56406AH¡]¥HÂŦâ®Ø½u³ò¦í¡A³o¬O¤p§ÇºÝ¡A°Ñ¦Ò³oùØ¡^¡A¦¹¬°¡u¼Ð·¢Åé¡v¦r¦êªº¦ì§}¡F²Ä¤@Ó¤¸¯À¦ì©ó¦ì§} 5640B8H ³B¡A¨äȬ° 564071H¡A¬O¡u·s²Ó©úÅé¡v¦r¦êªº¦ì§}¡K¡K¨Ì¦¹Ãþ±À¡C ¦b Win64 ¨t²Î¤¤¡A¦ì§}³£¥H 64 ¦ì¤¸ªí¥Ü¡A64 ¦ì¤¸´N¬O¤KӦ줸²Õ¡A¦]¦¹¥un¯àª¾¹D²Ä´XÓ¤¸¯À¡A»´©ö´N¯àºâ¥X¦r§Îªº©Ò¦b¦ì§}¡Cµ{¦¡¦p¤U¡G
;«Ø¥ßÅÞ¿è¦r§Î movzx rax,WORD PTR dis.itemID sub rax,IDM_STDKAI ;RAX¡×paryFont¤ºªº²Ä´XÓ¤¸¯À lea r10,paryFont[rax*8] ;R10¡×¸Ó¤¸¯Àªº¦ì§} mov r11,[r10] ;R11¡×¸Ó¤¸¯Àªº¤º®e¡×¦r§Î¦WºÙªº¦ì§} mov rsi,r11 ;RSI¡×¦r§Î¦WºÙªº¦ì§}¡A©I¥sDrawText®É¤~¥Î mov ecx,cyFontMenu sub ecx,4 mov rdi,rcx ;RCX¡×¦r§Î°ª«× invoke CreateFont,ecx,0,0,0,FW_THIN,0,0,0,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,\ CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH or FF_DONTCARE,r11
¨Ò¦p¨Ï¥ÎªÌÂI¿ï¦r§Î¤l¥\¯àªí¤¤¡A¦ì¸m²Ä¤Gªº¿ï¶µ¡A¤]´N¬OÂI¿ï¡uCourier New¡v¦r§Î¡AWindows ·|±N WM_DRAWITEM °T®§¶Çµ¹µøµ¡¨ç¦¡¡A¦Ó¨ä DRAWITEMSTRUCT ªº itemID Äæ¦ì¬° 2102¡C³o¨Ç¿ï¶µªºÃѧO½X¬O¦h¤Ö¡A¥²¶·¥h¬d¾\ ONDMENU.ASM ²Ä 154¡ã165 ¦æ¡CONDMENU n°µªº´N¬Opºâ¥X¡uCourier New¡v¦r¦ê¦ì§}¡A±N¨ä´î±¼ IDM_STDKAI¡]IDM_STDKAI µ¥©ó 2100¡^¡A±o¨ì¦b paryFont ùتº²Ä´XÓ¤¸¯À¡A¦¹®É RAX ¬° 2¡C
±µ¤U¨Ón°õ¦æªº¬O¡uLEA R10,paryFont[RAX¡Ñ8]¡v«ü¥O¡ALEA ·|¨ú±o¨Ó·½¹Bºâ¤¸ªº¦ì§}¡A±N¨ä¦s©ó R10 ¤º¡CRAX ¼¥H¤K¡A´N±o¨ì¦¹¦ì§}¶ZÂ÷ paryFont °}¦C¶}©l¦ì§}¦³¦h¤ÖӦ줸²Õ¡A«e±ªº paryFont ¦ì§}¬O 5640B0H¡A©Ò¥H paryFont[RAX¡Ñ8] ªº¦ì§}¬O 5640C0H¡A°õ¦æ§¹ LEA «á¡AR10 µ¥©ó 5640C0H¡C
±µ¤U¨Óªº«ü¥O¬O¡uMOV R11,[R10]¡v¡A·N«ä¬OŪ¨ú R10 ©Ò«ü¦ì§}ªº°O¾ÐÅ餺®e¡A±N¨ä¦s¤J R11¡C¤]´N¬O§â¦ì§} 5640C0H ªº¤º®e¡A56407AH¡A¦s¤J R11¡C³Ì«á R11 µ¥©ó 56407AH¡A¨ì¦¹ R11 ¤§È´N¬O¡uCourier New¡v¦r¦ê¦ì§}¡C
µM«á¬O¡uMOV RSI,R11¡v¡A³oÓ«ü¥O§â ONDMENU ¨¯¨¯WWpºâ±o¨ìªº¦r§Î¦WºÙ¦ì§}¦s¦b RSI ¤¤¡Aµ¥¨ì¦b¥\¯àªí¿ï¶µ¤¤¦L¥X¿ï¶µ¤å¦r®É¥Î±oµÛ¡A¦]¬°¿ï¶µ¤å¦r´N¬O¦r§Î¦WºÙ¡C±µ¤U¨Óªº¤T¦æpºâ CreateFont ªº nHeight °Ñ¼Æ¡A«e±¤w±Ôz¹L¤F¡A¤£¦hÁ¿¤F¡C
¥i¯à¦³¤H·|°Ý¡A¡u¤£Åܪº¼È¦s¾¹¡v¤£¬O»¡¤£¥iÀH·N§ïÅܨäȶܡH³o¨à«ç¯à¨Ï¥Î RSI ¼È®É«O¦s¦Û¦æ¦WºÙ¦ì§}©O¡H¨Æ¹ê¤W¡A¦b«Å§iµøµ¡¨ç¦¡®É¡A¥[¤W¤F¡uUSES¡v¡A¦p¤U¡G
WndProc PROC USES rsi rdi hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
´N¯à§â USES ¤§«áªº¼È¦s¾¹¦Cªí¦s¤J°ïÅ|¤¤¡Aµ¥µøµ¡¨ç¦¡ªð¦^®É¡A¦A«ì´_ìÈ¡C
⒞¡Bø»s¿ï¶µ¤å¦r¡A¥²¶·¨Ì¾Ú¤£¦P¦r§Îø»sªº¤å¦r¦r§Î¤]¤£¦P¬Ý°_¨Ó¦ü¥G«ÜÃø¡A¦ý«e±¤w«Ø¥ß¦nÅÞ¿è¦r§Î¡A¤]¤w±N¦r§Î¦WºÙ¦ì§}¦s¦b RSI ¤¤¡A¦]¦¹¤£¹³·Q¹³¤¤ªºÃø¡Cµ{¦¡½X¦p¤U¡A©I¥s SelectObject ®É²Ä¤GӰѼơARAX¡A¨ä¹ê´N¬O CreateFont ªº¦^¶ÇÈ¡A·N«ä´N¬O§â«Ø¥ßªºÅÞ¿è¦r§Î¿ï¤J¸Ë¸m¤º®e¤º¡C
;±N¦¹ÅÞ¿è¦r§Î¿ï¤J¥\¯àªíªº¸Ë¸m¤º®e¤¤µM«áø»s¿ï¶µ¤å¦r invoke SelectObject,dis.hDC,rax invoke DeleteObject,rax ;ì¨Óªº¦r§Î¤w¤£¥Î¡A¾P·´¥¦ add dis.rcItem.left,edi ;¿ï¶µ¤å¦r¦b¿ï¶µ¶}©l¤§³B¤@Ó¦r§Î¼e«×¶}©l invoke DrawText,dis.hDC,rsi,-1,ADDR dis.rcItem,DT_SINGLELINE or DT_VCENTER
⒟¡B³Ì«á¤@¥ó¨Æ¬O¦b¤Ä¿ïªº¿ï¶µ«e¡Aø»s¤@¥¿¤è§Î¥Nªí¦¹¿ï¶µ¬°¤Ä¿ïªº¡C¤£¹L³o¥ó¨Æ¬O¥u¦³¿ï¶µ¬°¤Ä¿ïª¬ºA®É¡A¤~»Ýn¶i¦æ¡CÀˬd³oª¬ºA¤]«Ü®e©ö¡AÀˬd DRAWITEMSTRUCT ªº itemState Äæ¦ì¬O§_§t ODS_CHECKED §Y¥i¡Cµ{¦¡½X¦p¤U¡G
;ø»s¤Ä¿ïª¬ºA
test dis.itemState,ODS_CHECKED
jz @f
invoke SelectObject,hdcMem,hBmp[40]
mov r8d,cyFontMenu
sub r8d,14
shr r8d,1
add r8d,dis.rcItem.top
invoke BitBlt,dis.hDC,2,r8d,14,14,hdcMem,0,0,SRCINVERT
¦¹¥¿¤è§Îªº¼e»P«×¬Ò¬° 14 Ó¹³¯À¡A¦ì¤¸¹Ï¥N½X¬O hBmp °}¦Cªº²Ä¤Ó¤¸¯À¡A¦b¡uTEST dis.itemState,ODS_CHECKED¡v¤§«á¡A«K±N hBmp[40] ¿ï¤J°O¾ÐÅé¸Ë¸m¤º¤§¤¤¡A¦A©I¥s BitBlt ±N¨ä¶Ç¿éµ¹¥\¯àªí¸Ë¸m¤º®e¡A´N¯àµe¥X¥¿¤è§Î¤F¡F¦ý¤S¤£¬O¯u¥¿ªº¶Ç¿é¹L¥h¡A¦Ó¬O§â¥¿¤è§Î»P¨ä«á±ªº¬ü¤k¹Ï¶i¦æ¤¬¥¸©Î¹Bºâ¡A³o¼Ë¤~¤£·|´N¬O¤@ӤĿ諸¤è¶ô¦ÓÅã±o¤Ó§bª©¡C
³B²z WM_DRAWITEM °T®§ªº³Ì«á±¡A´N¬O±N©I¥s DeleteDC¡A§â°O¾ÐÅé¸Ë¸m¤º®e¾P·´¡C³o¤@¨B¡A¤£½×¬O⑴ø»sÀɮפl¥\¯àªí¡AÁÙ¬O⑵ø»s¦r§Î¤l¥\¯àªí³£¥²¶·°µ¡A¦]¬°¦b¤À¶}³B²z¤§«e¡A³£´¿«Ø¥ß°O¾ÐÅé¸Ë¸m¤º®e¡C
ONDMENU ¨ä¥L³¡¤À¡A¦b«e±³£¤w¤¶²Ð¹L¤F¡A´N¤£¦h»¡¤F¡A¦Ó¥B³o¤@³¹¤º®e¤]°÷¦h¤F¡C
¦b MASM64 SDK »P WinInc ¤¤¡AMENUITEMINFO µ²ºcÅé¤À§O©w¸q¦b win64.inc »P winuser.inc ¥]§tÀɤº¡A¨ä¤º®e¦p¤U¡G
MASM64 win64.inc | WinInc winuser.inc | ¥¿½T |
MENUITEMINFO STRUCT cbSize UINT ? fMask UINT ? fType UINT ? fState UINT ? wID UINT ? DWORD ? hSubMenu HMENU ? hbmpChecked HBITMAP ? hbmpUnchecked HBITMAP ? dwItemData ULONG_PTR ? dwTypeData LPTSTR ? cch UINT ? DWORD ? hbmpItem HBITMAP ? MENUITEMINFO ENDS | MENUITEMINFOA STRUCT cbSize DWORD ? fMask DWORD ? fType DWORD ? fState DWORD ? wID DWORD ? hSubMenu HMENU ? hbmpChecked HBITMAP ? hbmpUnchecked HBITMAP ? dwItemData ULONG_PTR ? dwTypeData LPSTR ? cch DWORD ? if (WINVER ge 0500h) hbmpItem HBITMAP ? endif MENUITEMINFOA ENDS | MENUITEMINFO STRUCT cbSize DWORD ? fMask DWORD ? fType DWORD ? fState DWORD ? wID DWORD 2 DUP(?) hSubMenu HMENU ? hbmpChecked HBITMAP ? hbmpUnchecked HBITMAP ? dwItemData ULONG_PTR ? dwTypeData LPSTR ? cch DWORD 2 DUP (?) hbmpItem HBITMAP ? MENUITEMINFO ENDS |
³o¨âÓ©w¸q³£¬O¿ùªº¡C¤£½×¬O 32 ¦ì¤¸ÁÙ¬O 64 ¦ì¤¸ªº Windows ¤¤¡AUINT ¥NªíµL¸¹¾ã¼Æ¡]unsigned integer¡^¡Aªø«×§¡¬° DWORD¡A¦ý¦b win64.inc ¤¤»~´Ó¬° QWORD¡CWinInc ¤¤ªº MENUITEMINFO ¦b winuser.inc ¤¤«Å§i¡A¨ä¤¤ªº wID »P cch ¨âÄæ¦ìªø«×¬° DWORD ¬O¨S¿ù¡A¦ý¬O¤ñ¥¦Ì°ª¥|Ӧ줸²Õªº¦ì§}¬O¤@ӪŤU¨Ó¨S¨Ï¥ÎªºÂù¦r²Õ¡A©Ò¥H¥¦Ìªº¤U¤@ÓÄæ¦ìªº¦ì§}¥²¶·¦A¤ñ¥¦Ìªº¦ì§}¼W¥[¤KӦ줸²Õ¤~¹ï¡C¤p¤ì°¸´¿¼¶¼gµ{¦¡¡A©I¥s GetMenuItemInfo ¤Ï¦V±À½×¦ÓÅçÃÒ¦¹¤@·Qªk¡A¨Ã±N¥¿½Tªº MENUITEMINFO µ²ºcÅé¼g¦b¤Wªí³Ì¥kÄæ¡C
¥t¥~¡AWinInc ¤¤ªº MENUITEMINFO ¦³¨âÓª©¥»¡A¤À§O¹ïÀ³ ANSI ½s½Xªº¦r¦ê»P¼e¦r¤¸½s½Xªº¦r¦ê¡C¥¦Ì¤§¶¡ªº®t§O¥u¦³ dwTypeData Äæ¦ìªº¸ê®ÆÃþ«¬¤£¦P¡A«eªÌ¬O LPSTR¡A«áªÌ¦p¤U¡G
dwTypeData LPWSTR ?
¤£¹L¡A¤£½×¬O LPSTR ©Î LPWSTR¡A¹ê»Ú¤W³£¬O QWORD¡A¥¦Ì³£¥Nªí¦r¦ê¦ì§}¡A¹ï²Õ¦X»y¨¥¦Ó¨¥¨ä¹ê¬O¨S¦³®t§O¡C
¬°¦ón±N¦b wID¡Bcch ¤§«á¡A¦h¥X¨âÓ¨S¦³¦WºÙªºÄæ¦ì©O¡H¥Dn¬O¬°¤F¥[³t°O¾ÐÅ骺¦s¨ú¡C¦b 64 ¦ì¤¸ªº¹q¸£¤¤¡A¦pªG©Ò¦s¨úªº¸ê®Æ¦ì§}¬O¦s¨ú¸ê®Æªø«×ªº¾ã¼Æ¿¡A¨º»ò¦s¨ú³t²v¸û§Ö¡A¤Ï¤§ CPU »ÝnÃB¥~ªº®É¯ß¶g´Á¨Ó¦s¨ú¸ê®Æ¡A·|°§C®Ä²v¡C¨Ò¦pn¦s¨úÂù¦r²Õªº¸ê®Æ¡A¦pªG¦¹¸ê®Æ¦b¦ì§} 495000H¡A·|¤ñ¦b¦ì§} 495002H ¦s¨ú±o§Ö¡F³o¬O¦]¬°Âù¦r²Õªø 4 Ӧ줸²Õ¡A495000H ¯à³Q 4 ¾ã°£¡A¦Ó 495002H ¤£¯à³Q 4 ¾ã°£¡C¹³³oºØ©Ò¦s¨úªº¸ê®Æ¦ì§}¬O¦s¨ú¸ê®Æªø«×ªº¾ã¼Æ¿¡AºÙ¬°¡u¹ï»ô¡v¡A¯à¼W¥[¦s¨ú®Ä²v¡A²z¥Ñ»P´¹¤ù¤º¹q¸ô³]p¦³Ãö¡C
¦b MENUITEMINFO µ²ºcÅ餤¡AwID ¤§«á¦h¤F¤@ÓµL¦WªºÄæ¦ì¡A´N¬On¨Ï hSubMenu ¹ï»ô¦b¤K¦ì¤¸²Õªº¦ì§}¤W¡A·íµM³oÓ«e´£¬O MENUITEMINFO µ²ºcÅé©w¸q¦b¸`ªº¦ì§}¤W¡C¡]¸`¡A^¤åºÙ¬° paragraph¡A16 Ӧ줸ºÙ¬°¤@Ó¸`¡C¦b 64 ¦ì¤¸ªº Windows ¨t²Î¤¤¡A¤Z¬O¤°»ò¤°»ò¥N½X¡A¹³¥\¯àªí¥N½X¡B¦ì¤¸¹Ï¥N½X¡K¡K¡A¨äªø«×§¡¬°¥|¦r²Õ¡A§Y QWORD¡^
ALIGN ¬O¥Î¨Ó«ü¥Ü²ÕĶ¾¹§âµ{¦¡½X©Î¸ê®Æ¹ï»ô¬YÓ¦ì§}¡A¥H´£°ª¦s¨ú®Ä²v¡A¨ä¥Îªk¬O¡G
ALIGN boundary
boundary ¬O¤Gªº¾¦¸¤è¼Æ¡A¨Ò¦p 2¡B4¡B8¡B16¡Aªí¥Ü¦b¨Ï¥Î¤F ALIGN ¤§«á¡A¤U¤@Ó«ü¥O©Î¸ê®Æªº¦s©ñ¦ì§}¥²¶·¬O¯à³Q 2¡B4¡B8¡B16 ¾ã°£¡CÁöµM boundary ¥i¥H¬O¶W¹L 16¡A¦ý¬O·|®ö¶O«Ü¦h°O¾ÐÅé©Ò¥H«Ü¤Ö¥Î¡C
¦pªG¦bµ{¦¡¤¤ªº¸ê®Æ°Ï¬q¤¤©w¸q¤U±¸ê®Æ¡G
.CONST n1 DB 1 ALIGN 2 n2 DB 2 ALIGN 4 n3 DW 8086h ALIGN 8 str1 DB "TEST ALIGN",0 ALIGN 16 str2 DB "¤Ö¦~Ä@¡A²³¥Í©À¡A·ÀÃSÃR§¯¨¸¡I" szAppName DB "²Ä¤@ÓWin64µ{¦¡",0
¨º»ò¸ü¤J°O¾ÐÅ餧«á¡Aµ²ªG¦p¤U¹Ï¡G n2 ¤§«e¦³¡uALIGN 2¡v¡A©Ò¥H n2 ªº¦ì§}¥²¶·¬O¯à³Q 2 ¾ã°£¡C¦p¤W¹Ï¡An1 ¥u¦û¤@Ӧ줸²Õ¡A¦ì©ó¦ì§} 7F164000H¡A¥»¨Ó n2 À³©ñ¦b¦ì§} 7F164001H¡A¦ý¦]¬°¦³¡uALIGN 2¡v¡A²ÕĶ¾¹¦w´¡¤@Ӧ줸²Õªº 0¡]¥H¯»¬õ¦âªí¥Ü¡^¡A¨Ï 2 ©ñ¦b 7F164002H ³B¡Cn3 ¤§«e¦³¡uALIGN 4¡v¡A©Ò¥H n3 ªº¦ì§}¥²¶·¬O¯à³Q 4 ¾ã°£¡A¦]¦¹²ÕĶ¾¹¦w´¡¤@Ӧ줸²Õªº 0 ¡]¥H¾í¦âªí¥Ü¡^´N¥i¥HÅý n3 ©ñ¦b 7F164004H ³B¡C¦P²z¡A¬õ¦âªº¨âӦ줸²Õªº¹s»Pºñ¦âªº 13 Ӧ줸²Õªº¹s¡A¤À§O¬O AILGN 8¡BALIGN 16 ©Ò²K¥[ªº¡A¥H«K¨Ï str1¡Bstr2 ¦r¦ê¯à¦b¥|¦r²Õ¡B¸`ªºÃä¬É¤W¶}©l¡C
³oùؾã²z¤@¤U¡C