²Ä¤G¤Q¤G³¹¡@¹ï¸Ü²°¤¶­±ªºµ{¦¡

¦b¤W¤@³¹¤¶²Ð¤F±j¨î¦^À³¹ï¸Ü²°¡]¤]ºÙ¬°¼Ò¦¡¹ï¸Ü²°¡^¡A¤]¤¶²Ð¤F½d¨Ò¡AMODAL1.ASM¡A¥¦¥ý«Ø¥ß¤F¤@¯ëµøµ¡¡A«ö¤U¥[³tÁ䤧«á¤~¼u¥X±j¨î¦^À³¹ï¸Ü²°¡C¦ý³o¤@³¹±N¤¶²Ð§ó²³æªº¤èªk¡A¤p¤ì°¸ºÙ¤§¬°¡u¥H¹ï¸Ü²°¬°¥D­n¤¶­±ªºÀ³¥Îµ{¦¡¡v¡C

³o¤@³¹¡A¤p¤ì°¸¥´ºâ¤¶²Ð¥¦¡A°£¦¹¤§¥~·|¥ý¤¶²Ð¼Ð·Ç±±¨î¶µªº³Ì«á¤@­Ó¡A±²°Ê¶b±±¨î¶µ¡C³Ì«á¥H¤@­Ó§t¦³±²°Ê¶b±±¨î¶µ¹ï¸Ü²°§@¬°¥»³¹½d¨Ò¡A³o­Ó½d¨Òµ{¦¡¦³¤T­Ó¾î¦V±²°Ê¶b±±¨î¶µ¡A±±¨îµÛ¤T­ì¦â¬õºñÂÅÃC¦âªº±j«×¡A¨Ï¥ÎªÌ²¾°Ê±²¶b¤Wªº±²°Ê¤è¶ô¦ì¸m¥i¥H½Õ¾ã¦U¦â±j®z¡A¨Ã¥B¦b¥t¤@­ÓÀRºA±±¨î¶µÅã²{¥Xµ²ªG¡C


±²°Ê¶b±±¨î¶µ¡]Scroll-bar Control¡^

§Ú­Ì¦b²Ä¤E¡B¤Q³¹»¡©ú¹L±²°Ê¶b¡A»P¦b³o¨à¤¶²Ðªº±²°Ê¶b±±¨î¶µ¤£¤Ó¤@¼Ë¡AÁöµM¥L­Ìªº¦æ¬°«Ü¬Û¦ü¦ýÁÙ¬O¦³¤£¦Pªº¦a¤è¡C¬°¤F°Ï¤À¡A¤p¤ì°¸ºÙ©I«eªÌ¬°¡u¼Ð·Ç±²°Ê¶b¡v¡AºÙ©I¥»³¹ªº¥D¨¤¬°¡u±²°Ê¶b±±¨î¶µ¡v¡C©³¤U¨Ó¬Ý¬Ý¥¦­Ì¤§¶¡¤£¦Pªº¦a¤è¡C

¥ý¨Ó»¡»¡¼Ð·Ç±²°Ê¶b¡C¥¦¥²µM¦ì©óµøµ¡¤u§@°Ïªº¥k¤è»P¤U¤è¡AµLªk¨ì²¾¨ì§O³B¡FÁöµM¥¦¤£ÄÝ©ó¤u§@°Ïªº¤@³¡¥÷¡A¦ý«oÄÝ©óµøµ¡ªº¤@³¡¤À¡C©Ò¥H¡A¼Ð·Ç±²°Ê¶b¤£¬Oµøµ¡¡A¨S¦³µøµ¡¥N½X¡A¤]¨S¦³ÃѧO½X¡C¦A¨Ó¬Ý¬Ý±²°Ê¶b±±¨î¶µ¡C¥¦¥i¥H¦ì©ó¤u§@°Ïªº¥ô¦ó¦a¤è¡A¤]¥i¥H³]©w¦¨¥ô·N¤Ø¤o¡A¤]¥i¥H§ïÅܤؤo¡C¥¦¬Oµøµ¡ªº¤lµøµ¡¡A©Ò¥H¤]¬O¤@ºØµøµ¡¡A¨ã¦³µøµ¡¥N½X»PÃѧO½X¡C

¼Ð·Ç±²°Ê¶b»P±²°Ê¶b±±¨î¶µ¤£¤@¼Ëªº¦a¤è¡A°£¤F¤W­±´y­zªº¥H¥~¡AÁÙ¦³¤@¨Ç¡A¦ý¸û¬°º¾¸H¡Aµ¥µy«á¤¶²Ð±²°Ê¶b±±¨î¶µ®É·|¹J¨ì¡A¨º®É­Ô¦A»¡¡C©³¤U¥¿¦¡¤¶²Ð±²°Ê¶b±±¨î¶µ¡C

±²°Ê¶b±±¨î¶µªºµøµ¡Ãþ§O¬O¡uSCROLLBAR¡v¡A¥Ñ¥~Æ[¨Ó¬Ý¡A±²°Ê¶b±±¨î¶µ¤À¦¨¤TºØ¡G¤ô¥­¡B¹]Áè¤è¦V»P¤Ø¤o¤è¶ô¡C«Ø¥ß¤ô¥­ªº±²°Ê¶b±±¨î¶µ¡A»Ý«ü©w SBS_HORZ ­·®æ¡F«Ø¥ß¹]Á誺±²°Ê¶b±±¨î¶µ¡A»Ý«ü©w SBS_VERT ­·®æ¡F«Ø¥ß¤Ø¤o¤è¶ô¡A»Ý«ü©w SBS_SIZEBOX ©Î SBS_SIZEGRIP ­·®æ¡C¥k¹ÏÅã¥Ü«e¨âºØ±²°Ê¶b±±¨î¶µ¡A¥H¤Î¦U³¡¦WºÙ¡C«Ø¥ß±²°Ê¶b±±¨î¶µªº¤èªk¸ò¨ä¥L±±¨î¶µ¤@¼Ë¡A¦³¨âºØ¤èªk¡G①©I¥s CreateWindowEx¡B②¦b¹ï¸Ü²°­±ªO©w¸q±²°Ê¶b±±¨î¶µ¡A¦A©I¥s DialogBoxParam¡C

