²Ä¤Q¤K³¹¡@¥\¯àªí¡]¤T¡^

³o¤@³¹ÁÙ¬O½Í¥\¯àªí¡A¦ý¬O§ï¥Î¥H©I¥s CreateMenu¡BInsertMenuItem¡BSetMenu µ¥ Win64 API ¨Ó«Ø¥ß¥D¥\¯àªí¡A¦Ó¤£¨Ï¥Î¸ê·½´y­zÀɤ¤ªº 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


»P¥\¯àªí¬ÛÃöªº Win64 API

CreateMenu API

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

InsertMenuItem API

¦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

MENUITEMINFO    STRUCT 
  cbSize        DWORD     ?         ;MENUITEMINFO ªºªø«×¡A¥H¦ì¤¸²Õ³æ¦ì
  fMask         DWORD     ?         ;ºX¼Ð¡A«ü©w­n¦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¡C­Y¨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ªG­n¤@¦¸³]©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¿ï¶µ¤¤Åã¥Ü¦ì¤¸¹Ï¡A­nÅã¥Üªº¦ì¤¸¹Ï¥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
dwItemDataWin64 ¨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
  1. MFT_BITMAP¡G¥Î¦ì¤¸¹ÏÅã¥Ü¿ï¶µ¦Ó¤£¥Î¤å¦r¡A¸Ó¦ì¤¸¹Ï¥N½X¦s©ó dwTypeData Äæ¦ì¥B©¿²¤ cch Äæ¦ì¡CMFT_BITMAP ¤§­È¬° 4¡C
  2. MFT_MENUBARBREAK¡G¹ï¥D¿ï³æ¦Ó¨¥¡A¦Û¦¹¿ï¶µ¶}©lÅã¥Ü©ó¤U¤@¦C¡F¹ï¤l¥\¯àªí¡B§Ö±¶¥\¯àªí¦Ó¨¥¡AÅã¥Ü©ó¤U¤@¦æ¥B¨â¦æ¶¡¦³¹]Áè½u¤À¹j¡CMFT_MENUBARBREAK ¤§­È¬° 20H¡C
  3. MFT_MENUBREAK¡G¦P¤W¡A¦ý¨S¦³¹]Áè½u¤À¹j¡CMFT_MENUBREAK ¤§­È¬° 40H¡C
  4. MFT_OWNERDRAW¡G¨ã¦³ MFT_OWNERDRAW ªº¿ï¶µ¡A¥²¶·¥ÑÀ³¥Îµ{¦¡¾á­t°_ø»s¦¹¿ï¶µªº³d¥ô¡C«Ø¥ß³oºØ¿ï¶µ®É¡AÀ³¥Îµ{¦¡·|¦¬¨ì WM_MEASUREITEM °T®§¡A¨C·í§ó·s¿ï¶µ¥~Æ[®É·|¦¬¨ì WM_DRAWITEM °T®§¡AÀ³¥Îµ{¦¡Âǵ۳o¨â«h°T®§Ã¸»s¿ï¶µ¡C«ü©w MFT_OWNERDRAW ®É¡AdwItemData ¥i¥H«ü©wÀ³¥Îµ{¦¡¦Û¦æ©w¸qªº¼Æ­È¡CÀ³¥Îµ{¦¡·|¦¬¨ìªº WM_MEASUREITEM¡BWM_DRAWITEM °T®§¤¤¡AlParam ¤À§O¬O MEASUREITEMSTRUCT¡BDRAWITEMSTRUCT µ²ºcÅé¦ì§}¡A¨ä¤¤ªº itemData ¤º¦sµÛ dwTypeData ¦Û¦æ©w¸qªº¼Æ­È¡CMFT_OWNERDRAW ¤§­È¬° 100H¡C
  5. MFT_RADIOCHECK¡G·í fState ¬° MFS_CHECKED¡A¦b fType ¨ã¦³ MFT_RADIOCHECK ªº¿ï¶µ«e¥H●ªí¥Ü¤Ä¿ïª¬ºA¡CMFT_RADIOCHECK ¤§­È¬° 200H¡C
  6. MFT_RIGHTJUSTIFY¡G±q¨ã¦³ MFT_RIGHTJUSTIFY ªº¿ï¶µ¶}©l¡A±Æ¦C¦b¥D¥\¯àªíªº¥kÃä¡CMFT_RIGHTJUSTIFY ¥u¯à¥Î©ó¥D¥\¯àªí¤¤ªº¿ï¶µ¡A¨ä­È¬° 4000H¡C
  7. MFT_RIGHTORDER¡Gªü©Ô§B»y¡B§Æ§B¨Ó»yª©¥»ªº Windows ¤~¯à¨Ï¥Î¡A¨Ï¿ï¶µ¦r¦ê¥Ñ¥k¦Ü¥ª¾\Ū¡C
  8. MFT_SEPARATOR¡G¦b¤l¥\¯àªí¡B§Ö±¶¥\¯àªí¤¤¡A¨ã¦³ MFT_SEPARATOR ®É¡AÅã¥Ü¤ô¥­¤À¹j½u¡CdwTypeData¡Bcch ·|³Q©¿²¤¡CMFT_SEPARATOR ¤§­È¬° 800H¡C
  9. MFT_STRING¡G¥Î¦r¦êªí¥Ü¿ï¶µ¡AdwTypeData ¬°¦r¦ê¦ì§}¡A¦¹¦r¦ê¶·¥H¹sµ²§À¡Ccch ¬°¦r¦êªø«×¡CMFT_STRING ¤§­È¬°¹s¡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
  1. MFS_CHECKED¡G¦¹¿ï¶µ¬°¤Ä¿ïªº¡A¨ä­È¬° 8¡C¥i¥H³]©w hbmpChecked ¬°¬Y¹Ï¤ùªº¦ì¤¸¹Ï¥N½X¡A©ÎªÌ³]©w hbmpChecked ¬°¹s¨Ï¥Î¹w³]¹Ï¤ù¡A¥HÅã¥Ü¦b¿ï¶µ¤å¦r«eªí¥Ü¤Ä¿ïª¬ºA¡C­Y­n³]©w hbmpChecked¡A¥²¶·§â fMask Äæ¦ì³]¬° MIIM_CHECKMARKS¡C
  2. MFS_DEFAULT¡G¦¹¿ï¶µ¬°¤º©wªº¿ï¶µ¡A¤@¥\¯àªí¤¤¥u¦³¤@­Ó¿ï¶µ¬O¤º©wªº¡A¥B¥H²ÊÅé¦rªí¥Ü¡CMFS_DEFAULT ¤§­È¬° 1000H¡C
  3. MFS_DISABLED¡G¦¹ª¬ºAªº¿ï¶µ¬O¸T¥Îªº¥B¥H¦Ç¦â¦rªí¥Ü¡AµLªk³Q¨Ï¥ÎªÌÂI¿ï¡A»P MFS_GRAYED ¦P¸q¡CMFS_DISABLED ¤§­È¬° 3¡C
  4. MFS_ENABLED¡G¦¹ª¬ºAªº¿ï¶µ¬O±Ò¥Îªº¡A¥i¥H³Q¨Ï¥ÎªÌÂI¿ï¡A¨ä­È¬° 0¡C
  5. MFS_GRAYED¡G»P MFS_DISABLED ¦P¸q¡AMFS_GRAYED ¬° 3¡C
  6. MFS_HILITE¡G¥H°ª«G«×Åã¥Ü¿ï¶µ¡A¨ä­È¬° 80H¡C
  7. MFS_UNCHECKED¡G¥¼¤Ä¿ïªº¿ï¶µ¡A¨ä­È¬° 0¡C¥i¥H³]©w hbmpUnchecked ¬°¬Y¹Ï¤ùªº¦ì¤¸¹Ï¥N½X¡A©ÎªÌ³]©w hbmpUnchecked ³]¬°¹s¤£¨Ï¥Î¥ô¦ó¹Ï¤ù¡A¥HÅã¥Ü¦b¿ï¶µ¤å¦r¤§«eªí¥Ü¥¼¤Ä¿ïª¬ºA¡C­Y­n³]©w hbmpUnchecked¡A¥²¶·§â fMask Äæ¦ì³]¬° MIIM_CHECKMARKS¡C
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­Ó¦ì¤¸¡A­Y¬°¤@ªí¥Ü­n¨M©w¤F¬Y­Óª«¥óªº©Ê½è¡A­Y¬°¹sªí¥Ü¨S¦³¦¹©Ê½è¡C