①¡B©I¥s CreateWindowEx ®É¡Aµøµ¡Ãþ§O«ü©w¡u"SCROLLBAR",0¡v¦r¦ê¡A¨Ã¥B¨Ì¾Ú­n«Ø¥ß¤ô¥­©Î¬O¹]Áè¤è¦Vªº±²°Ê¶b±±¨î¶µ¡A¨Ï¥Î SBS_HORZ ©Î SBS_VERT ­·®æ¡A¥B¤£­n§Ñ¤FÁÙ­n«ü©w¡uWS_CHILD or WS_VISIBLE¡v­·®æ¤~¯à±N¦¹µøµ¡³]¬°¤lµøµ¡¨ÃÅã²{±±¨î¶µ¡C¨Ò¦p©³¤Uªº¨Ò¤l¬O«Ø¥ß¤ô¥­¤è¦Vªº±²¶b±±¨î¶µ¡G

szSbClass       DB      "SCROLLBAR"
  ⁝
invoke  CreateWindowEx,0,OFFSET szSbClass,0,WS_CHILD or WS_VISIBLE or SBS_HORZ,\
        x,y,width,height,hwndParent,IDSB_HORZ,hInstance,0

②¡B¦b¹ï¸Ü²°­±ªO©w¸q±²°Ê¶b±±¨î¶µ¡A¦A©I¥s DialogBoxParam¡CÁÙ¬O¥H¤ô¥­±²°Ê¶b¬°¨Ò¡A¦b¹ï¸Ü²°±±¨î­±ªO¤¤©w¸q¥i¥H¬O¤U­±¨âªÌ¤¤ªº¤@ºØ¡G

SCROLLBAR  IDSB_HORZ,x,y,aidth,heigth

©Î

CONTROL "",IDSB_HORZ,"SCROLLBAR",WS_CHILD|WS_VISIBLE|SBS_HORZN,x,y,width,heigth

µM«á©I¥s DialogBoxParam §Y¥i¡C

«Ø¥ß¦n±²°Ê¶b±±¨î¶µ¤§«á¡AÁÙ¥²¶·³]©w±²°Ê¤è¶ôªº¦ì¸m½d³ò¡C¤@¯ë¬O¦b³B²z WM_CREATE ©Î WM_INITDIALOG °T®§®É¡A©I¥s SetScrollRange¡A¥i°Ñ¾\²Ä¤E³¹¡C¦ý§Y¨Ï°µ¨ì³o¼Ëªº¦a¨B¡AÁÙµLªk¨Ï±²°Ê¶b±±¨î¶µ¥¿±`¹B§@¡A·í¨Ï¥ÎªÌ©ì¦²±²°Ê¤è¶ô©Î«ö¤U±²°Ê½bÀY¡A¦pªG¤£©I¥s SetScrollPos¡A±²°Ê¤è¶ô¤´·|¦^¨ì­ì³B¡C

±²°Ê¶b±±¨î¶µªº­·®æ

±²°Ê¶b±±¨î¶µ¥i¥H¨Ï¥Îªº­·®æ¦³¤U­±¤QºØ¡G

±²°Ê¶b±±¨î¶µªº­·®æ¼Æ­È»¡©ú
SBS_HORZ0«Ø¥ß¤ô¥­±²°Ê¶b±±¨î¶µ¡C¦pªG¤£¨ã SBS_BOTTOMALIGN¡B¤]¤£¨ã SBS_TOPALIGN ­·®æ¡A«h±²°Ê¶b±±¨î¶µªº°ª«×¡B¼e«×©M¦ì¸m¥Ñ CreateWindowEx ©Î¹ï¸Ü²°­±ªOªº x¡By¡Bwidth¡Bheight ¨M©w¡C
SBS_VERT1«Ø¥ß¹]Áè±²°Ê¶b±±¨î¶µ¡C¦pªG¤£¨ã SBS_RIGHTALIGN¡B¤]¤£¨ã SBS_LEFTALIGN ­·®æ¡A«h±²°Ê¶b±±¨î¶µªº°ª«×¡B¼e«×©M¦ì¸m¥Ñ CreateWindowEx ©Î¹ï¸Ü²°­±ªOªº x¡By¡Bwidth¡Bheight ¨M©w¡C
SBS_TOPALIGN2±²°Ê¶b±±¨î¶µªº°ª«×¬°¨t²Î¹w³]ªº°ª«×¡A¥B¤W½t»P CreateWindowEx ©Î¹ï¸Ü²°­±ªO¤¤¡Ax¡By¡Bwidth¡Bheight ©Ò©w¸qªº¯x§Î¤W½t¹ï»ô¡C¦¹­·®æ¥²¶·»P SBS_HORZ ·f°t¨Ï¥Î¡C
SBS_LEFTALIGN2±²°Ê¶b±±¨î¶µªº¼e«×¬°¨t²Î¹w³]ªº¼e«×¡A¥B¥ª½t»P CreateWindowEx ©Î¹ï¸Ü²°­±ªO¤¤¡Ax¡By¡Bwidth¡Bheight ©Ò©w¸qªº¯x§Î¥ª½t¹ï»ô¡C¦¹­·®æ¥²¶·»P SBS_VERT ·f°t¨Ï¥Î¡C
SBS_SIZEBOXTOPLEFTALIGN2¨Ï¨ã¦³ SBS_SIZEBOXBOTTOMRIGHTALIGN ©Î SBS_SIZEBOXTOPLEFTALIGN ­·®æªº±²°Ê¶b±±¨î¶µ¤º¡A¨ä¤Ø¤o¤è¶ô¦b±²°Ê¶b±±¨î¶µªº¥ª¤W¨¤¡C
SBS_BOTTOMALIGN4±²°Ê¶b±±¨î¶µªº°ª«×¬°¨t²Î¹w³]ªº°ª«×¡A¥B¤U½t»P CreateWindowEx ©Î¹ï¸Ü²°­±ªO¤¤¡Ax¡By¡Bwidth¡Bheight ©Ò©w¸qªº¯x§Î¤U½t¹ï»ô¡C¦¹­·®æ¥²¶·»P SBS_HORZ ·f°t¨Ï¥Î¡C
SBS_RIGHTALIGN4±²°Ê¶b±±¨î¶µªº¼e«×¬°¨t²Î¹w³]ªº¼e«×¡A¥B¥k½t»P CreateWindowEx ©Î¹ï¸Ü²°­±ªO¤¤¡Ax¡By¡Bwidth¡Bheight ©Ò©w¸qªº¯x§Î¥k½t¹ï»ô¡C¦¹­·®æ¥²¶·»P SBS_VERT ·f°t¨Ï¥Î¡C
SBS_SIZEBOXBOTTOMRIGHTALIGN4¨Ï¨ã¦³ SBS_SIZEBOXBOTTOMRIGHTALIGN ©Î SBS_SIZEBOXTOPLEFTALIGN ­·®æªº±²°Ê¶b±±¨î¶µ¤º¡A¨ä¤Ø¤o¤è¶ô¦b±²°Ê¶b±±¨î¶µªº¥k¤U¨¤¡C
SBS_SIZEBOX8¦b CreateWindowEx ©Î¹ï¸Ü²°­±ªO¤¤¡Ax¡By¡Bwidth¡Bheight ©Ò©w¸qªº¯x§Î¥k¤U¨¤¡A«Ø¥ß¥i½Õ¾ã¹ï¸Ü²°¤j¤pªº¤Ø¤o¤è¶ô¡C
SBS_SIZEGRIP10H¦b CreateWindowEx ©Î¹ï¸Ü²°­±ªO¤¤¡Ax¡By¡Bwidth¡Bheight ©Ò©w¸qªº¯x§Î¥k¤U¨¤¡A«Ø¥ß¥i½Õ¾ã±²°Ê¶b±±¨î¶µ¤j¤pªº¤Ø¤o¤è¶ô¡C

¦pªG«Ø¥ß±²°Ê¶b±±¨î¶µ®É¡A«ü©w SBS_SIZEBOX ©ÎªÌ SBS_SIZEGRIP ­·®æ¡A¨º»ò¥Í¦¨ªºµ²ªG¸ò·Q¹³¤¤ªº±²°Ê¶b±±¨î¶µ¤@ÂI¤]¤£¹³¡C¤U­±¹ï¸Ü²°­±ªO¥Í¦¨ªº±²°Ê¶b±±¨î¶µ³£¨S¦³±²°Ê½bÀY¡B±²°Ê­y¹D¡B±²°Ê¤è¶ôµ¥³¡¤À¡A¥u¦³¦b CreateWindowEx ©Î¹ï¸Ü²°­±ªO¤¤¡Ax¡By¡Bwidth¡Bheight ©Ò©w¸qªº¯x§Î¥k¤U¨¤¦³¤@ºÙ¬°¤Ø¤o¤è¶ôªº³¡¤À¡A¦p¥k¹Ï¡C·í¨Ï¥ÎªÌ§â·Æ¹«´å¼Ð²¾¤J±²°Ê¶b±±¨î¶µ½d³ò¤º«ö¦í¤£©ñ¡AµM«á²¾°Ê·Æ¹«®É¡ASBS_SIZEBOX ­·®æ·|§ïÅܹï¸Ü²°¤Ø¤o¡ASBS_SIZEGRIP ·|§ïÅܱ±¨î¶µ¤Ø¤o¡C

TSTSB   DIALOGEX    200,100,110,112
FONT    10,"MS Shell Dlg"
CAPTION "±²°Ê¶b±±¨î¶µªº­·®æ"
{
  LTEXT   "SBS_SIZEBOX",1,  4, 5,60,8
  CONTROL "",IDSB_RED, "SCROLLBAR",SBS_SIZEBOX|WS_BORDER, 4,15,100,30
  LTEXT   "SBS_SIZEGRIP",2, 4,51,60,8
  CONTROL "",IDSB_GRN, "SCROLLBAR",SBS_SIZEGRIP|WS_BORDER,4,61,100,30
  DEFPUSHBUTTON "Â÷¶}",IDB_EXIT, 60,95, 46,14
}

¹Ï¤¤¹ï¹ï¸Ü²°­I´º¸g¹L¬V¦â¦¨¸û²`ªºÃC¦â¡A¦P®É¨ã¦³ WS_BORDER ­·®æ¡A³o¼Ë´N¯à°÷¬Ý¥X±²°Ê¶b±±¨î¶µªº½d³ò¡C¦pªG¨ã¦³ SBS_SIZEBOX ©ÎªÌ SBS_SIZEGRIP ­·®æªº±²°Ê¶b±±¨î¶µ¡A¦P®É¤]¦³ SBS_SIZEBOXBOTTOMRIGHTALIGN ­·®æ¡A¨º»ò¤Ø¤o¤è¶ô·|¦ì©ó¥k¤U¨¤¡A³o¬O¹w³]­È¡F¦pªG«ü©w¤F SBS_SIZEBOXTOPLEFTALIGN¡A¨º»ò¤Ø¦T¤è¶ô·|¦b¥ª¤W¨¤¡C¦pªG¨ã¦³³o¨â­Ó­·®æ¤¤ªº¨ä¤¤¤@­Ó¡A¨º»ò¥u¦³¨Ï¥ÎªÌ§â·Æ¹«´å¼Ð²¾¦Ü¤Ø¤o¤è¶ô¤W¡A¤~¯à§ïÅܱ±¨î¶µ©Î¹ï¸Ü²°ªº¤j¤p¡C