SetMenuItemInfo API

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 API

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¡F­Y¥¢±Ñ¡A¦^¶Ç­È¬°¹s¡C


¤£¨Ï¥Î¸ê·½´y­zÀɤ¤ªº MENU °Ï¶ô«Ø¥ß¥\¯àªí

¨Ò¤l¡GDRAW5.ASM

³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

¸Ñ»¡

¹ï winuser.inc ¤¤¤T­Ó±`¼Æ¤Î MENUITEMINFO ªº»¡©ú

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¥D­nª©¥»¡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

¦bµøµ¡¤¤¥[¤J¥\¯àªí

±µ¤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

¦b¥\¯àªí¤¤¥[¤J¶§¬Kªº¿ï¶µ

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¸¹¼Æ¡A­n³]©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ª¾¹D­n¦³¿ï¶µ¤å¦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 ©Ò¥H­n§â 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¤W­zªº¿ï¶µÁÙ¦³¥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²{¨Ï¥Î¤èªk­n¤T¨BÆJ¡F¦Ó¤W¤@ºØ¤èªk¶È¨â¨BÆJ¡C

²K¥[¼u¥X¿ï¶µ

¦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

²K¥[¨ã¦³✔¤Ä¿ïª¬ºA©Î●¤Ä¿ïª¬ºAªº¿ï¶µ

¦p¦ó²K¥[¨ã¦³✔¤Ä¿ïª¬ºAªº¿ï¶µ©O¡H¨ä¹ê¤£Ãø¡A¸ò«e­±³]©w¤£¨ã¤Ä¿ï¿ï¶µÃþ¦ü¡A¥u¬O¦h¤F­n±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

²K¥[¤À¹j½u

³Ì«á¤@ºØ¡A¦p¦ó³]©w¤À¹j½u©O¡H­º¥ý±N fMask Äæ¦ì³]¬° MIIM_FTYPE¡AµM«á¦A§â fType ³]¬° MFT_SEPARATOR¡C¨£²Ä 262¡ã265 ¦æ¡C

²K¥[¿ï¶µ«á©I¥s DrawMenuBar

DRAW5 ²K¥[¤F³\¦h¿ï¶µ¡A¤]Åܧó¤F¦³¨Ç¿ï¶µªºÄÝ©Ê¡A¨Ã¤£»Ý­n¨C¦¸Åܧó´N©I¥s DrawMenuBar¡Aµ¥³Ì«á¥þ³¡§¹¦¨¦A¤@¦¸©I¥s DrawMenuBar §Y¥i¡C


¾Ö¦³ªÌø»sªº¿ï¶µ¡]Owner-Drawn Menu Items¡^

¡u¾Ö¦³ªÌø»sªº¿ï¶µ¡v·N«ä¬O«ü¥ÑÀ³¥Îµ{¦¡³B²z¦³Ãö¿ï¶µªº´X¥G©Ò¦³¤u§@¡A¥]§tø»s¿ï¶µ¤å¦r©Î¬O­I´º¹Ï¤ù¡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

¦p¦ó«Ø¥ß¾Ö¦³ªÌø»sªº¿ï¶µ

¨ä¹ê¥u­n°Ñ¦Ò¤W­± InsertMenuItem ªº»¡©ú¡AÀ³¸Ó´N¯à°÷»s§@¥X¨Ó¡C¥D­n´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¿ï¶µ­×§ï¦¨§Ú­Ì·Q­nªº¼Ë¤l©O¡H­º¥ý­n­×§ï¿ï¶µ½d³òªº¤j¤p¡C

WM_MEASUREITEM °T®§

·í«Ø¥ß¾Ö¦³ªÌø»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

  1. CtlType¡G¥i¯à¬O¤Uªí¤¤ªº¨ä¤¤¤§¤@¡G
    CtlType¼Æ­È»¡©ú
    ODT_MENU1¾Ö¦³ªÌø»sªº¥\¯àªí
    ODT_LISTBOX2¾Ö¦³ªÌø»sªº²M³æ±±¨î¶µ
    ODT_COMBOBOX3¾Ö¦³ªÌø»sªº¤U©Ô¦¡¤è¶ô±±¨î¶µ
    ODT_BUTTON4¾Ö¦³ªÌø»sªº«ö¶s±±¨î¶µ
    ODT_STATIC5¾Ö¦³ªÌø»sªºÀRºA±±¨î¶µ
    ODT_TAB101¾Ö¦³ªÌø»sªº¼ÐÅÒ­¶±±¨î¶µ
    ODT_LISTVIEW102¾Ö¦³ªÌø»sªº²M³æÀ˵ø±±¨î¶µ
  2. CtlID¡G¹ï©ó¾Ö¦³ªÌø»sªº¥\¯àªí¦Ó¨¥¡A¤£¥Î¦¹Äæ¡F¹ï±±¨î¶µ¦Ó¨¥¡A¬°±±¨î¶µÃѧO½X¡C
  3. itemID¡G¥\¯àªí¿ï¶µªºÃѧO½X©Î²M³æ¡B¤U©Ô¦¡¤è¶ôµ¥±±¨î¶µªº¶µ¥Ø¦ì¸m¡C²M³æ±±¨î¶µ¨ã¦³ LBS_OWNERDRAWVARIABLE ®É¥H¤Î¤U©Ô¦¡¤è¶ô±±¨î¶µ¨ã¦³ CBS_OWNERDRAWVARIABLE ®É¡A¤~·|¨Ï¥Î¦¹Äæ¦ì©w¡C
  4. itemWidth¡G¥\¯àªí¤¤¿ï¶µªº¼e«×¡A¥H¹³¯À¬°³æ¦ì¡C¦bµ²§ô¦¹°T®§¤§«e¡A¥²¶·§â¥¿½T­È¦s¤J itemWidth Äæ¦ì¥H¨Ï¨t²Î³]©w¿ï¶µ¼e«×¡C
  5. itemHeight¡G¥\¯àªí¤¤¿ï¶µªº°ª«×©Î²M³æ¡B¤U©Ô¦¡¤è¶ô±±¨î¶µªº¶µ¥Ø°ª«×¡A¥H¹³¯À¬°³æ¦ì¡C¦bµ²§ô¦¹°T®§¤§«e¡A¥²¶·§â¥¿½T­È¦s¤J itemHeight Äæ¦ì¥H¨Ï¨t²Î³]©w¿ï¶µ©Î¶µ¥Ø°ª«×¡C
  6. itemData¡GÀ³¥Îµ{¦¡¦Û¦æ©w¸qªº¼Æ­È¡C

¨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

WM_DRAWITEM °T®§

·í¾Ö¦³ªÌø»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

  1. CtlType¡G¨£¤Wªí¡C
  2. CtlID¡G¹ï©ó¾Ö¦³ªÌø»sªº¥\¯àªí¦Ó¨¥¡A¤£¥Î¦¹Äæ¡F¹ï±±¨î¶µ¦Ó¨¥¡A¬°±±¨î¶µÃѧO½X¡C
  3. itemID¡G¥\¯àªí¿ï¶µªºÃѧO½X©Î²M³æ¡B¤U©Ô¦¡¤è¶ôµ¥±±¨î¶µªº¶µ¥Ø¦ì¸m¡C
  4. itemAction¡G¬O«ü¦b«ç¼Ëªº°Ê§@¤U»Ý­nø»s±±¨î¶µ©Î¿ï¶µ¡A¥i¯àªº±¡§Î¬O¤U­±¤TºØ±¡§Î¤§¤@¡A¤]¥i¯à¦hºØ±¡§Î¡G
    itemAction¼Æ­È»¡©ú
    ODA_DRAWENTIRE1±±¨î¶µ»Ý¾ã­Óø»s
    ODA_SELECT2¿ï¾Üª¬ºAµo¥Í§ïÅÜ
    ODA_FOCUS4±±¨î¶µÀò±o©Î¥¢¥h¿é¤JµJÂI
  5. itemState¡Gø»s§¹¦¨«á¶µ¥Øªºª¬ºA¡A¥i¯à¬O¤Uªí©Ò¦Cªº¼Æ­È©Î¨ä²Õ¦X¡G
    itemAction¼Æ­È»¡©ú
    ODS_SELECTED1¥\¯àªí¤¤ªº¶µ¥Ø¬O³Q¿ï¾Üªº
    ODS_GRAYED2¥\¯àªí¤¤ªº¶µ¥Ø¬OµL®Äªº
    ODS_DISABLED4¸T¥Îªº¶µ¥Ø
    ODS_CHECKED8¥\¯àªí¤¤ªº¶µ¥Ø¬O³Q¤Ä¿ïªº
    ODS_FOCUS10H¦¹¶µ¥Ø¨ã¦³Áä½L¿é¤JµJÂI
    ODS_DEFAULT20H¦¹¶µ¥Ø¬O¹w³]ªº
    ODS_HOTLIGHT40H¦¹¶µ¥Ø°ª«G«×Åã¥Ü¡A¥ç§Y·í·Æ¹«°±¯d¦b¦¹¶µ¥Ø®É³Q¬ðÅã¥X¨Ó
    ODS_INACTIVE80H¸Ó¥\¯àªí¶µ¥Ø³B©ó«D¬¡°Êª¬ºA¡A¨Ã¥B¨ã¦³¸Ó¥\¯àªíªºµøµ¡¤]³B©ó«D¬¡°Êª¬ºA
    ODS_NOACCEL100H¦³¨Ç±±¨î¶µ·|¦b¤å¦r¤Uµe¦³©³½u¥H´£¥Ü§Ö±¶Áä¡A¦b ODS_NOACCEL ª¬ºA¤U«h¤£´£¥Ü
    ODS_NOFOCUSRECT200H±±¨î¶µÀò±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_COMBOBOXEDIT1000Hø»s¤U©Ô¦¡¤è¶ô±±¨î¶µªº½s¿è®Ø
  6. hwndItem¡G¹ï¥\¯àªí¦Ó¨¥¡A¬°¨ã¦³¦¹¿ï¶µªº¥\¯àªí¥N½X¡F¹ï±±¨î¶µ¦Ó¨¥¡A¬°±±¨î¶µ¥N½X¡C
  7. hDC¡G¸Ë¸m¤º®e¥N½X¡A·íø»s¾Ö¦³ªÌø»sªº¥\¯àªí¿ï¶µ©Î±±¨î¶µ®É³£·|¥Î±oµÛ¡C
  8. rcItem¡G©w¸q¤F¦b hDC Äæ¦ì¤¤Ã¸»sªº½d³ò¡C¹ï±±¨î¶µ¦Ó¨¥¡A¨t²Î·|¦Û°Êµô°Å¶W¥Xªº³¡¤À¡F¹ï¥\¯àªí¦Ó¨¥¡A¨t²Î¤£·|¦Û°Êµô°Å¶W¥Xªº³¡¤À¡C
  9. itemData¡GÀ³¥Îµ{¦¡¦Û¦æ©w¸qªº¸ê®Æ¡C

WM_DRAWITEM ªð¦^®É¡A¥²¶·±N¦^¶Ç­È³]¬°¤@¡AÅý¨t²Îª¾¹D¤w³B²z§¹ WM_DRAWITEM °T®§¡C

GetSysColor API

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_3DDKSHADOW21¤TºûÅã¥Ü¤¸¯Àªº³±¼v³¡¤ÀªºÃC¦â
COLOR_BACKGROUND1®à­±ªºÃC¦â
COLOR_BTNFACE15¤TºûÅã¥Ü¤¸¯Àªí­±ªºÃC¦â©Î¹ï¸Ü®Ø­I´ºÃC¦â
COLOR_BTNTEXT18«ö¶s¤Wªº¤å¦rÃC¦â
COLOR_MENU4¥\¯àªí­I´º¦â
COLOR_MENUTEXT7¥\¯àªí¤å¦rªºÃC¦â
COLOR_WINDOWTEXT8µøµ¡¤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 API

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 API

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

  1. nHeight¡G¦r§Î°ª«×¡A¥HÅÞ¿è³æ¦ìªí¥Ü¡CÅÞ¿è³æ¦ì¡]logical units¡^»P¬M®g¼Ò¦¡¦³Ãö¡A¹w³]ªº¬M®g¼Ò¦¡¬O MM_TEXT¡A¦b³oºØ¬M®g¼Ò¦¡¤U¡AÅÞ¿è³æ¦ìµ¥©ó¹³¯À¡C¦pªG nHeight ¬° 0¡Aªí¥Ü¦r§Î°ª«×¬°¹w³]­È¡CnHeight ¥i¥H¬O¥¿­È©Î­t­È¡C°Ñ¦Ò¤W¹Ï¡A¦pªG nHeight ¬°¥¿­È¡A«h nHeight ´N¬O¹Ï¤¤ªº Height¡A¤£¥]§t ExternalLeading¡C¦pªG nHeight ¬°­t­È¡A¨Ï nHeight ¨úµ´¹ï­È¤§«á¡A¥u¥]§t Ascent »P Descent¡A¦Ó±Æ°£ InternalLeading¡C
  2. nWidth¡G¦r«¬ªº¥­§¡¼e«×¡A¥HÅÞ¿è³æ¦ìªí¥Ü¡C¦pªG nWidth ³]¬°¹s¡A«h¨t²Î·|¦Û°Ê¨Ï¥Î¯à»P nHeight ¤Ç°tªº³Ì±µªñ­È¡C¨Ï¥Î«D¹s­È¹ïÂI°}¦r¦æ¨Ã¤£·|°_¤Ó¤j§@¥Î¡A¦ý¹ï©ó TrueType ¦r§Î¡A¯à»´ÃP¦a¥Î¥¦¨ÓÀò±o¤ñ¥¿±`¦r¤¸§ó¼e©Î§ó¯¶ªº¦r§Î¡C
  3. nEscapement¡G¦r¤¸¶¡©Ò³s¦¨ªºª½½u»P¤ô¥­½u¤§¶¡ªº§¨¨¤¡A³æ¦ì¬O 0.1 «×¡C¥u¦³¦b¹Ï§Î¼Ò¦¡¬° GM_ADVANCED ¤~¦³®ÄªG¡F¦pªG¬O GM_COMPATIBLE ¼Ò¦¡¡A¨º»ò nEscapement ¥²¶·»P nOrientation ¤§­È¬Û¦P¡A­Y¤£¦P¥H nEscapement ¬°·Ç¡C
  4. nOrientation¡G¦r§Î°ò½u¡]BaseLine¡A¤W¹Ï¡^»P¤ô¥­½u¤§¶¡ªº§¨¨¤¡A³æ¦ì¬O 0.1 «×¡C¤Uªí¥H¹Ï§Î¼Ò¦¡¤À§O¬O GM_COMPATIBLE ©Î GM_ADVANCED¡A°²³] nEscapement¡BnOrientation ¤À§O¬° 0 «×©Î 30 «×®É¡A¦L¥X¡u®LÂÍ­¸³·¡A½ü°j¤£¹L¤@¿h¡C¡v¦r¦ê¡A¨Ó»¡©ú³o¨Ç¨¤«×¡G
    ¹Ï§Î¼Ò¦¡GM_COMPATIBLEGM_ADVANCED
    nEscapement03000300
    nOrientation30003000
    µ²ªG
    ²Ä¤@Äæ¬O GM_COMPATIBLE ¼Ò¦¡¡A©Ò¥H§Y¨Ï¬O nEscapement¡BnOrientation ¦U¬O 0¡B300¡A¨Æ¹ê¤W¥H nEscapement ¬°·Ç¡A©Ò¥H nEscapement¡BnOrientation §¡¬° 0¡A¤]´N¬O¤£Âà°Ê¡C¦P²z¡A²Ä¤GÄæ¨ä¹ê nEscapement¡BnOrientation §¡¬° 300¡A¦ý¦]¬°¬O GM_COMPATIBLE ¼Ò¦¡¡A¥u¦³ nOrientation ¦³§@¥Î¡A©Ò¥H¦r§Î°ò½u»P¤ô¥­½u§¨ 30 «×¨¤¡C²Ä¤TÄæ¬O GM_ADVANCED ¼Ò¦¡¡AnEscapement¡BnOrientation §¡¦³§@¥Î¡AnEscapement ¬O 0 ªí¥Ü¦r¤¸ªº³s½u¡]ºñ½u¡A¸û²³æªº¬Ýªk¬O§â¦r¤¸¥ª¤U¨¤³s°_¨Ó¡^»P¤ô¥­½u§¨¹s«×¨¤¡AnOrientation ¬O 30 «×ªí¥Ü¦r§Î°ò½u¡]¬õ½u¡^¤ô¥­½u§¨ 30 «×¨¤¡C²Ä¥|Äæ¡AnEscapement ¬O 300 ªí¥Ü¦r¤¸ªº³s½u¡]ºñ½u¡^»P¤ô¥­½u§¨ 30 «×¨¤¡AnOrientation ¬O 0 ªí¥Ü¦r§Î°ò½u¡]¬õ½u¡^¤ô¥­½u§¨¹s«×¨¤¡C³o¬qø»s¦r¦êªºµ{¦¡½X¦p¤U¡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
  5. fnWeight¡G¦r§Îªº²Ê²Ó¡A¥i¥H¬O 0¡B100¡B200¡B300¡K¡K900¡A¼Æ­È¶V¤j¦rÅé¶V²Ê¡C¤]¥i¥H¥Î¥H¤U±`¼Æ¥N´À¡GFW_THIN¡×100¡AFW_NORMAL¡×400¡AFW_BOLD¡×700¡AFW_BLACK¡×900¡C
  6. fdwItalic¡G¬O§_¬°±×Åé¡A1 ¥Nªí±×Åé¡A0 ¥¿±`¡C
  7. fdwUnderline¡G¬O§_¦³©³½u¡C1 ¥Nªí¦³©³½u¡A0 ¨S¦³©³½u¡C
  8. fdwStrikeOut ¡G¬O§_¦³§R°£½u¡A1 ¥Nªí¦³§R°£½u¡A0 ¥Nªí¨S¦³§R°£½u¡C§R°£½u¬O¦b¤å¦r¤¤¶¡ªº¾î½u¡C
  9. fdwCharSet¡G«ü©w¦r¤¸¶°¡A¦r¤¸¶°¥Î¨Ó½T©w¦r§Î©Ò¤ä´©ªº¦r¤¸½d³ò¡A¨ÏÀ³¥Îµ{¦¡©Ò«Ø¥ßªº¦r§Î¥i¥H¥¿½TÅã¥Ü¡C©³¤U¬O±`¥Î¥B¤w¸g¦b Windows ¨t²Î¤º¹w¥ý©w¸qªº¦r¤¸¶°¡G
    fdwCharSet¼Æ­È»¡©ú
    ANSI_CHARSET0¬ü°ê¤Î¦è¼Ú±`¨Ï¥Îªº¦r¤¸¶°
    DEFAULT_CHARSET1°õ¦æÀ³¥Îµ{¦¡ªº¹q¸£¤W¡A¨t²Î¤º©wªº¦r¤¸¶°
    SHIFTJIS_CHARSET128¤é¤å¦r¤¸¶°
    GB2312_CHARSET134²Å餤¤å¦r¤¸¶°
    CHINESEBIG5_CHARSET136¥¿Å餤¤å¦r¤¸¶°
    ¦pªGµLªk½T©w¥Î­þ¤@ºØ¦r¤¸¶°¡A´N¨Ï¥Î DEFAULT_CHARSET §a¡C³o¬O¨t²Î¤º©wªº¦r¤¸¶°¡A¤£·|¿ùªº¡C
  10. fdwOutputPrecision¡G«ü©w¦r§Î¿é¥Xªººë½T«×¡A¥¦«ü©w¤F¿é¥Xªº¦r§Î¥²¶·»P¥H¤U°Ñ¼Æ nHeight¡BnWidth¡BnEscapement¡BnOrientation¡B¶¡¶Z©M¦r«¬Ãþ«¬©Ò«ü©wªº¸ê®Æ¬Û¤Ç°tªºµ{«×¡A¤Uªí¬O±`¥Îªº fdwOutputPrecision¡G
    fdwOutputPrecision¼Æ­È»¡©ú
    OUT_CHARACTER_PRECIS2¤£¨Ï¥Î¿é¥Xºë½T«×
    OUT_DEFAULT_PRECIS0¨Ï¥Î¤º©wªº¿é¥Xºë½T«×
    OUT_DEVICE_PRECIS5¨Ï¥Î¸Ë¸m¦r§Î¿é¥Xºë½T«×¡A¸Ë¸m¦r§Î¬O¦b¨ä¥L©PÃä³]³Æ¤º«Øªº¦r§Î¡A¨Ò¦p¦³¨Ç¦Lªí¾÷´N¦³¤º«Ø¦r§Î
    OUT_OUTLINE_PRECIS8¨Ï¥Î TrueType ¦r§Î©M¨ä¥L´yÃä¦r§Î¿é¥Xºë½T«×
    OUT_PS_ONLY_PRECIS10¥u¦b PostScript ¦r§Î¤¤¿ï¾Ü¡C¦pªG¨t²Î¤¤¨S¦³¦w¸Ë PostScript ¦r§Î¡A«h¨Ï¥Î¤º©w­È
    OUT_RASTER_PRECIS6·í¨t²Î¥]§t¦h­Ó¬Û¦P¦WºÙªº¦r§Î®É¡A¿ï¾ÜÂI°}¦r§Î
    OUT_SCREEN_OUTLINE_
    PRECIS
    9¨Ï¥Î¿Ã¹õÅã¥Üªº´yÃä¦r§Îªº¿é¥Xºë«×¡A¦b¿Ã¹õ¤W¯à«OÃҳ̨ÎÅã¥Ü®ÄªG
    OUT_STRING_PRECIS1³o­Ó­È¤£¬O«ü©w¦r§Î¦ÓÅýÀ³µ{¦¡¨Ï¥Î¡A¦CÁ|ÂI°}¦r§Î
    OUT_STROKE_PRECIS3³o­Ó­È¤£¬O«ü©w¦r§Î¦ÓÅýÀ³µ{¦¡¨Ï¥Î¡A¦CÁ| TrueType ¦r§Î©Î¨ä¥L¦V¶q¦r§Î
    OUT_TT_ONLY_PRECIS7¥u¦b TrueType ¦r§Î¤¤¿ï¾Ü¡C¦pªG¨t²Î¤¤¨S¦³¦w¸Ë TrueType ¦r§Î¡A«h¨Ï¥Î¤º©w­È
    OUT_TT_PRECIS4·í¨t²Î¥]§t¦h­Ó¬Û¦P¦WºÙªº¦r§Î®É¡A¿ï¾Ü TrueType ¦r§Î
  11. fdwClipPrecision¡G«ü©wµô°Åºë½T«×¡A¥ç§Y¦p¦óµô°Å¶W¥Xµô°Å¯x§Îªº¦r¤¸¡A±`¥Îªº¤èªk¦p¤Uªí¡G
    fdwClipPrecision¼Æ­È»¡©ú
    CLIP_DEFAULT_PRECIS0¨Ï¥Î¤º©wµô°Åºë½T«×
    CLIP_CHARACTER_PRECIS1¤£¨Ï¥Îµô°Åºë½T«×
    CLIP_STROKE_PRECIS2³o­Ó­È¤£¬O«ü©w¦r§Î¦ÓÅýÀ³µ{¦¡¨Ï¥Î¡A¦Ó¬O¦CÁ|ÂI°}¡B¦V¶q©Î TrueType ¦r§Î
  12. fdwQuality¡G«ü©w¿é¥X«~½è¡A¥i¥H¬O¤Uªí¼Æ­Èªº¨ä¤¤¤@ºØ¡G
    fdwQuality¼Æ­È»¡©ú
    DEFAULT_QUALITY0¥H¨t²Î¹w³]­È³B²z¦r§Î¥~Æ[¡A¦Ó¤£¯S§O¥[±j³B²z
    DRAFT_QUALITY1¦r§Îªº«~½è¸û¤£­«­n
    PROOF_QUALITY2¦r§Îªº«~½è¡]¥­·Æ«×¡B²M´·«×¡^¤ñ¸û­«­n¡A§Y¨Ï¦r§Î¤j¤p¤£¯à»P©Ò«ü©wªº¤Ç°t
    NONANTIALIASED_QUALITY3¤£¶i¦æ¤Ï¿÷¾¦³B²z
    ANTIALIASED_QUALITY4¦r§Î¬°¥­·Æªº¡A¤]´N¬O¤Ï¿÷¾¦
    CLEARTYPE_QUALITY5¥H ClearType ¤è¦¡¤Ï¿÷¾¦
  13. fdwPitchAndFamily¡GfdwPitchAndFamily¤À¬°¨â³¡¤À¡G
    ¡@¡@①¡G0¡ã3¦ì¤¸¥Nªí¦r¤¸¶¡¶ZÂ÷¡A¨ä¹ê¬O¦r§Î¼e«×¥i¥H¬O¥H¤U¤TªÌ¤§¤@¡G
    ¡@¡@¡@¡@DEFAULT_PITCH¡G¤º©w¦r¶Z¡A¥i¯à¬O©T©w¼e«×©Î¥iÅܼe«×¡C¨ä­È¬° 0¡C
    ¡@¡@¡@¡@FIXED_PITCH¡G©T©w¼e«×¡A¨ä­È¬° 1¡C
    ¡@¡@¡@¡@VARIABLE_PITCH¡G¥iÅܼe«×¡A¨ä­È¬° 2¡C
    ¡@¡@②¡G4¡ã8¦ì¤¸«h´y­z¤F¦r§Î¥~Æ[©Î­·®æ¡A¥i¥H¬O¤U­±¼Æ­È¡]³o¨Ç¼Æ­È¥]§t¤F¸û§Cªº¥|­Ó¦ì¤¸¡^¡G
    ¡@¡@¡@¡@FF_DONTCARE¡G©¿²¤¦r§Î¥~Æ[©Î­·®æ¡A¨ä­È¬° 0¡C
    ¡@¡@¡@¡@FF_ROMAN¡Gù°¨¦r§Î¡A¨Ò¦p MS Serif¡C¨ä­È¬° 10H¡C
    ¡@¡@¡@¡@FF_SWISS¡G·ç¤h¦r§Î¡A¨Ò¦p MS Sans Serif¡C¨ä­È¬° 20H¡C
    ¡@¡@¡@¡@FF_MODERN¡G²{¥N¦r§Î¡A¨Ò¦p Pica¡BElite¡BCourier New¡C¨ä­È¬° 30H¡C
    ¡@¡@¡@¡@FF_SCRIPT¡G¤â¼g©Î¯ó¼g¦r§Î¡A¨Ò¦p Script¡BCursive¡A¨ä­È¬° 40H¡C
    ¡@¡@¡@¡@FF_DECORATIVE¡G¸Ë¹¢©Ê¦r«¬¡A¨Ò¦p Old English¡A¨ä­È¬° 50H¡C
    ¦b©I¥s CreateFont ®É¡AÀ³±N³o¨â³¡¤À¥H or ¹Bºâ¤l³s±µ¡A³o¼Ë²ÕĶ¾¹¯àºâ¥Xµ²ªG¡A¦¹µ²ªG¤~¬O fdwPitchAndFamily °Ñ¼Æ¡C
  14. lpszFace¡G¦r§Î¦WºÙªº¦ì§}¡A¦r§Î¦WºÙ¬O¥H¹s¬°µ²§Àªº¦r¦ê¡A¥B¦¹¦r¦êªø«×¥]§tµ²§Àªº¹s¤£¯à¶W¹L 32 ­Ó¦r¤¸¡C¦pªG lpszFace ¬°¹s©Î©Ò«üªº¦ì§}¬°ªÅ¦r¦ê¡A¨º»ò GDI ±N¨Ï¥Î²Å¦X¨ä¥L«ü©wÄݩʪº²Ä¤@­Ó¦r§Î¡C