¶Ç»¼°T®§µ¹±²°Ê¶b±±¨î¶µ

À³¥Îµ{¦¡©I¥s SendMessage¡A¥i¥H±N¥H¤Uªº±²°Ê¶b±±¨î¶µ°T®§µo°eµ¹±²°Ê¶b±±¨î¶µ¡A¨Ï¨ä°µ¥X¬ÛÃö¦^À³¡G

①¡BSBM_ENABLE_ARROWS¡Gµo°e¦¹°T®§µ¹±²°Ê¶b±±¨î¶µ¡A¯à±Ò¥Î©Î¸T¥Î±²°Ê½bÀY¡C¦Ü©ó­n¸T¥Î©Î±Ò¥Î­þ­Ó±²°Ê½bÀY¡A¥Ñ wParam ¨M©w¡A¨£¤Uªí¡ClParam ¤£¨Ï¥Î¡AÀ³³]¬°¹s¡C¦pªG SendMessage ¦¨¥\°õ¦æ SBM_ENABLE_ARROWS¡A¦^¶Ç­È¬° 1¡F§_«h¬° 0¡C
±`¼Æ»¡©ú
ESB_DISABLE_BOTH¸T¥Î¨â­Ó±²°Ê½bÀY
ESB_DISABLE_DOWN¸T¥Î¦V¤U±²°Ê½bÀY
ESB_DISABLE_LTUP¸T¥Î¦V¥ª©Î¦V¤W±²°Ê½bÀY
ESB_DISABLE_LEFT¸T¥Î¦V¥ª±²°Ê½bÀY
ESB_DISABLE_RTDN¸T¥Î¦V¥k©Î¦V¤U±²°Ê½bÀY
ESB_DISABLE_UP¸T¥Î¦V¤W±²°Ê½bÀY
ESB_ENABLE_BOTH±Ò¥Î¨â­Ó±²°Ê½bÀY
②¡BSBM_GETPOS¡Gµo°e¦¹°T®§µ¹±²°Ê¶b±±¨î¶µ¡A¯à¨ú±o±²°Ê¤è¶ô¦ì¸m¡CwParam¡BlParam §¡¤£¨Ï¥Î¡A³£³]¬°¹s¡C¦^¶Ç­È¬°±²°Ê¤è¶ô·í«e¦ì¸m¡C
③¡BSBM_GETRANGE¡Gµo°e¦¹°T®§µ¹±²°Ê¶b±±¨î¶µ¡A¯à¨ú±o±²°Ê¤è¶ô¦ì¸m½d³ò¡CwParam¡BlParam §¡¬°¬Y­ÓÂù¦r²ÕÅܼƦì§}¡A°õ¦æ SendMessage ¤§«á¡A±²°Ê¤è¶ô¦ì¸mªº³Ì¤p­È»P³Ì¤j­È·|¤À§O¦s¤J³o¨â­ÓÅܼƤ¤¡C
④¡BSBM_GETSCROLLBARINFO¡Gµo°e¦¹°T®§µ¹±²°Ê¶b±±¨î¶µªº¸ê®Æ¡CwParam ¤£¨Ï¥Î¡AÀ³³]¬°¹s¡FlParam ¬° SCROLLBARINFO µ²ºcÅ骺¦ì§}¡C¦¹µ²ºcÅé¦UÄæ¦ì·N¸q¦p¤U¡G
CCHILDREN_SCROLLBAR     EQU     5
SCROLLBARINFO   STRUCT 
cbSize          DWORD   ?
rcScrollBar     RECT	<>
dxyLineButton   DWORD   ?
xyThumbTop      DWORD   ?
xyThumbBottom   DWORD   ?
reserved        DWORD   ?
rgstate         DWORD   CCHILDREN_SCROLLBAR+1 dup (?)
SCROLLBARINFO   ENDS
SCROLLBARINFO µ²ºcÅé¥i¥H¥Î©ó SBM_GETSCROLLBARINFO¡A¤]¥i¥Î©ó GetScrollBarInfo API¡A¦Ó«áªÌ¤]¯à¨ú±o¼Ð·Ç±²°Ê¶bªº¸ê®Æ¡A¦]¦¹©³¤UªºÄæ¦ì»¡©ú¡A¥H±²°Ê¶b¥N´À±²°Ê¶b±±¨î¶µ©Î¼Ð·Ç±²°Ê¶b¡C
⑴¡BcbSize¡GSCROLLBARINFO µ²ºcÅ骺ªø«×¡A¥H¦ì¤¸²Õ¬°³æ¦ì¡A¥²¶·¦b©I¥s SendMessage ¤§«e³]¦n¦¹Äæ¦ì¡C
⑵¡BrcScrollBar¡G±²°Ê¶b©Ò¦bªº¯x§Î°Ï°ì¡A¥H¿Ã¹õ®y¼Ð¡]¹³¯À¡^ªí¥Ü¡C
⑶¡BdxyLineButton¡G±²°Ê¤è¶ôªº¼e«×¡]¤ô¥­±²°Ê¶b¡^©Î°ª«×¡]««ª½±²°Ê¶b¡^¡A³æ¦ì¬O¹³¯À¡C
⑷¡BxyThumbTop¡G±²°Ê¤è¶ô¥ª½t¡]¤ô¥­±²°Ê¶b¡^©Î¤W½t¡]««ª½±²°Ê¶b¡^¶ZÂ÷±²°Ê¶b¥ª½t©Î¤W½t¦h¤Ö¹³¯À¡C
⑸¡BxyThumbBottom¡G±²°Ê¤è¶ô¥k½t¡]¤ô¥­±²°Ê¶b¡^©Î¤U½t¡]««ª½±²°Ê¶b¡^¶ZÂ÷±²°Ê¶b¥ª½t©Î¤W½t¦h¤Ö¹³¯À¡C
⑹¡Breserved¡G«O¯dªºÂù¦r²Õ¡A¥¼¨Ï¥Î¡C
⑺¡Brgstate ¬O¥Ñ¤»­Ó¤¸¯À²Õ¦¨ªº°}¦C¡A²Ä¹s¡ã¥|­Ó¤¸¯À¤À§O¥Nªí±²°Ê¶b¥»¨­¡B¦V¥ª©Î¦V¤W±²°Ê½bÀY¡B¦V¥k©Î¦V¤U±²°Ê½bÀY¡B±²°Ê¤è¶ô¡B¥ªÃä©Î¤WÃä±²°Ê­y¹D¡B¥kÃä©Î¤UÃä±²°Ê­y¹Dªºª¬ºA¡C³o¨Ç±²°Ê¶b¤º¦U³¡¤Àªºª¬ºA¡A¥i¯à¬O©³¤Uªº¼Æ­È¤§²Õ¦X¡G¡]rg ¬O array of ªºÁY¼g¡^
⒜¡BSTATE_SYSTEM_INVISIBLE¡G¹ï±²°Ê¶b¦Ó¨¥¡Aªí¥Ü±²°Ê¶b¤£¦s¦b¡A¥i¯à¬O¦]¬°¤º®e¤£¶W¥Xµøµ¡½d³ò¡A¦]¦¹¤£»Ý­n¡C¹ï±²°Ê­y¹D¦Ó¨¥¡Aªí¥Ü±²°Ê¤è¶ô²¾¦Ü³ÌÃä½tªº¦ì¸m¨Ï±o³o¨Ç°Ï°ì¤£¥i¨£¡C¨Ò¦p±²°Ê¤è¶ô¦b¤ô¥­±²°Ê¶b³Ì¥ªÃä¡A´N·|¨Ï¥ªÃä±²°Ê­y¹D¤£¦s¦b¡CSTATE_SYSTEM_INVISIBLE µ¥©ó 8000H¡C
⒝¡BSTATE_SYSTEM_OFFSCREEN¡G¹ï±²°Ê¶b¦Ó¨¥¡Aªí¥Üµøµ¡ªº¤j¤p©Î¦ì¸m¨Ï±o±²°Ê¶b¤£¥i¨£¡A¨Ò¦pµøµ¡ªº±²°Ê¶b¦ì©ó¿Ã¹õ¥~¡A±²°Ê¶b¤´¦s¦b¦ý¨S¦³Åã¥Ü¥X¨Ó¡CSTATE_SYSTEM_OFFSCREEN µ¥©ó 10000H¡C
⒞¡BSTATE_SYSTEM_PRESSED¡Gªí¥Ü±²°Ê¶bªº±²°Ê½bÀY©Î±²°Ê­y¹D³B©ó«ö¤Uª¬ºA¡C³q±`¬O¨Ï¥ÎªÌ¥H·Æ¹««ö¦í³o¨Ç°Ï°ì®É¥X²{¡A¦¹®É±²°Ê¶b³Q«ö¤Uªº³¡¤À¡A·|¥HÅãµÛªºÃC¦âªí¥Ü¡CSTATE_SYSTEM_PRESSED ¬° 8H¡C
⒟¡BSTATE_SYSTEM_UNAVAILABLE¡Gªí¥Ü±²°Ê¶bªº¦¹³¡¤À³Q¸T¥Î¡A¨Ï¥ÎªÌµLªk¾Þ§@¥¦¡CSTATE_SYSTEM_UNAVAILABLE µ¥©ó 1¡C
⑤¡BSBM_GETSCROLLINFO¡Gµo°e¦¹°T®§µ¹±²°Ê¶b±±¨î¶µªº¸ê®Æ¡CwParam ¤£¨Ï¥Î¡AÀ³³]¬°¹s¡FlParam ¬° SCROLLINFO µ²ºcÅ骺¦ì§}¡CSCROLLINFO µ²ºcÅé»P«e­±»¡¹Lªº SCROLLBARINFO µ²ºcÅé¦WºÙ«Ü¬Û¦ü¡A§O§Ë¿ù¤F¡A¥i°Ñ¾\²Ä¤Q³¹ SCROLLINFO ªº»¡©ú¡C
⑥¡BSBM_SETPOS¡Gµo°e¦¹°T®§µ¹±²°Ê¶b±±¨î¶µ¡A¯à³]©w±²°Ê¤è¶ô¦ì¸m¡CwParam ¬O±²°Ê¤è¶ôªº·s¦ì¸m¡A¥²¶·¦b SetScrollPos ©Ò³]©wªº¦ì¸m½d³ò¤º¡A§_«h·|³Q±Ë±ó¨ì³Ì±µªñªº½d³ò¤º¡ClParam ³]¬°¹sªí¥Ü¤£­«·sø»s¦¨·s¦ì¸m¡F³]¬°¤@ªí¥Ü­«Ã¸·s¦ì¸m¡C¦^¶Ç­È¬°±²°Ê¤è¶ô·í«e¦ì¸m¡C
⑦¡BSBM_SETRANGE¡Gµo°e¦¹°T®§µ¹±²°Ê¶b±±¨î¶µ¡A¯à³]©w±²°Ê¤è¶ôªº¦ì¸m½d³ò¡CwParam ¬°¦ì¸mªº³Ì¤p­È¡AlParam ¬°¦ì¸mªº³Ì¤j­È¡C¦^¶Ç­È¬°±²°Ê¤è¶ô·í«e¦ì¸m¡C
⑧¡BSBM_SETRANGEREDRAW¡Gµo°e¦¹°T®§µ¹±²°Ê¶b±±¨î¶µ¡A¯à³]©w±²°Ê¤è¶ôªº¦ì¸m½d³ò¡CwParam ¬°¦ì¸mªº³Ì¤p­È¡AlParam ¬°¦ì¸mªº³Ì¤j­È¡C»P SBM_SETRANGE ¤£¦Pªº¬O¡A¦ì¸mªº³Ì¤j­È»P³Ì¤p­È¤§®t¡A¤£¥i¶W¹L MAXLONG¡A¨ä­È¬° 7FFF FFFFH¡C¦pªG³Ì¤j­È»P³Ì¤p­È¬Ûµ¥¡A·|¸T¥Î¨ÃÁôÂñ²°Ê¶b±±¨î¶µ¡C¦^¶Ç­È¬°±²°Ê¤è¶ô·í«e¦ì¸m¡C
⑨¡BSBM_SETSCROLLINFO¡Gµo°e¦¹°T®§µ¹±²°Ê¶b±±¨î¶µ¡A¯à³]©w±²°Ê¤è¶ôªºÄÝ©Ê¡CwParam ³]¬°¹sªí¥Ü¤£­«·sø»s¡F³]¬°¤@ªí¥Ü­«Ã¸¡ClParam ¬° SCROLLINFO µ²ºcÅ骺¦ì§}¡A¥i°Ñ¾\²Ä¤Q³¹ SCROLLINFO ªº»¡©ú¡C

¤W­±¤EºØ°T®§¤¤ªº¤»ºØ¡GSBM_GETPOS¡BSBM_GETRANGE¡BSBM_GETSCROLLINFO¡BSBM_SETPOS¡BSBM_SETRANGE¡BSBM_SETSCROLLINFO ¥Î©ó¨t²Î¤º³¡¡AÀ³¥Îµ{¦¡¤£À³µo°e³o¨Ç°T®§µ¹±²°Ê¶b±±¨î¶µ¡A¦Ó¬O©I¥s¬ÛÃö Win64 API¡C¨Ò¦p­nÀò±o±²°Ê¤è¶ô¦ì¸mÀ³©I¥s GetScrollPos¡AÀò±o±²°Ê¤è¶ô¦ì¸m¤§½d³òÀ³©I¥s GetScrollRange¡AÀò±o±²°Ê¶b¸ê®ÆÀ³©I¥s GetScrollInfo¡A³]©w±²°Ê¶b¤è¶ô¦ì¸mÀ³©I¥s SetScrollPos¡AÀò±o±²°Ê¤è¶ô¦ì¸m¤§½d³òÀ³©I¥s SetScrollRange¡A³]©w±²°Ê¶b±±¨î¶µ¸ê®ÆÀ³©I¥s SetScrollInfo¡C³o¤»ºØ°T®§§¡¥H·tºñ¦âÅã¥Ü¡C

±²°Ê¶b±±¨î¶µªº³qª¾½X

·í¨Ï¥ÎªÌ¾Þ§@±²°Ê¶b±±¨î¶µ¡A¨Ã¤£¬O¹³«ö¶s¡B½s¿è®Øµ¥±±¨î¶µµo¥X WM_COMMAND °T®§¡A³qª¾¤÷µøµ¡¨Ï¥ÎªÌ°µ¤F­þ¨Ç°Ê§@¡A¦Ó¬Oµo¥X WM_HSCROLL ©Î WM_VSCROLL °T®§¡A³qª¾¤÷µøµ¡¡CÅã¦Ó©ö¨£ªº¡A¤ô¥­±²°Ê¶b±±¨î¶µµo¥X WM_HSCROLL °T®§¡A¹]Áè±²°Ê¶b±±¨î¶µµo¥X WM_VSCROLL °T®§¡C

³o¨â«h°T®§¤¤¡AwParam ªº§C¦r²Õ¬O³qª¾½X¡A½Ð°Ñ¾\²Ä¤E³¹ªº»¡©ú¡F°ª¦r²Õ¬° NULL¡A°£¤F³qª¾½X¬O SB_THUMBPOSITION ©Î SB_THUMBTRACK ®É¡A°ª¦r²Õ¬O¨Ï¥ÎªÌ©ì¦²±²°Ê¤è¶ô·í®Éªº¦ì¸m¡ClParam ¬O±²°Ê¶b±±¨î¶µ¥N½X¡C