CreateFont ªº°Ñ¼Æ«Ü¦h¡A¦@¤Q¥|­Ó¡A³£¬O´y­zÅÞ¿è¦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¿ï¶µªº¨Ò¤l

¸ÑÄÀ§¹»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¡C­I´º¹Ï¬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.ASM¡BONDMENU.RC ¤Î¨ä¥L¹Ï®×ÀÉ

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¸ê·½´y­zÀɤ¤ªº¹Ï¥Ü¦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¼Ë·|¤ñ¤W­z¤èª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

³B²z WM_MEASUREITEM °T®§

«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­«·s­pºâ¿ï¶µªº¼e«×»P°ª«×¡A´N·|¦h­pºâ¦n´X¦¸¦Ó¨Ï®Ä²vÅܧC¡]¹ê»Ú¤W¥H²{¤µ CPU ªº®Ä²v¡A³o¤@ÂI©µ¿ð¤HÃþ¬O·Pı¤£¥X¨Óªº¡^¡C°²¦p§â³o­pºâ¥æ¥Ñ³B²z WM_CREATE °T®§®É´N­pºâ¦n¡A¨º¥u­nºâ¤@¦¸§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¥u­nÀˬ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 (?)

©Ò¥H­n¦s¨ú hBmp °}¦Cªº¦ì¤¸¹Ï¥N½X¥i¥H¥Î hBmp[8¡Ñm]¡Am ¬O²Ä´X­Ó¤¸¯À¡Am ¥Ñ 0 ¨ì 5¡C­Y m ¬° 4¡A­pºâµ²ªG¬° hBmp[32]¡A´N¬O¬ü¤k¹Ï¥N½X¡C

²Ä¤G­Ó­È±o¤@´£ªº¬O ASSUME »P PTR °²«ü¥O¡C

PTR ¹Bºâ¤l

¦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 °²«ü¥O

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«e­z¼È¦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ªG­n¦s¨ú¸Óµ²ºcÅ餺ªºÄæ¦ì¡A¥u­n¦A¥[¤W¸ÓÄæ¦ìªº°¾²¾¦ì§}§Y¥i¡C¨Ò¦p­n§â 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

³B²z WM_DRAWITEM °T®§

·í­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¤å¦r­I´º¼Ò¦¡³]¬°³z©ú¡Cø»s¨â­Ó¤l¥\¯àªí³£¥²¶·§â¤å¦r­I´º¼Ò¦¡³]¬° TRANSPARENT¡C¥i¥H©I¥s SetBkMode §â­I´º¼Ò¦¡³]¬° TRANSPARENT¡A³o¼Ë¤å¦rªº­I´ºÅܦ¨³z©ú¡A¤~¯àÅã²{¥X­I´º¹Ï¨Ó¡C¦pªG¤£³]¦¨³z©ú¡A·|Åܦ¨¤U¹Ïªº¼Ë¤l¡C¦]¬°·Æ¹«´å¼ÐÄa°±ªº¿ï¶µ¡]§Y³Q¿ï¾Üªº¿ï¶µ¡^¤å¦r»P­I´º¦P¦â¡A©Ò¥H®Ú¥»¬Ý¤£¥X¨Ó¿ï¶µ¤å¦r¡C