¥H¹ï¸Ü²°¬°¥D­n¤¶­±ªºÀ³¥Îµ{¦¡

¦b¤W¤@³¹¤¶²Ð¤F±j¨î¦^À³¹ï¸Ü²°¡]¤]ºÙ¬°¼Ò¦¡¹ï¸Ü²°¡^¡A¨ä¤¤ªº½d¨Ò¡AMODAL1.ASM¡A¥¦¥ý«Ø¥ß¤F¤@¯ëµøµ¡¡A«ö¤U¥[³tÁ䤧«á¤~¼u¥X±j¨î¦^À³¹ï¸Ü²°¡C¨Æ¹ê¤W¨Ã¤£»Ý­n¦h¦¹¤@Á|¡A¥i¥Hª½±µ«Ø¥ß±j¨î¦^À³¹ï¸Ü²°§@¬°µ{¦¡ªº¥D­n¤¶­±¡A³o¼Ëªºµ{¦¡«Ü²³æ¡A¤£»Ý­nµù¥Uµøµ¡Ãþ§O¡B¤£»Ý­n«Ø¥ß°T®§´`Àô¡A¬O³\¦hµ{¦¡³]­p®v³ß·R±Ä¥Îªº¤è¦¡¡A¦¹¤D¡u¥H¹ï¸Ü²°¬°¥D­n¤¶­±ªºÀ³¥Îµ{¦¡¡v¡C¥¦ªº­ì©lµ{¦¡¥i¥H¼g¦¨¤U­±ªº¡u¼ÒªO¡v¡G

OPTION CASEMAP:NONE
OPTION WIN64:7

INCLUDE         WINDOWS.INC
INCLUDELIB      KERNEL32.LIB
INCLUDELIB      USER32.LIB
;*******************************************************************************
.CONST
szDlgName       DB      "DLGNAME",0
  ⁝
;*******************************************************************************
.DATA
hInst   HANDLE  ?       ;¼Ò²Õ¥N½X
  ⁝
;*******************************************************************************
.CODE
;-------------------------------------------------------------------------------
DlgProc PROC    hDlg:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
.if uMsg==WM_INITDIALOG
  ⁝
 
.elseif uMsg==WM_COMMAND
        mov     rax,r8  ;R8W¡×ÃѧO½X
        shr     rax,10h ;AX¡×³qª¾½X
  ⁝

.elseif uMsg==WM_CLOSE
exit:   invoke  EndDialog,hDlg,0
 
.else   ;¨ä¥L¥¼³B²zªº°T®§ªð¦^ FALSE
        xor     rax,rax
        ret
 
.endif  ;¤w³B²zªº°T®§¡Aªð¦^ TRUE
        mov     rax,1
        ret
DlgProc ENDP
;-------------------------------------------------------------------------------
main    PROC
        invoke  GetModuleHandle,0
        mov     hInst,rax
        invoke  DialogBoxParam,hInst,OFFSET szDlgName,0,OFFSET DlgProc,0
        invoke  ExitProcess,0
main    ENDP
;*******************************************************************************
END     main

¥¦ªº¸ê·½´y­zÀÉ¥i¥H¼g¦¨©³¤Uªº¼Ë¤l¡G

#include "RESOURCE.H"
  ⁝
DLGNAME DIALOGEX    x, y, width, height
FONT    10,"MS Shell Dlg"
CAPTION "SOME TEXT"
BEGIN
  CONTROL "text", id, "class name", style, x, y, width, height
  ⁝
END

¥»³¹½d¨Ò©Ò»Ýªº­ì²z¡A´X¥G¤w¤¶²Ð§¹²¦¡A¶È³Ñ¤U·|¨Ï¥Îªº Win64 API¡C

SetDlgItemText API

SetDlgItemText API ¥Î©ó³]©w¹ï¸Ü²°¤º¬Y­Ó±±¨î¶µªº¼ÐÃD©Î¤å¦r¡A¨Ò¦pÀRºA±±¨î¶µ¡B«ö¶s¡B½s¿è®Ø¤W­±ªº¤å¦r¡C¥¦ªº­ì«¬¬O¡G

invoke  SetDlgItemText,\
        hDlg,\          ; handle of dialog box
        nIDDlgItem,\    ; identifier of control
        lpString        ; text to set

hDlg ¬O¹ï¸Ü²°¥N½X¡A­n³]©w¤å¦rªº±±¨î¶µ¥]§t¦b¸Ó¹ï¸Ü²°¤º¡FnIDDlgItem ¬O­n³]©w¤å¦rªº±±¨î¶µÃѧO½X¡FlpString ¬O¥H¹sµ²§Àªº¦r¦ê¦ì§}¡A±±¨î¶µ¤Wªº¤å¦r·|³]¬°¦¹¦r¦ê¡C¦pªG SetDlgItemText °õ¦æ¦¨¥\¦^¶Ç­È¬°¤@¡F¦pªG¥¢±Ñ¦^¶Ç­È¬°¹s¡C

SetDlgItemText ¥i¥H¦b¤£ª¾¹D±±¨î¶µ¥N½X©Î¬O¥i¥H¬Ý¦¨¬Oµøµ¡¥N½Xªº±¡§Î¤U¡A³]©w¨ä¤å¦r¡A¹ï©ó¹ï¸Ü²°¤ºªº±±¨î¶µ¦Ó¨¥«Ü¤è«K¡CÀ³¥Îµ{¦¡¤]¥i¥H¦bª¾¹D±±¨î¶µ¥N½Xªº±¡§Î¤U¡A©I¥s SetWindowText ³]©w±±¨î¶µ¥N½X¤Wªº¤å¦r¡C

SetBkColor API

SetBkColor ¥Î¨Ó³]©w¤å¦rªº­I´ºÃC¦â¡C¨ä­ì«¬¬°¡G

invoke  SetBkColor,\
        hdc,\           ; handle of device context
        crColor         ; background color value

hdc ¬O¸Ë¸m¤º®e¥N½X¡AcrColor ¬O¤å¦rªº­I´ºÃC¦â¡C¦³ÃöÃC¦âªº³]©w¤èªk¡A°Ñ¾\²Ä¤Q¤@³¹ªº»¡©ú¡C¦pªG SetBkColor °õ¦æ¦¨¥\¡A¦^¶Ç­È¬O­ì¥ýªº­I´ºÃC¦â¡F¦pªG¥¢±Ñ¡A¦^¶Ç­È¬O CLR_INVALID¡C¡]CLR_INVALID¡×¡Ð1¡^

SetBkColor ·|¥Î crColor ¶ñº¡¤å¦r½u±ø¤§¶¡ªº¶¡»Ø¡A¦ý¤£·|¶ñº¡¤å¦r©Ò¦û¤è¶ô¤§¥~ªºªÅ¶¡¡A¨ºªÅ¶¡¬Oµe¨ê¶ñº¡ªº¡]¨£µy«áªº WM_CTLCOLORSTATIC °T®§¡^¡CSetBkColor ¤]·|³]©w TextOut ©M ExtTextOut ªº­I´ºÃC¦â¡C¦pªG­I´º¼Ò¦¡¬° TRANSPARENT¡A¨º»ò SetBkColor ´NµL§@¥Î¡C¦pªG­I´º¼Ò¦¡¬O OPAQUE¡A¥B­I´º¬°ÂI°}¹Ï¡A¨º»ò¤]·|¨Ï¥Î­I´º¦â¡C

WM_CTLCOLORSTATIC °T®§

·í¨t²Î­nø»sÀRºA±±¨î¶µ¤§«e¡A·|§â WM_CTLCOLORSTATIC °T®§µo°eµ¹¤÷µøµ¡ªºµøµ¡¨ç¦¡¡CÀ³¥Îµ{¦¡¥i¥H¦b³B²z¦¹°T®§®É¡A³]©wÀRºA±±¨î¶µªº¤å¦rÃC¦â¡B¤å¦r­I´ºÃC¦â¥H¤ÎÀRºA±±¨î¶µªº­I´ºµe¨ê¡C·í¨t²Îµo°e WM_CTLCOLORSTATIC °T®§®É¡AwParam ¬OÀRºA±±¨î¶µªº¸Ë¸m¤º®e¥N½X¡AlParam ¬OÀRºA±±¨î¶µ¥N½X¡Fªð¦^¦Ü¨t²Î®É¡A¦^¶Ç­È¬Oµe¨ê¥N½X¡A¨t²Î·|¥Î³oµe¨ê¶îº¡ÀRºA±±¨î¶µªº­I´º¡C


¥H¹ï¸Ü²°¬°¥D­n¤¶­±ªºÀ³¥Îµ{¦¡½d¨Ò¡GMODAL2

¥»³¹¤¶²Ð¤F±²°Ê¶b±±¨î¶µ¥H¤Î¥H¹ï¸Ü²°¬°¥D­n¤¶­±ªºÀ³¥Îµ{¦¡¡A©Ò¥H±µ¤U¨Ó«K¥Î¥¦­Ì¨Ó¹ê§@¤@­ÓÀ³¥Îµ{¦¡¡AMODAL2¡A¥¦°õ¦æ®Éµe­±¦p¥k¹Ï¡C

²³©Ò©Pª¾¡AWindows §@·~¨t²ÎªºÃC¦â¬O¥H¬õ¡Bºñ¡BÂŤT¦â²Õ¦¨¡A¨CºØÃC¦âªº½d³ò¬O 0¡ã255 ¤§¶¡¡C¦pªG¤T¦â§¡¬°¹s¡A¥Nªí¶Â¦â¡F­Y¤T¦â§¡¬° 255¡A¥Nªí¥Õ¦â¡CMODAL2 ¦³¤T­Ó±²°Ê¶b±±¨î¶µ¡A¨ä±²°Ê¤è¶ô¦ì¸m¤]¦b 0¡ã255 ¤§¶¡¡A¤À§Oªí¥Ü³o¤T¦âªº±j«×¡C¨Ï¥ÎªÌ¥i¥H©ì¦²±²°Ê¶b¤è¶ô¡B©Î«ö±²°Ê½bÀY¡B©Î¬O«ö±²°Ê­y¹D§ïÅܱ²°Ê¶b¤è¶ô¦ì¸m¡C¦b§ïÅܱ²°Ê¤è¶ô¦ì¸m¥kÃ䪺ÀRºA±±¨î¶µ¡A·|Åã¥Ü·í«e±²°Ê¤è¶ô¦ì¸m¡A¦P®É¥ª¤U¨¤ªºÀRºA±±¨î¶µÃC¦â·|ÀH¤§§ïÅÜ¡C

MODAL2 ªº­ì©lµ{¦¡

©³¤U¬O MODAL2.ASM ªº¤º®e¡G

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
;®i¥Ü¥H¹ï¸Ü²°¬°¥D­n¤¶­±ªºÀ³¥Îµ{¦¡
;²ÕĶ»P³sµ²¡G
;rc modal2.rc
;uasm64 -win64 modal2.asm
;link modal2.obj modal2.res /largeaddressaware:no
OPTION CASEMAP:NONE
OPTION WIN64:7

IDSB_RED   EQU  2001
IDSB_GREEN EQU  2002
IDSB_BLUE  EQU  2003
IDS_COLOR  EQU  2004
IDB_EXIT   EQU  2005
IDS_RED    EQU  2006
IDS_GREEN  EQU  2007
IDS_BLUE   EQU  2008

INCLUDE         WINDOWS.INC
INCLUDELIB      KERNEL32.LIB
INCLUDELIB      USER32.LIB
INCLUDELIB      GDI32.LIB
;*******************************************************************************
.CONST
szDlgName       BYTE    "COLOR",0
szFmt           DB      "%d",0
;*******************************************************************************
.DATA
hInst   HANDLE  ?       ;¼Ò²Õ¥N½X
hRedSb  HANDLE  ?       ;¥Nªí¬õ¦â±j«×ªº±²°Ê¶b±±¨î¶µ
hGrnSb  HANDLE  ?       ;¥Nªíºñ¦â±j«×ªº±²°Ê¶b±±¨î¶µ
hBluSb  HANDLE  ?       ;¥NªíÂŦâ±j«×ªº±²°Ê¶b±±¨î¶µ
hColor  HANDLE  ?       ;¥NªíÃC¦âªºÀRºA±±¨î¶µ
iPos    DD    3 DUP (0) ;¤T­Ó±²°Ê¶b±±¨î¶µ¦ì¸m
;*******************************************************************************
.CODE
;-------------------------------------------------------------------------------
DlgProc PROC    hDlg:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
        LOCAL   buffer[20h]:BYTE,tmp:QWORD
.if uMsg==WM_INITDIALOG
    ;¨ú±o¤T­Ó±²°Ê¶b±±¨î¶µªº¥N½X¡A¤À§O¦s©óhRedSb¡BhGrnSb¡BhBluSb¤º¡A
    ;¨Ã³]©w¦¹¤T­Ó±²°Ê¶b±±¨î¶µªº½d³ò¦b0¡ã255¤§¶¡
        invoke  GetDlgItem,hDlg,IDSB_RED
        mov     hRedSb,rax
        invoke  SetScrollRange,rax,SB_CTL,0,255,1
        invoke  GetDlgItem,hDlg,IDSB_GREEN
        mov     hGrnSb,rax
        invoke  SetScrollRange,rax,SB_CTL,0,255,1
        invoke  GetDlgItem,hDlg,IDSB_BLUE
        mov     hBluSb,rax
        invoke  SetScrollRange,rax,SB_CTL,0,255,1
    ;¨ú±oIDS_COLORÀRºA±±¨î¶µ¥N½X¡A¨äÃC¦â·|ÀHµÛ±²°Ê¶b±±¨î¶µ¤Wªº¤è¶ô¦ì¸m¦ÓÅÜ
        invoke  GetDlgItem,hDlg,IDS_COLOR
        mov     hColor,rax

.elseif uMsg==WM_COMMAND
        mov     rax,r8  ;R8W¡×ÃѧO½X
        shr     rax,10h ;AX¡×³qª¾½X
  .if ax==BN_CLICKED
    .if r8w==IDB_EXIT   ;­Y¨Ï¥ÎªÌ«ö¤UÂ÷¶}«ö¶s´Nµ²§ôÀ³¥Îµ{¦¡
        jmp     exit
    .endif
  .endif

.elseif uMsg==WM_HSCROLL
    ;§PÂ_¨Ï¥ÎªÌ¾Þ§@­þ­Ó±²°Ê¶b±±¨î¶µ
    .if r9==hRedSb
        xor     rax,rax ;RAX¡×0¡Aªí¥Ü¨Ï¥ÎªÌ¾Þ§@¥Nªí¬õ¦âªº±²°Ê¶b±±¨î¶µ
    .elseif r9==hGrnSb
        mov     rax,4   ;RAX¡×4¡Aªí¥Ü¨Ï¥ÎªÌ¾Þ§@¥Nªíºñ¦âªº±²°Ê¶b±±¨î¶µ
    .else
        mov     rax,8   ;RAX¡×8¡Aªí¥Ü¨Ï¥ÎªÌ¾Þ§@¥NªíÂŦ⪺±²°Ê¶b±±¨î¶µ
    .endif
        mov     tmp,rax
    ;¨Ì¾Ú¨Ï¥ÎªÌªº¾Þ§@¡A§ïÅܬ۹ïÀ³±²°Ê¶b¤W±²°Ê¤è¶ô¦ì¸m
    .if r8w==SB_LINELEFT
        dec     iPos[rax]
    .elseif r8w==SB_LINERIGHT
        inc     iPos[rax]
    .elseif r8w==SB_PAGELEFT
        sub     iPos[rax],10h
    .elseif r8w==SB_PAGERIGHT
        add     iPos[rax],10h
    .elseif r8w==SB_THUMBTRACK
        mov     r10,wParam
        shr     r10,10h
        mov     iPos[rax],r10d
    .endif
    ;Àˬd±²°Ê¤è¶ô¦ì¸m¬O§_¦b0¡ã255¤§¶¡¡A­Y¤£¦b³o½d³ò«h½Õ¾ã¬°0©Î255
        cmp     iPos[rax],0
        jl      negat
        cmp     iPos[rax],255
        jbe     ok
        mov     iPos[rax],255
        jmp     ok
negat:  mov     iPos[rax],0
    ;§â±²°Ê¤è¶ô¦ì¸m¡AÅã¥Ü©ó±²°Ê¶b±±¨î¶µ¥kÃ䪺ÀRºA±±¨î¶µ¤W
ok:     invoke  wsprintf,ADDR buffer,OFFSET szFmt,iPos[rax]
        mov     rdx,tmp
        shr     rdx,2
        add     rdx,IDS_RED     ;RDX¡×¨Ï¥ÎªÌ¾Þ§@ªº±²°Ê¶b±±¨î¶µÃѧO½X
        invoke  SetDlgItemText,hDlg,edx,ADDR buffer
    ;³]©w·sªº±²°Ê¶b¤è¶ô¦ì¸m
        mov     rax,tmp
        invoke  SetScrollPos,lParam,SB_CTL,iPos[rax],1
    ;±j­¢IDS_COLORÀRºA±±¨î¶µ­«Ã¸
        invoke  InvalidateRect,hColor,0,1

.elseif uMsg==WM_CTLCOLORSTATIC
    .if r9==hColor
        mov     ecx,iPos[8]     ;ECX¡×ÂŦâ±j«×
        mov     r10d,iPos[4]    ;R10D¡×ºñ¦â±j«×
        shl     ecx,10h
        shl     r10d,8h
        add     ecx,iPos        ;ECX¡×³Ì«áÃC¦â
        add     ecx,r10d
        invoke  CreateSolidBrush,ecx
        ret
    .endif

.elseif uMsg==WM_CLOSE
exit:   invoke  EndDialog,hDlg,0
 
.else   ;¨ä¥L¥¼³B²zªº°T®§ªð¦^ FALSE
        mov     rax,0
        ret
 
.endif  ;¤w³B²zªº°T®§¡Aªð¦^ TRUE
        mov     rax,1
        ret
DlgProc ENDP
;-------------------------------------------------------------------------------
main    PROC
        invoke  GetModuleHandle,0
        mov     hInst,rax
        invoke  DialogBoxParam,hInst,OFFSET szDlgName,0,OFFSET DlgProc,0
        invoke  ExitProcess,0
main    ENDP
;*******************************************************************************
END     main

©³¤U¬O MODAL2.RC ªº¤º®e¡G

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "RESOURCE.H"
#define  IDSB_RED   2001
#define  IDSB_GREEN 2002
#define  IDSB_BLUE  2003
#define  IDS_COLOR  2004
#define  IDB_EXIT   2005
#define  IDS_RED    2006
#define  IDS_GREEN  2007
#define  IDS_BLUE   2008

COLOR   DIALOGEX    200,100,150,108
FONT    10,"MS Shell Dlg"
CAPTION "¥úªº¤T­ì¦â"
BEGIN
  RTEXT         "¬õ",1,           4, 5, 10,10
  SCROLLBAR          IDSB_RED,   16, 4,100,10,SBS_HORZ
  LTEXT         "0", IDS_RED,   118, 5, 16,10
  RTEXT         "ºñ",2,           4,25, 10,10
  SCROLLBAR          IDSB_GREEN, 16,24,100,10,SBS_HORZ
  LTEXT         "0", IDS_GREEN, 118,25, 16,10
  RTEXT         "ÂÅ",3,           4,45, 10,10
  SCROLLBAR          IDSB_BLUE,  16,44,100,10,SBS_HORZ
  LTEXT         "0", IDS_BLUE,  118,45, 16,10
  CTEXT         "",  IDS_COLOR,  16,64, 30,30
  DEFPUSHBUTTON "Â÷¶}",IDB_EXIT, 85,80, 46,14
END

¸ÑÄÀ MODAL2.RC

ª`·N¨ì¡AMODAL2.RC ¤¤²Ä 24 ¦æªºÀRºA±±¨î¶µ¨Ã¨S¦³¤å¦r¡A§Y¨Ï¤§«á¤@ª½¨ì MODAL2 µ²§ô¡A¤]³£¨S¦³¤å¦r¡C²z¥Ñ«Ü²³æ¡A³o­ÓÀRºA±±¨î¶È¶È¥Î¨Óªí²{ÃC¦â¡A©Ò¥H¤£»Ý­n¤å¦r¡C¬Æ¦Ü¦pªG¦³¤å¦r¡AÁÙ·|«Ü³Â·Ð¡C

°²³]¦³¤F¤@­Ó¤å¦r¡uX¡v¡A°õ¦æµ²ªG·|Åܦ¨¥k¹Ï¡C³o®É­ÔÁÙ­n¶O¤ß©I¥s SetBkColor¡AÅý¤å¦r­I´º¦â»P±±¨î¶µªº­I´º¦â¤@¼Ë¡F¤]­n©I¥s SetTextColor §ïÅܤå¦rÃC¦â¡C³o¼Ë°Z¤£¼W¥[³Â·Ð¡H©Ò¥H°®¯ÜÅý³o­ÓÀRºA±±¨î¶µ¦Û©l¦Ü²×¨S¦³¤å¦r¡C

¸ÑÄÀ MODAL2.ASM ¤¤³B²z WM_HSCROLL °T®§ªº¹Lµ{

±²°Ê¶b±±¨î¶µ¶Ç»¼°T®§µ¹¤÷µøµ¡¡A¨Ã¤£¬OÂÇ¥Ñ WM_COMMAND °T®§¡C¹ï©ó¤ô¥­±²°Ê¶b±±¨î¶µ¡A¬O¾aµÛ WM_HSCROLL °T®§¡F¹ï©ó¹]Áè±²°Ê¶b±±¨î¶µ¡A«h¬O¾a WM_VSCROLL °T®§¡CÂǵ۳o¨âºØ°T®§¡A±²°Ê¶b±±¨î¶µ¤~¯à°÷§i¶D¤÷µøµ¡¡A¨Ï¥ÎªÌ°µ¤F­þ¨Ç¾Þ§@¡A¤÷µøµ¡¦bµøµ¡¨ç¦¡¤¤¤~¯à°µ¥X¬Û¹ïªº¦^À³¡C

¦ý¬O MODAL2 ªº¹ï¸Ü²°¦³¤T­Ó±²°Ê¶b±±¨î¶µ¡A¤À§O¹ïÀ³¬õ¦â¡Bºñ¦â¡BÂŦâ±j«×ªº±²°Ê¶b±±¨î¶µ¡A¥¦­Ì³£·|µo¥X WM_HSCROLL °T®§¡A¨º­n«ç»ò¤À¿ë©O¡H¨ä¹ê¤£Ãø¡A¥Ñ lParam ¤ºªº±²°Ê¶b±±¨î¶µ¥N½X¡A´N¯àª¾¹D¨Ï¥ÎªÌ¥¿¦b¾Þ§@­þ­Ó±²°Ê¶b±±¨î¶µ¡C³o¬q¹Lµ{¦b MODAL2.ASM ªº²Ä 65¡ã73 ¦æ¡A³Ì«áµ²ªG¬ö¿ý©ó RAX ¼È¦s¾¹¤º¡A¦A¦s¤J tmp °Ï°ìÅܼƤ¤¡Cµ{¦¡½X¦p¤U¡G

65 ;§PÂ_¨Ï¥ÎªÌ¾Þ§@­þ­Ó±²°Ê¶b±±¨î¶µ
66 .if r9==hRedSb
67     xor     rax,rax ;RAX¡×0¡Aªí¥Ü¨Ï¥ÎªÌ¾Þ§@¥Nªí¬õ¦âªº±²°Ê¶b±±¨î¶µ
68 .elseif r9==hGrnSb
69     mov     rax,4   ;RAX¡×4¡Aªí¥Ü¨Ï¥ÎªÌ¾Þ§@¥Nªíºñ¦âªº±²°Ê¶b±±¨î¶µ
70 .else
71     mov     rax,8   ;RAX¡×8¡Aªí¥Ü¨Ï¥ÎªÌ¾Þ§@¥NªíÂŦ⪺±²°Ê¶b±±¨î¶µ
72 .endif
73     mov     tmp,rax

¥i¯à·|¦³¤HÃhºÃ¡A­è­è¤£¬O»¡¥H lParam §@¬°§PÂ_­þ­Ó±²°Ê¶b±±¨î¶µµo¥Xªº WM_HSCROLL °T®§¶Ü¡H«ç»ò¤W­±ªºªºµ{¦¡¤ù¬q¥Î R9 ¼È¦s¾¹©O¡H³o¬O¦]¬°¦b MODAL2.ASM ²Ä¤C¦æ¦³¹D±Ô­z¡uOPTION WIN64:n¡v¡A·í n ªº²Ä¹s¦ì¤¸¬°¤@®É¡A·|¦Û°Ê¦b°Æµ{¦¡¤@¶}©l¨Ï RCX¡BRDX¡BR8¡BR9 Åܬ°«e¥|­Ó°Ñ¼Æ¡A©Ò¥H R9 ´Nµ¥©ó lParam¡C·í¨Ï¥ÎªÌ¾Þ§@¤£¦Pªº±²°Ê¶b±±¨î¶µ®É¡AR9 ¬°±±¨î¶µ¥N½X¡A¨Ì¾Ú R9 ³]©w RAX¡A¦p¤U¡G

  1. ·í¨Ï¥ÎªÌ¾Þ§@¥Nªí¬õ¦âªº±²°Ê¶b±±¨î¶µ®É¡A¤£½×¬O©ì¦²±²°Ê¤è¶ôÁÙ¬O«ö±²°Ê½bÀY©Î¬O¨ä¥L¾Þ§@¡ARAX ³£¬O 0¡C
  2. ·í¨Ï¥ÎªÌ¾Þ§@¥Nªíºñ¦âªº±²°Ê¶b±±¨î¶µ®É¡A¤£½×¬O¦óºØ¾Þ§@¡ARAX ³£¬O 4¡C
  3. ·í¨Ï¥ÎªÌ¾Þ§@¥NªíÂŦ⪺±²°Ê¶b±±¨î¶µ®É¡A¤£½×¬O¦óºØ¾Þ§@¡ARAX ³£¬O 8¡C

¬°¦ó RAX ­n³]¬°³o¤TºØ¼Æ¡A¤£¦æ³] 0¡B1¡B2 ©Î¨ä¥L¼Æ¶Ü¡H³o©M¬ö¿ý¤T­Ó±²°Ê¶b±±¨î¶µ¤W±²°Ê¤è¶ôªº¦ì¸m¦³Ãö¡C¦b MODAL2.ASM ªº²Ä 33 ¦æ©w¸q¤F¥Ñ¤T­ÓÂù¦r²Õªøªº¤¸¯À©Ò²Õ¦¨ªº°}¦C¡AiPos¡C¥Ñ¨ä¦WºÙ¥i¥Hª¾¹D¡A³o­Ó°}¦C¬O¬ö¿ý¤T­Ó±²°Ê¶b±±¨î¶µ¤W±²°Ê¶bªº¦ì¸m¡A¦Ó¥B¨C­Ó¤¸¯Àªø 4 ­Ó¦ì¤¸²Õ¡C¤]´N¬O»¡ iPos[0] ¥Nªí¬õ¦â±²°Ê¶b¤W±²°Ê¤è¶ôªº¦ì¸m¡AiPos[4] ¥Nªíºñ¦â±²°Ê¶b¤W±²°Ê¤è¶ôªº¦ì¸m¡K¡K¡C