⑵¡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¬ü¤k­I´º¹Ï¡C³o®É¶·©I¥s BitBlt¡A¦]¦¹©I¥s CreateCompatibleDC «Ø¥ß°O¾ÐÅé¸Ë¸m¤º®e¡C

⑶¡B³]©w¤å¦rÃC¦â¡C¦bø»sÀɮפl¥\¯àªí»P¦r§Î¤l¥\¯àªíªº®É­Ô¡A³Q¿ï¾Üªº¤å¦rÃC¦â§¡¬°¥Õ¦â¡A¥¼³Q¿ï¾Üªº¤å¦rÃC¦â§¡¨Ï¥Î¹w³]ªºÃC¦â¡Cµ{¦¡¦p¤U¡G
      ;³]©w¿ï¶µ¤å¦rÃC¦â¡A¿ï¾Üªº¥Î¥Õ¦â¡A¥¼¿ï¾Üªº¥Î¹w³]ªº¿ï¶µ¤å¦rÃC¦â
        mov     edx,clrMenuText
        test    dis.itemState,ODS_SELECTED
        jz      @f
        mov     edx,0ffffffh
¹w³]ªº¿ï¶µ¤å¦rÃC¦â¡A¥i¥H¥Î COLOR_MENUTEXT ¬°°Ñ¼Æ¡A©I¥s GetSysColor¡A¦A±N©ÒÀò±oªºÃC¦â¦s©ó clrMenuText¡C

³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

⑴¡Bø»sÀɮפl¥\¯àªí¤ºªº¿ï¶µªº¨BÆJ¬O⒜ø»s¬õ¦â¥ú´Î©Î­I´º¦â¡B⒝ø»s¿ï¶µ¤å¦r¡B⒞ø»s¿ï¶µ¤å¦r«eªº¦ì¤¸¹Ï¡Cª`·N¡I²Ä⒜¶µ¤u§@¤@©w­n³Ì¥ýø»s¡A¦Ó⒝¡B⒞¨â¶µ½Ö¥ý½Ö«á«hµLÃöºò­n¡C¦pªG²Ä⒜¶µ¤ñ⒝¡B⒞«áø»s¡A¨º»ò¬õ¦â¥ú´Î©Î­I´º¦â´N·|Âл\±¼¿ï¶µ¤å¦r¤Î¦ì¤¸¹Ï¡A¿ï¶µùؤ°»ò³£¨S¦³¡A§Y¨ÏÁÙ¬O¥i¥H¥¿±`¾Þ§@¡C

¥ý»¡©ú⒜¤¤ªº¬õ¦â¥ú´Î©M­I´º¦â¦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¨º»ò±N­nø»s²Ä¹s­Ó¿ï¶µ®É rcItem ¥ª¤W¨¤®y¼Ð¬O ( 0,0 )¡A±N­nø»s²Ä¤@­Ó¿ï¶µ®É rcItem ¥ª¤W¨¤®y¼Ð¬O ( 0,20 )¡K¡K¨Ì¦¹Ãþ±À¡C