±µ¤U¨Ó²Ä 74¡ã87 ¦æµ{¦¡¦p¤U¡C¥Ñ wParam §C¦r²Õ¤ºªº¸ê®Æ¥i¥Hª¾¹D¨Ï¥ÎªÌ¶i¦æ¤F¤°»ò¾Þ§@¡AwParam ¦b¶i¤Jµøµ¡¨ç¦¡®É´N¦]²Ä¤C¦æªº¡uOPTION WIN64:7¡v±Ô­z¡A¦Ó¦s©ó R8 ¼È¦s¾¹¡A©Ò¥H¥u»Ý¥Ñ R8W ¨Ó§PÂ_§Y¥i¡C¨Ò¦p·í¨Ï¥ÎªÌ«ö¤U¬õ¦â±²°Ê¶b±±¨î¶µ¤Wªº¦V¥k±²°Ê­y¹D¡A¨º»ò R8W ¬° SB_PAGERIGHT¡A¦]¦¹­n¨Ï iPos ªº²Ä 0 ­Ó¤¸¯À¥[¤W 10H¡A©Ò¥H­n°õ¦æªº«ü¥O¬O¡uadd iPos[rax],10h¡v¡C

74 ;¨Ì¾Ú¨Ï¥ÎªÌªº¾Þ§@¡A§ïÅܬ۹ïÀ³±²°Ê¶b¤W±²°Ê¤è¶ô¦ì¸m
75  .if r8w==SB_LINELEFT
76      dec     iPos[rax]
77  .elseif r8w==SB_LINERIGHT
78      inc     iPos[rax]
79  .elseif r8w==SB_PAGELEFT
80      sub     iPos[rax],10h
81  .elseif r8w==SB_PAGERIGHT
82      add     iPos[rax],10h
83  .elseif r8w==SB_THUMBTRACK
84      mov     r10,wParam
85      shr     r10,10h
86      mov     iPos[rax],r10d
87  .endif

³Ñ¤UªºÀˬd iPos[rax] ªº½d³ò¬O§_¦b 0¡ã100 ¤§¶¡¡A§ïÅܱ²°Ê¶b±±¨î¶µ¥kÃ䪺ÀRºA±±¨î¶µ¤Wªº¤å¦r¡A³]©w±²°Ê¤è¶ôªº¦ì¸m³£«Ü²³æ¡A¤£¶·¸Ô­z¡C