°ò©ó¤W­z­ì¦]¡A¦pªG­n§â¿ï¶µ¤å¦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ø»s¦r§Î¤l¥\¯àªí¤ºªº¿ï¶µ®Éªº¨BÆJ¬O⒜ø»s­I´ºªº¬ü¤k¹Ï¡B⒝«Ø¥ßÅÞ¿è¦r§Î¡B⒞¥HÅÞ¿è¦r§Îø»s¿ï¶µ¤å¦r¡B⒟ø»s¥Nªí¤Ä¿ïªº¥¿¤è§Î¡C»P⑴ªº¹D²z¬Û¦P¡A¥²¶·¥ýø»s⒜ªº¬ü¤k¹Ï¡A­Y«áø»s¬ü¤k¹Ï¨º»ò¥ýµe¥X¨ÓªºªF¦è³£·|³Q­I´º¬ü¤k¹Ï»\¹L¡C

⒜¡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¦]¦¹¥u­n¯àª¾¹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¬O­pºâ¥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 ¨¯¨¯­W­W­pºâ±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


µù¸Ñ

µù¤@¡GMENUITEMINFO µ²º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.incWinInc 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¥D­n¬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¨Ò¦p­n¦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¬O­n¨Ï 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¡^

µù¤G¡GALIGN °²«ü¥O

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

  1. ALIGN 2¡G¤U­Ó«ü¥O©Î¸ê®Æ¡A¦s©ñ©óªº¦ì§}¥²¶·¯à³Q 2 ¾ã°£¡A¥iµø¬°¦r²ÕÃä¬É¡C
  2. ALIGN 4¡G¤U­Ó«ü¥O©Î¸ê®Æ¡A¦s©ñ©óªº¦ì§}¥²¶·¯à³Q 4 ¾ã°£¡A¥iµø¬°Âù¦r²ÕÃä¬É¡C
  3. ALIGN 8¡G¤U­Ó«ü¥O©Î¸ê®Æ¡A¦s©ñ©óªº¦ì§}¥²¶·¯à³Q 8 ¾ã°£¡A¥iµø¬°¥|¦r²ÕÃä¬É¡C
  4. ALIGN 16¡G¤U­Ó«ü¥O©Î¸ê®Æ¡A¦s©ñ©óªº¦ì§}¥²¶·¯à³Q 16 ¾ã°£¡A¥iµø¬°¸`Ãä¬É¡C