³Ì«áªºÃøÃD¬O¡A·í¨Ï¥ÎªÌ¤w¸g¾Þ§@¤F±²°Ê¶b±±¨î¶µ¤§«á¡A­n¦p¦óIJµo WM_CTLCOLORSTATIC °T®§¡A³o¼Ë¤~¯à§Y®É§ïÅÜ¥ª¤U¨¤ªºÀRºA±±¨î¶µ¡]±±¨î¶µ¥N½X¦s©ó hColor Åܼơ^­I´ºÃC¦â¡H³o®É¥i¥H©I¥s InvalidateRect¡AÅý hColor ¨ã¦³µL®Ä°Ï°ì¡C¦b MODAL2.ASM ªº²Ä 106 ¦æ¡A´N¬O¨Ï±o hColor ªº¾ã­Ó¤u§@°Ï³£ÅܱoµL®Ä¡A³o¼Ë´N¥²¶·­«Ã¸ hColor¡A¦p¦¹´N¯àIJµo WM)CTLCOLORSTATIC °T®§¡C

¸ÑÄÀ MODAL2.ASM ¤¤³B²z WM_CTLCOLORSTATIC °T®§ªº¹Lµ{

­º¥ý¦b MODAL2 ¹ï¸Ü²°ùئ³¤C­ÓÀRºA±±¨î¶µ¡A¦ý¥u¦³±±¨î¶µ¥N½X¬O hColor ªºÀRºA±±¨î¶µ¡]¤]´N¬O¹ï¸Ü²°¥ª¤U¨¤ªºÀRºA±±¨î¶µ¡^­n§ïÅÜ­I´ºÃC¦â¡A¨ä¾l¤£¥²¡C¦]¦¹¥²¶·¥Î .if/.endif ¨Ó§PÂ_¦¹ WM_CTLCOLORSTATIC ¬O§_¬° hColor µo¥X¨Óªº¡Cµ{¦¡¦b²Ä 108¡ã118 ¦æ¡A¸`¿ý¦p¤U¡G

108 .elseif uMsg==WM_CTLCOLORSTATIC
109     .if r9==hColor
110         mov     ecx,iPos[8]     ;ECX¡×ÂŦâ±j«×
111         mov     r10d,iPos[4]    ;R10D¡×ºñ¦â±j«×
112         shl     ecx,10h
113         shl     r10d,8h
114         add     ecx,iPos        ;ECX¡×³Ì«áÃC¦â
115         add     ecx,r10d
116         invoke  CreateSolidBrush,ecx
117         ret
118     .endif

·í .if/endif ÀË´ú¨ì¹ï¸Ü²°¥ª¤U¨¤ªºÀRºA±±¨î¶µµo¥Xªº WM_CTLCOLORSTATIC °T®§®É¡A¤~§â¦^¶Ç­È³]¬°¥Ñ¤T­Ó±²°Ê¶b±±¨î¶µ¥Í¦¨ªºÃC¦â©Ò«Ø¥ßªºµe¨ê¡A³o¼Ë¨t²Î´N¯à¥H¦¹µe¨ê¶ñº¡ÀRºA±±¨î¶µªº­I´ºÃC¦â¤F¡CÁöµM¡A¨ä¥LªºÀRºA±±¨î¶µ¤]·|µo¥X WM_CTLCOLORSTATIC¡A¦ý¨Ã¨S¦³³]¸m¾A·íªº¦^¶Ç­È¡A©Ò¥H¦b¨t²Î¤º³¡³]¸mµe¨ê®É·|µo¥Í¿ù»~¡A¦ýÁÙ¬O¦³­ì¨Óªºµe¨ê¥i¨Ñ¨t²Î¨Ï¥Î¡A©Ò¥H¨ä¥LÀRºA±±¨î¶µ¤´¯à¥¿±`µe¥X­I´ºÃC¦â¡C

¤W­±ªºµ{¦¡²Ä 110¡ã115 ¦æ¡A¬O®Ú¾Ú±²°Ê¤è¶ô¦ì¸m¡A¤]¥i¥H»¡¬O¤T­ì¦âªº±j«×¡A­pºâ¥XÃC¦â¡AµM«á¦s©ó ECX ¼È¦s¾¹¡C²Ä 116 ¦æ«h¬O®Ú¾Ú ECX ¤ºÀx¦sªºÃC¦â©I¥s CreateSolidBrush «Ø¥ßµe¨ê¡ACreateSolidBrush ªº¦^¶Ç­È´N¬O·sµe¨ê¥N½X¡A¦s©ó RAX¡AµM«áª½±µªð¦^¹ï¸Ü²°ºÞ²z¾¹¡A¹ï¸Ü²°ºÞ²z¾¹·|¦Û°Ê¨Ï¥Î·sµe¨êø»s­I´º¡C


«á°O

¥»³¹¤¶²Ð¤F¨â­Ó¥DÃD¡G¡u±²°Ê¶b±±¨î¶µ¡v©M¡u¥H¹ï¸Ü²°¬°¥D­n¤¶­±ªºÀ³¥Îµ{¦¡¡v¡C¥H«áªº½d¨Òµ{¦¡¡A¤j³¡¤À³£·|¬O¡u¥H¹ï¸Ü²°¬°¥D­n¤¶­±ªºÀ³¥Îµ{¦¡¡v¬°¥D¡A¦]¬°¥¦¤Ó¤è«K¤F¡C¦ý¬O²Ó¤ßªº§A¡A¥i¯à·|µo²{¡A³o´X³¹¬Æ¦Ü§ó¦­¤§«e©Ò«Ø¥ßªºµøµ¡³£¬OÁàÁ઺¡A¦ü¥G¸ò¤@¯ë¥«°â³nÅ骺µøµ¡¤£¤Ó¤@¼Ë¡C³o¬O¦]¬°¤§«eªº½d¨Òµ{¦¡³£¨S¦³¨Ï¥Î¡uvisual styles¡v¡A¤U¤@³¹¤¶²Ð¥¦¡C