Windows §@·~¨t²Î¯à°÷±µÄò DOS §@·~¨t²Î¡A¦¨¬°Ó¤H¹q¸£¥Dnªº§@·~¨t²Î¡A»P¨ä¿Ë©Mªº¨Ï¥ÎªÌ¤¶±¤£µLÃö«Y¡A¦Ó³o¨ä¤¤±±¨î¶µ¡]controls¡^°^Äm§ó¬OÁ|¨¬»´«¡C¦b¹q¸£¤¤¡A±±¨î¶µ¡]¤]½Ķ¬°±±¥ó©Î³¡¥ó¡Awidget¡^¬O¤@ºØ¹Ï§Î¤Æªº¨Ï¥ÎªÌ¤¶±¡A¥i¥HÅã¥Ü³\¦h¸ê®Æ¨Ñ¨Ï¥ÎªÌ¾Þ§@¡C
±q Windows 1.0 ¶}©l¡A´N¶}©l¨Ï¥Î±±¨î¶µ¡A¨ì Windows 3.x ¤w¸g§¹³Æ¡C³o¨Ç±±¨î¶µºÙ¬°¼Ð·Ç±±¨î¶µ¡]standard controls¡^¡A¦³
¡@¡@①ÀRºA±±¨î¶µ¡]static control¡^¡@¡@¡@¡@ ¡@ ¡@¡@②½s¿è®Ø±±¨î¶µ¡]edit control¡^
¡@¡@③«ö¶s±±¨î¶µ¡]button control¡^¡@¡@¡@¡@¡@¡@¡@④²M³æ²°±±¨î¶µ¡]list box control¡^
¡@¡@⑤¤U©Ô¦¡¤è¶ô±±¨î¶µ¡]combo box control¡^¡@¡@⑥±²°Ê¶b±±¨î¶µ¡]scroll-bar control¡^
¦@¤»ºØ¡C©I¥s¸ò¼Ð·Ç±±¨î¶µ¦³Ãöªº Win64 API ³£¦b USER32.DLL ¤º¡A¦]¦¹¦bÀ³¥Îµ{¦¡¤¤n©I¥s³o¨Ç Win64 API¡A¥²¶·¨Ï¥Î¡uINCLUDELIB USER32.LIB¡v¤~¦æ¡C¥k¹Ï»¡©ú¤F«e¤TºØ±±¨î¶µ¡G
¨ì Windows 95 ¤Î¨ä«á±ªº¨t²Î¡A¤S·s¥[¤F³\¦h±±¨î¶µ¡AºÙ¬°³q¥Î±±¨î¶µ¡]common controls¡^¡A¨Ò¦p TreeView¡BListView¡BTab µ¥¡C¦³Ãö³q¥Î±±¨î¶µªº Win64 API ³£¦b COMCTL32.DLL ¤º¡A¥H«áªº³¹¸`¦A¤¶²Ð¡C
¦b Windows §@·~¨t²Î¤¤¡A±±¨î¶µ¨ä¹ê´N¬O¤lµøµ¡¡C¤lµøµ¡¥²©w¦b¨ä¤÷µøµ¡ªº¤u§@°Ï¤º¡A·í¤÷µøµ¡³Q¾P·´®É¤lµøµ¡¤]³Q¾P·´¡C
¦b Windows §@·~¨t²Î¤¤¡An¦p¦ó«Ø¥ß±±¨î¶µ©O¡H¨ä¹ê¦³³\¦hºØ¤èªk¡A¥»³¹¥ý¤¶²Ð¤@ºØ¡C¦b»¡©ú¦p¦ó«Ø¥ß±±¨î¶µªº¦P®É¡A¤]»¡©ú±±¨î¶µªº¤@¨Ç¯S©Ê¡G
①¡Bº¥ýnª¾¹Dªº¬O¡A¤£½×¥Hþ¤@ºØ¤èªk©Ò«Ø¥ßªº±±¨î¶µ³£¬O¤lµøµ¡¡A¬JµM¬Oµøµ¡´N¥i¥H©I¥s CreateWindowEx «Ø¥ß¡C¦b«Ø¥ßµøµ¡®É¥²¶·«ü©wµøµ¡Ãþ§O¡]class¡^¡A±±¨î¶µªºÃþ§O³£¤w¸g¥Ñ Windows ¹w¥ý©w¸q¦n¤F¡A¨£¤Uªí¡CÀ³¥Îµ{¦¡¥u»Ý§â¤Uªíªºµøµ¡Ãþ§O©w¸q¦¨¥H¹sµ²§Àªº¦r¦ê¡A¤j¤p¼g¤£©ë¡A·í§@©I¥s CreateWindowEx ªº²Ä¤GӰѼƧY¥i¡C
±±¨î¶µ | µøµ¡Ãþ§O | »¡¡@¡@¡@©ú |
«ö¶s±±¨î¶µ | button | ¦bµøµ¡ùØÅã¥Ü¤@Óªø¤è§Î°Ï°ì·í§@«ö¶s¡A¨Ï¥ÎªÌ¥i¥H«ö¤U«ö¶s©ÎÃP¶}«ö¶s¡C |
½s¿è®Ø±±¨î¶µ | edit | ¦bµøµ¡ùثإߤ@Ó½s¿è®Øªº¤lµøµ¡¡A¥i¥HÅý¨Ï¥ÎªÌ¿é¤J¤å¦r©Î¼Æ¦r¡C |
ÀRºA±±¨î¶µ | static | «Ø¥ß¤@Óªø¤è§Î°Ï°ìªº¤lµøµ¡¡A¥i¥HÅã¥Ü¦r¦ê¡A³oºØ¤lµøµ¡µLªkÅý¨Ï¥ÎªÌ°µ¿é¥X¿é¤J°Ê§@¡C |
²M³æ±±¨î¶µ | listbox | «Ø¥ß¤@¶ôªø¤è§Î°Ï°ì¡A¨ä¤¤¦³³\¦h¦r¦ê¥i¨Ñ¨Ï¥ÎªÌ¿ï¾Ü¡A¨Ò¦p¶}±ÒÀÉ®×®ÉÅã¥Ü²{¦³Àɮתº¤lµøµ¡¡C |
¤U©Ô¦¡¤è¶ô±±¨î¶µ | combobox | ¬O½s¿è®Ø©M²M³æªºµ²¦X¡A³q±`¦³¤@¶ô°Ï°ìÅã¥Ü²M³æ¨Ñ¨Ï¥ÎªÌ¿ï¾Ü¡A©ÎªÌ«ö¤U¥kÃ䪺¤U©Ô¶s«á¤~Åã¥Ü²M³æ¡C |
±²°Ê¶b±±¨î¶µ | scrollbar | ¤@ªø±ø§Îªº°Ï°ì¡A¤W±¦³¤@·Æ°Ê±ì¥i¨Ñ¨Ï¥ÎªÌ©ì°Ê¦¹·Æ°Ê±ì¨Ó¿ï¾Ü¾A·íªº¼ÆÈ¡A¨Ò¦p½Õ¾ãµ¶qªº¤j¤p¡C |
¥Ñ¤Wªí¥iª¾¡G¤£¦Pªº±±¨î¶µ¨ã¦³¤£¦PªºÃþ§O¡A¬Û¦Pªº±±¨î¶µ¦³¬Û¦PªºÃþ§O¡C¨Ò¦p«ö¶s±±¨î¶µ¡A¾Þ§@¤è¦¡»P¥~Æ[³£¤j¦P¤p²§¡A¦ý»PÀRºA±±¨î¶µ´NºIµM¤£¦P¡C
②¡BCreateWindowEx ªºì«¬¦p¤U¡G
invoke CreateWindowEx,\ dwExStyle,\ ; extended window style lpClassName,\ ; pointer to registered class name lpWindowName,\ ; pointer to window name dwStyle,\ ; window style x,\ ; horizontal position of window y,\ ; vertical position of window nWidth,\ ; window width nHeight,\ ; window height hWndParent,\ ; handle to parent or owner window hMenu,\ ; handle to menu, or child-window identifier hInstance,\ ; handle to application instance lpParam ; pointer to window-creation data
¦b©I¥s CreateWindowEx «Ø¥ß±±¨î¶µ®É¡A¥²¶·ª`·N¤U±´X¥ó¨Æ¡G
©³¤U¥ý¬ÝÓ¨Ò¤l¡C¥»³¹¤@¶}©lªº¹Ï¤ù¬O¤@Ó¡u¬O§_¶|¦~¡H¡vªºµøµ¡¡A¨ä¤ºªº¡u¿é¤J¦è¤¸¦~¥÷¡G¡v¬OÀRºA±±¨î¶µ¡A°²¦pn«Ø¥ß¦¹ÀRºA±±¨î¶µ¡Aµ{¦¡¦p¤U¡G
IDS_ASK EQU 8000 szAskYear DB "¿é¤J¦è¤¸¦~¥÷¡G",0 szClassStatic DB "STATIC",0 ⁝ invoke CreateWindowEx,0,OFFSET szClassStatic,OFFSET szAskYear,\ WS_CHILD or WS_VISIBLE,16,10,108,28,hWnd,IDS_ASK,hInstance,0
Ãþ§O¦WºÙ¬O©w¸q¦b szClassStatic ÅܼƤ¤¡A¤º®e¬O¡u"STATIC",0¡v¡A¤j¤p¼gµL©Ò¿×¡A¥¦¬O Windows ¤º«ØªºÃþ§O¡C²Ä¤TӰѼƬOÅã¥Ü¦bÀRºA±±¨î¶µªº¤å¦r¡A¥¦¬O¥H¹sµ²§Àªº¦r¦ê¡CIDS_ASK ¬OÀRºA±±¨î¶µªºÃѧO½X¡C
·í¨Ï¥ÎªÌÂIÀ»¥\¯àªí¿ï¶µ¡B§U¾ÐÁä¡B±±¨î¶µ¡B¥[³tÁä®É¡A¨t²Î³£·|§â WM_COMMAND °T®§¶Çµ¹µøµ¡¨ç¦¡¡A¦p¤Uªí¡G
¨Æ¥ó | wParam | lParam | |
16¡ã31 ¦ì¤¸ | 0¡ã15 ¦ì¤¸ | ||
¨Ï¥ÎªÌÂIÀ»¿ï¶µ ©Î«ö¤U§U¾ÐÁä | 0 | ¿ï¶µÃѧO½X | 0 |
¨Ï¥ÎªÌ«ö¤U¥[³tÁä | 1 | ¥[³tÁäÃѧO½X | 0 |
¨Ï¥ÎªÌÂIÀ»±±¨î¶µ | ³qª¾½X | ±±¨î¶µÃѧO½X | ±±¨î¶µ¥N½X |
²{¦b¶È»¡©ú±±¨î¶µ¡C·í¨Ï¥ÎªÌ¾Þ§@±±¨î¶µ©Î±±¨î¶µª¬ºA§ïÅܮɡA¤÷µøµ¡´N·|¦¬¨ì±±¨î¶µ¶Ç¨Óªº WM_COMMAND °T®§¡A¦b¦¹°T®§¤¤¡AwParam ªº 16¡ã31 ¦ì¤¸¬O³qª¾½X¡]notifications¡^¡A0¡ã15 ¦ì¤¸¬O±±¨î¶µªºÃѧO½X¡AlParam ¬O±±¨î¶µ¥N½X¡C·í¨Ï¥ÎªÌ¹ï±±¨î¶µ¶i¦æ¾Þ§@·|¥Í¦¨³qª¾½X¡A©Î¬O±±¨î¶µªºª¬ºA§ïÅܤ]·|²£¥Í³qª¾½X¡C
¨Ò¦p·í¨Ï¥ÎªÌ¥H·Æ¹«¥ªÁäÂIÀ»«ö¶s¡A«ö¶sµo¥X BN_CLICKED ³qª¾½X¡F¦pªG¬OÀ£µÛ«ö¶s¤£©ñ¡A«hµo¥X BN_PUSHED ³qª¾½X¡FÃP¶}«ö¶s®É¡A¦¬¨ì BN_UNPUSHED ³qª¾½X¡C¦ý¬O¦pªG¨Ï¥ÎªÌÂIÀ»¨ã¦³ SS_NOTIFY ·®æªºÀRºA±±¨î¶µ¡A«hµo¥X STN_CLICKED ³qª¾½X¡CÀ³¥Îµ{¦¡¥i¥HÂǥѤ£¦Pªº³qª¾½X¡A³]pµ{¦¡¸Ó¦p¦ó¦^À³¨Ï¥ÎªÌªº¾Þ§@¡C
©³¤U³v¤@»¡©úÀRºA±±¨î¶µ¡B«ö¶s±±¨î¶µ»P½s¿è®Ø±±¨î¶µ¡C
ÀRºA±±¨î¶µ¤§©Ò¥HºÙ¬°ÀRºAªºì¦]¡A¬O¦]¬°¥¦¤£±µ¦¬·Æ¹«©ÎÁä½L¿é¤J¡A¤]¤£¦V¤÷µøµ¡µo°e WM_COMMAND °T®§¡A°£«D¬O¨ã¦³ SS_NOTIFY ·®æ¡C¤j³¡¤Àªº±¡ªp¤U¡AÀRºA±±¨î¶µ¥u¬O¥Î¨Ó´£¥Ü¨Ï¥ÎªÌ¿é¤J¸ê®Æ¡BÅã¥Üµ²ªG©Î¬O¬ü¤Æµe±¡C
¨Ì¾ÚÀRºA±±¨î¶µªº¥~Æ[¡A¤jP¤À¬°¥H¤U¥|ºØÃþ«¬¡G①²³æ¹Ï§ÎÀRºA±±¨î¶µ¡B②¤å¦rÀRºA±±¨î¶µ¡B③¹Ï®×ÀRºA±±¨î¶µ¡B④¾Ö¦³ªÌø»sªºÀRºA±±¨î¶µ¡CÄÝ©óþºØÃþ«¬¬O¥ÑÀRºA±±¨î¶µªº·®æ¨M©w¡C
²³æ¹Ï§ÎªºÀRºA±±¨î¶µ·|Åã¥Ü¥~®Ø¡B¶ñ¥R¯x§Î¡C¥~®Ø¥i¥H¥Î¤Ö³\ÃC¦âø»s¡A¹³¬O¶Â¦â¡B¦Ç¦â©Î¥Õ¦â¡C¦¹¥~¡A¥i¥H¥Î¥b¥W³´ªº¥~®Ø¡A¨Ï¨ä¨ã¦³¥ßÅé¥~Æ[¡C
²³æ¹Ï§ÎªºÀRºA±±¨î¶µªº·®æ¦³¤U±´XºØ¡A¦P®É°Ñ¦Ò¥k¹Ï¡A¬°¤F¸û©öÆ[¹î¡A¥k¹ÏªºI´º¦â¨Ï¥Î²HÂŦâ¡G
ÅU¦W«ä¸q¡A¤å¦rÀRºA±±¶µ¤W±´N¶ÈÅã¥Ü¤å¦r¡C¨Ò¦p¥»³¹¤@¶}©lªº¹Ï¤ù¬O¤@Óµøµ¡¡A¨ä¤ºªº¡u¿é¤J¦è¤¸¦~¥÷¡G¡v»P¡u¦è¤¸2024¦~¬O¶|¦~¡C¡v³£ÄÝ©ó¤å¦rÀRºA±±¨î¶µ¡C¤å¦rÀRºA±±¨î¶µ¦³©³¤U´XºØ·®æ¡G
¹Ï®×ÀRºA±±¨î¶µ¥i¥HÅã¥Ü¦ì¤¸¹Ï¡B¹Ï¥Ü¡B´å¼Ðµ¥¹Ï®×¡A¦³¤U±´XºØ·®æ¡G
©³¤Uªº¨Ò¤l¡A·|¨Ï¹Ï®×ÀRºA±±¨î¶µÅã¥Ü¤@±i¬ü¤k¹Ï®×¡Cº¥ýn·Ç³Æ¤@±i¹Ï¤ùÀÉ¡ABEAUTY.BMP¡A¨Ã¦b¸ê·½´yzÀɤ¤©w¸q¡G
BTY BITMAP BEAUTY.BMP
µM«á¦b²Õ¦X»y¨¥ì©lµ{¦¡¤¤¡A¼¶¼g¤U±µ{¦¡½X¡G
IDS_Bty EQU 9000
szBty DB "BTY",0 ;»P¸ê·½´yzÀÉBITMAP°Ï¶ô¦WºÙ¬Û¦P
szClassStatic DB "STATIC",0
⁝
invoke CreateWindowEx,0,OFFSET szClassStatic,OFFSET szBty,\
WS_CHILD or WS_VISIBLE or SS_BITMAP,10,10,256,256,hWnd,IDS_Bty,hInstance,0
ÁöµM¤W±µ{¦¡«ü©wÀRºA±±¨î¶µ¤Ø¤o¬° 256¡Ñ256¡A¦ý¹ê»Ú¤W·|¥H BEAUTY.BMP ¹Ï®×Àɪº¤Ø¤o¬°·Ç¡C¦pªGÀ³¥Îµ{¦¡nÅܧóÀRºA±±¨î¶µªº¹Ï¤ù¡A¥i¥H©I¥s SendMessage¡A²Ä¤GӰѼƬ° STM_SETIMAGE¡A¨£¡u»PÀRºA±±¨î¶µ¦³Ãöªº°T®§¡v¡C
¨ã¦³ SS_OWNERDRAW ·®æªºÀRºA±±¨î¶µ¡A´N¬O¾Ö¦³ªÌø»sªºÀRºA±±¨î¶µ¡AÀ³¥Îµ{¦¡¥²¶·¦b³B²z WM_DRAWITEM °T®§®Éø»s³oºØÀRºA±±¨î¶µ¡C³oºØ±¡§Î¸ò²Ä¤Q¤K³¹¾Ö¦³ªÌø»sªº¿ï¶µÃþ¦ü¡C
¨ã¦³ SS_NOTIFY ·®æªºÀRºA±±¨î¶µ¡A¦b¨Ï¥ÎªÌ¥H·Æ¹«¥ªÁäÂIÀ»ÀRºA±±¨î¶µ®É¡BÂùÀ»®É¡B¸T¥Î®É¡B±Ò¥Î®É¡A¤À§O¹ï¤÷µøµ¡µo¥X STN_CLICKED¡BSTN_DBLCLK¡BSTN_DISABLE ¥H¤Î STN_ENABLE ³qª¾½X¡C³o¨Ç³qª¾½X·|¦¨¬° WM_COMMAND °T®§¤¤ wParam ªº²Ä 16¡ã31 ¦ì¤¸¡AÀ³¥Îµ{¦¡¥i¥H¦bµøµ¡¨ç¦¡¤¤³B²z³o¨Ç¨Æ¥ó¡CÀRºA±±¨î¶µ¦³ SS_NOTIFY ·®æ¡A·|µo¥X WM_COMMAND °T®§¡A¦ý³o¥u¬O¨ä¤¤¤@Ó±ø¥ó¡FÀRºA±±¨î¶µÁÙ¥²¶·¬O±Ò¥Îªº¡]enable¡^¡A¤~¯àµo¥X WM_COMMAND °T®§¡Cn±Ò¥Î©Î¸T¥Î¡]disable¡^ÀRºA±±¨î¶µ¡A¥i¥H©I¥s EnableWindow API¡C
À³¥Îµ{¦¡¥i¥H¹ïÀRºA±±¨î¶µµo¥X°T®§¡A¨Ó¨ú±o©Î³]©wÀRºA±±¨î¶µªº¸ê®Æ¡A³o¨Ç°T®§³£¥H¡uSTM_¡v¬°°_ÀY¡A¨ä¤¤ªº¡uST¡v¥Nªí static ªº·N«ä¡A¡uM¡v¥Nªí message¡C¤Uªí¬O»PÀRºA±±¨î¶µ¦³Ãöªº°T®§¡G
°T®§ | »¡©ú | wParam | lParam | ¦^¶ÇÈ |
STM_GETICON | Àò±o¨ã¦³ SS_ICON ·®æªºÀRºA±±¨î¶µ¹Ï¥Ü¥N½X | ¤£¨Ï¥Î¡AÀ³³]¬° 0 | ¤£¨Ï¥Î¡AÀ³³]¬° 0 | Y¦¨¥\¡A¦^¶ÇȬ°¹Ï¥Ü¥N½X¡FY¥¢±Ñ¡A¦^¶ÇȬ° 0 |
STM_SETICON | ³]©w¨ã¦³ SS_ICON ·®æªºÀRºA±±¨î¶µ¹Ï¥Ü¥N½X | ¹Ï¥Ü¥N½X | ¤£¨Ï¥Î¡AÀ³³]¬° 0 | Y¦¨¥\¡A¦^¶ÇȬ°ì¥ýªº¹Ï¥Ü¥N½X¡FY¥¢±Ñ¡A¦^¶ÇȬ° 0 |
STM_GETIMAGE | Àò±oÀRºA±±¨î¶µªº¦ì¤¸¹Ï¡B´å¼Ð¡B¼W±j«¬¹Ï¤¸¤å¥ó¡B¹Ï¥Ü¥N½X | n¨ú±oþºØÃþ«¬ªº¹Ï®×¡G IMAGE_BITMAP IMAGE_CURSOR IMAGE_ENHMETAFILE IMAGE_ICON | ¤£¨Ï¥Î¡AÀ³³]¬° 0 | Y¦¨¥\¡A¦^¶ÇȬ°¬Û¹ïÀ³ªº¦ì¤¸¹Ï¡B´å¼Ð¡B¼W±j«¬¹Ï¤¸¤å¥ó¡B¹Ï¥Ü¥N½X¡FY¥¢±Ñ¡A¦^¶ÇȬ° 0 |
STM_SETIMAGE | ³]©wÀRºA±±¨î¶µªº¦ì¤¸¹Ï¡B´å¼Ð¡B¼W±j«¬¹Ï¤¸¤å¥ó¡B¹Ï¥Ü | n³]©wþºØÃþ«¬ªº¹Ï®×¡G IMAGE_BITMAP IMAGE_CURSOR IMAGE_ENHMETAFILE IMAGE_ICON | ¬Û¹ïÀ³ wParam ªº¦ì¤¸¹Ï¡B´å¼Ð¡B¼W±j«¬¹Ï¤¸¤å¥ó¡B¹Ï¥Ü¥N½X | Y¦¨¥\¡A¦^¶ÇȬ°ì¥ý¬Û¹ïÀ³ªº¦ì¤¸¹Ï¡B´å¼Ð¡B¼W±j«¬¹Ï¤¸¤å¥ó¡B¹Ï¥Ü¥N½X¡FY¥¢±Ñ¡A¦^¶ÇȬ° 0 |
À³¥Îµ{¦¡¹ïÀRºA±±¨î¶µµo¥X°T®§¡A³£¬O©I¥s SendMessage API¡A²Ä¤@ӰѼƬOÀRºA±±¨î¶µ¥N½X¡A²Ä¤GӰѼƬO°T®§ºØÃþ¡A²Ä¤T¡B¥|ӰѼơAwParam¡BlParam¡A¤§È»P°T®§ºØÃþ¦³Ãö¡C¨Ò¦pnÀò±o¨ã¦³ SS_ICON ·®æªºÀRºA±±¨î¶µ¹Ï¥Ü¥N½X¡A¥i¥H¹ïÀRºA±±¨î¶µµo¥X STM_GETICON ©Î¬O STM_GETIMAGE °T®§¨ÏÀRºA±±¨î¶µ¶Ç¦^¹Ï¥Ü¥N½X¡Aµ{¦¡½X¦p¤U¡G
invoke SendMessage,hStatic,STM_GETICON,0,0 invoke SendMessage,hStatic,STM_GETIMAGE,IMAGE_ICON,0
©Ò±oªºµ²ªG¬O¤@¼Ëªº¡C¦ýnª`·Nªº¬O¡A¦pªGÀRºA±±¨î¶µ¤£¨ã¦³ SS_ICON ·®æªº¸Ü¡A´N·|µo¥Í¿ù»~¡C
¹ï©ó STM_GETIMAGE »P STM_SETIMAGE ¦Ó¨¥¡A¤]¬O¦p¦¹¡C¦pªGn¨ú±o©Î³]©wªºÀRºA±±¨î¶µ¡A¨ã¦³ SS_BITMAP¡A¨º»ò´N¥u¯à¨ú±o©Î³]©w¦ì¤¸¹Ï¡A¦pªG¬O¨ä¥LÃþ«¬ªº¹Ï®×´N·|µo¥Í¿ù»~¡A³o¤]´N¬O¦b¤Wªí¤¤¡A·|µù©ú¥²¶·¬O¬Û¹ïÀ³ªº¹Ï®×¡C§ó¸Ô²Óªº»¡¡AwParam ¬O¹Ï®×Ãþ«¬¡A¥i¥H¬O IMAGE_BITMAP¡BIMAGE_CURSOR¡BIMAGE_ENHMETAFILE¡BIMAGE_ICON¡A¤À§O¬OÀò±o©Î³]©w¦ì¤¸¹Ï¡B´å¼Ð¡B¼W±j«¬¹Ï¤¸¤å¥ó¡B¹Ï¥Üªº¥N½X¡F·íµM¡AÀRºA±±¨î¶µ¥²¶·n¨ã¦³¬ÛÃöªº·®æ¤~¥i¥H©I¥s¦¨¥\¡C
ÀRºA±±¨î¶µ¤]¯à±N°T®§¶Çµ¹¤÷µøµ¡¡A¤@¯ë¥¦¬°³qª¾½X¡]notifications¡^¡A¦Ó¤£ºÙ¬°°T®§¡]messages¡^¡F³qª¾½X³£¥H¡uSTN_¡v¬°°_ÀY¡A¥¦¬O¦]¬°¨Ï¥ÎªÌ©ÎÀ³¥Îµ{¦¡¾Þ§@ÀRºA±±¨î¶µ¡A¦Ó¨ÏÀRºA±±¨î¶µµo¥X WM_COMMAND °T®§§iª¾¤÷µ{¦¡¡A¦Ó¨Ï¤÷µ{¦¡¯à°µ¥X¬Û¹ïÀ³ªº°Ê§@¡C¨Æ¹ê¤W¡A¤£¥uÀRºA±±¨î¶µ¦p¦¹¡A«ö¶s¡B½s¿è®Ø¡K¡K¤]³£¦p¦¹¡A¥¦Ì³£·|§â³qª¾½X´O¦b WM_COMMAND °T®§¤¤¶Çµ¹¤÷µ{¦¡¡A¨ä wParam ªº²Ä 16¡ã31 ³£¬O³qª¾½X¡A²Ä 0¡ã15 ¦ì¤¸¬O±±¨î¶µªºÃѧO½X¡A¦Ó lParam «h¬O±±¨î¶µ¥N½X¡C
»PÀRºA±±¨î¶µ¬ÛÃöªº³qª¾½X¦³ STN_CLICKED¡BSTN_DBLCLK¡BSTN_DISABLE¡BSTN_ENABLE¡A¤À§O¬O·í¨Ï¥ÎªÌ¥H·Æ¹«¥ªÁäÂIÀ»ÀRºA±±¨î¶µ¡BÂùÀ»ÀRºA±±¨î¶µ¡BÀRºA±±¨î¶µ¸T¥Î¡B©Î±Ò¥Î®É©Òµo¥Xªº¡C¦ýnª`·Nªº¬O¡A¨Ã¤£¬O©Ò¦³ÀRºA±±¨î¶µ³£·|µo¥X³qª¾½X¡A¨ã¦³ SS_NOTIFY ·®æªºÀRºA±±¨î¶µ¤~¯àµo¥X³qª¾½X¡C
¸T¥Î¡]disable¡^©Î±Ò¥Î¡]enable¡^¬OÀRºA±±¨î¶µªº¨ä¤¤¨âºØª¬ºA¡A¥i¥H©I¥s EnableWindow API ¨Ó§ïÅܳo¨âºØª¬ºA¡C·íÀRºA±±¨î¶µ³B©ó¸T¥Îª¬ºA®É¡A·|¥H¦Ç¦â¦rªí²{¡A§Y¨Ï¨ã¦³ SS_NOTIFY ·®æ¤]¤£·|µo¥X WM_COMMAND °T®§¡C¥u¦³¨ã¦³ SS_NOTIFY ·®æªºÀRºA±±¨î¶µ¥B³B©ó±Ò¥Îª¬ºA¡A¤~·|µo¥X WM_COMMAND °T®§¡C
½s¿è®Ø±±¨î¶µ³q±`¬O¤@Ó¯x§Î°Ï°ì¡A¥i¨Ñ¨Ï¥ÎªÌ¥HÁä½L¿é¤J¤å¦r¡A¿é¤Jªº¤å¦r·|Åã¥Ü¦b½s¿è®Øªº¯x§Î¤§¤º¡C¦p¥»³¹¤@¶}©lªº¹Ï®×¤¤¡A¼Ð©ú¡u③¡vªº¯x§Î¡A´N¬O½s¿è®Ø¡A¨ä¤ºªº¡u2024¡v¬O¨Ï¥ÎªÌ¿é¤Jªº¤å¦r¡C
n«Ø¥ß½s¿è®Ø¤]¬O©I¥s CreateWindowEx¡A¦¹®É²Ä¤GӰѼƬ°Ãþ§O¦WºÙªº¦ì§}¡AÃþ§O¦WºÙ¬°¡u"EDIT",0¡v¡A¤j¤p¼g¤£©ë¡C²Ä¤TӰѼƬOÅã¥Ü¦b½s¿è®Ø¤º¹w³]ªº¦r¦ê¡AY¬° 0¡A¼Ð¥Ü½s¿è®Ø¤º¨S¦³¹w³]¦r¦ê¡CY CreateWindowEx ¦¨¥\°õ¦æ¡A´N¯à«Ø¥ß½s¿è®Ø¡C
¨CÓ½s¿è®Ø³£¥i¥H«ü©w¼ÆºØ·®æ¡A³£¥H¡uES_¡v¬°°_ÀY¡A¥¦¬O¡uedit style¡vªºÁY¼g¡C³o¨Ç·®æÅý½s¿è®ØÅã¥Ü¤£¦Pªº¥~Æ[©M¥\¯à¡A¨Ò¦p«ü©w½s¿è®Ø¬O³æ¦æ¤å¦rÁÙ¬O¦h¦æ¤å¦r¡B³o¨Ç¤å¦r¦p¦ó¹ï»ô¡A¬Æ¦Ü¬O§_Åã¥Ü¤å¦r¡C
©³¤U»¡©ú¤@¨Ç±`¥Îªº½s¿è®Ø·®æ¡G
¤ñ¸û¯S§Oªº¬O¡A½s¿è®Ø¨Ã¨S¦³¾Ö¦³ªÌø»sªº·®æ¡C¤j·§¬O¦]¬°½s¿è®Ønø»sªº¦æ¬°¥]§t¦r¤¸¿é¤J¡B¿ï¾Ü¡B°ª«GÅã¥Ü¡B±²°Êµ¥¥\¯à¡A³o¨Ç¥\¯à¹ï©ó½s¿è®Øªº¥¿±`¹B§@«Ü«n¡A¥æ¥ÑÀ³¥Îµ{¦¡¦Û¦æø»s©Î³B²z¡A¥i¯à·|¤zÂZ³o¨Ç®Ö¤ß¥\¯à¡C
À³¥Îµ{¦¡¥i¥H¹ï½s¿è®Øµo¥X°T®§¡A¦Ó½s¿è®Ø¤]¯à¹ïÀ³¥Îµ{¦¡µo¥X§t¦³³qª¾½Xªº WM_COMMAND °T®§¡AÅýÀ³¥Îµ{¦¡°µ¥X¬ÛÀ³ªº¦^À³¡A³oÂI¸òÀRºA±±¨î¶µ¤@¼Ë¡A¨Æ¹ê¤W¼Ð·Ç±±¨î¶µ³£¬O¦p¦¹¡CÀ³¥Îµ{¦¡¥i¥H¹ï½s¿è®Øµo¥X°T®§¡A³£¥H¡uEM_¡v¬°°_ÀY¡A¨ä¤¤¡uE¡v¥Nªí edit¡C½s¿è®Ø¤]¬O¤@ºØµøµ¡¡]¨ä¹ê´N¬O¤lµøµ¡¡^¡A©Ò¥H¦³¨Ç¥H¡uWM_¡v¬°°_ÀYªº°T®§¤]¯àµo°eµ¹½s¿è®Ø¡C¤£½×°_ÀY¬Oþ¤@ºØ^¤å¦r¥À¡A³o¨Ç°T®§³£¬O¥H SendMessage API ¶Çµ¹½s¿è®Ø¡C
½s¿è®Ø¤ñÀRºA±±¨î¶µªº¥\¯àÁÙ¦h¡A¤]«n±o¦h¡A©Ò¥H¨ä°T®§©Î³qª¾½X³£¤ñÀRºA±±¨î¶µ¦h±o¦h¡C¤Uªí¬O±`µo°eµ¹½s¿è®Ø°T®§¡Aªí¤¤¦C¥X¤F wParam¡BlParam¡A¥H¤Î¦^¶ÇÈ¡A¨ä¾lªº½Ð¬d¾\ MSDN¡C
°T®§ | »¡©ú | wParam | lParam | ¦^¶ÇÈ |
EM_SETPASSWORDCHAR | ³]©w±K½X¦r¤¸ | nÅã¥Ü±K½X¦r¤¸¡CY³]¬°¹s¡A«h½s¿è®Ø¥¢¥h ES_PASSWORD ·®æ | ¤£¨Ï¥Î¡AÀ³³]¬° 0 | µL |
EM_SETLIMITTEXT | ³]©w½s¿è®Ø³Ì¦h¯à®e¯Ç¦h¤Ö¦r ¤¸¡A»P EM_LIMITTEXT ¬Û¦P | ³Ì¦h¯à®e¯Çªº¦r¤¸Ó¼Æ¡A¤£§tµ²§Àªº¹s¡A¨£«á±»¡©ú | ¤£¨Ï¥Î¡AÀ³³]¬° 0 | µL |
EM_SETREADONLY | ³]©w½s¿è®Ø¥u¯àŪ¨ú©Î±N¦¹·®æ²¾°£ | Y¬° 1¡A³]©w°ßŪ¡F Y¬° 0¡A²¾°£°ßŪ | ¤£¨Ï¥Î¡AÀ³³]¬° 0 | ³]©w¦¨¥\¡A¦^¶ÇȬ° 1¡F ¥¢±Ñ¡A¦^¶ÇȬ° 0 |
WM_GETTEXTLENGTH | µøµ¡ªº¤å¦rªø«×¡]¥H¦r¤¸¬°³æ¦ì¡^¡A¸Ô²Ó±¡§Î¨£¤U±»¡©ú | ¤£¨Ï¥Î¡AÀ³³]¬° 0 | ¤£¨Ï¥Î¡AÀ³³]¬° 0 | ±±¨î¶µªº¤å¦rªø«×¡A¨Ã¤£¥]§tµ²§Àªº 0 |
EM_SETLIMITTEXT °T®§»P EM_LIMITTEXT ¬O¤@¼Ëªº¡AÀ³¥Îµ{¦¡§Q¥Î¦¹°T®§³]©w½s¿è®Ø³Ì¦h¯à®e¯Ç¦h¤Ö¦r¤¸¡C¨Ï¥Î¤è¦¡¬O©I¥s SendMessage¡A¦p¤U¡G
invoke SendMessage,hEdit,EM_SETLIMITTEXT,wParam,0
hEdit ¬On³]©wªº½s¿è®Ø¥N½X¡ClParam ¤£¨Ï¥Î¡AÀ³³]¬° 0¡CwParam ¬O¯à®e¯Çªº¦r¤¸Ó¼Æ¡A¦¹¼Æ¤£§tµ²§Àªº¹s¡A¦Ü©ó wParam ³Ì¦h¬°¦h¤Ö¡A»P Windows ª©¥»¤Î³æ¦æ©Î¦h¦æ¦³Ãö¡A°Ñ¦Ò¤Uªí¡C
¤£½×þ¤@ºØ Windows §@·~¨t²Î¡A¤]¤£½×³æ¦æ©Î¦h¦æ½s¿è®Ø¡Aè«Ø¥ß®É¹w³]ªº®e¶q¬O 30000 Ӧ줸²Õ¡]30000¡×7530H¡^¡C¦pªG»ÝnÂX¥R½s¿è®Øªº®e¶q®É¡A¨£¤Uªí¡G
¹w³]½s¿è®Ø®e¶q | ÂX¥R«á½s¿è®Ø³Ì¤j®e¶q | ||
Windows ª©¥» | ©Ò¦³ Windows ª©¥» | Windows 95/98/Me | Windows NT/2K/XP/¤Î¨ä¥H«áªºª©¥» |
³æ¦æ½s¿è®Ø | 7530H | 07FFEH | 07FFFFFFEH |
¦h¦æ½s¿è®Ø | 7530H | 0FFFFH | 0FFFFFFFFH |
¥H WM_GETTEXTLENGTH ¬°°Ñ¼Æ©I¥s SendMessage «áªº¦^¶ÇȬO½s¿è®Ø¤ºªº¤å¦rªø«×¡A¨Ã¤£¥]§tµ²§Àªº 0¡C¨Æ¹ê¤W¡A¥un¬Oµøµ¡³£¥i¥H¥Î¦¹ªk±o¨ìµøµ¡ªº¤å¦rªø«×¡A»¡©ú¦p¤U¡G
①¹ï½s¿è®Ø¦Ó¨¥¡A²Ä¤@ӰѼƬO½s¿è®Ø¥N½X¡AÀò±oªº¬O½s¿è®Ø¤º¤å¦rªºªø«×¡F
②¹ï¤U©Ô¦¡¤è¶ô¦Ó¨¥¡A²Ä¤@ӰѼƬO¤U©Ô¦¡¤è¶ô¥N½X¡AÀò±oªº¬O¤U©Ô¦¡¤è¶ô¤¤½s¿è®Ø¤ºªº¤å¦rªø«×¡F
③¹ï«ö¶s¦Ó¨¥¡A²Ä¤@ӰѼƬO«ö¶s¥N½X¡AÀò±oªº¬O«ö¶s¤W¤å¦rªºªø«×¡F
④¹ïÀRºA±±¨î¶µ¦Ó¨¥¡A²Ä¤@ӰѼƬOÀRºA±±¨î¶µ¥N½X¡AÀò±oªº¬O¨ä¤W¤å¦rªºªø«×¡F
⑤¹ï¨ä¥L¤@¯ëµøµ¡¦Ó¨¥¡A²Ä¤@ӰѼƬOµøµ¡¥N½X¡AÀò±oªº¬Oµøµ¡¼ÐÃDÄæ¤W¤å¦rªºªø«×¡C
nª`·Nªº¬O¡A¦´Áªº§@·~¨t²Î¡A¹³ Windows 95/98¡A¨ä¦r¤¸½s½X¤è¦¡¬OÂù¦ì¤¸²Õ¦r¤¸¶°¡]double-byte character set¡A²ºÙ¬° DBCS¡^¡A¨Ò¦p Big5¡BGBK µ¥³£ÄÝ©ó³oºØ½s½X¤è¦¡¡A¥¦Ìªº¤¤¤å¦r¬O¥H¨âӦ줸²Õ½s½X¡A¦Ó^¤å¦r¥À¬O¤@Ӧ줸²Õ¡C³oºØ±¡§Î¡AWM_GETTEXTLENGTH ªº¦^¶ÇÈ¥i¯à·|¤ñ¥¿½Tªº¤j¡C³o¬O¦]¬°¥¦Ì¬O¦r¤¸¦³¨Ç¬OÂù¦ì¤¸²Õ¡A¦³¨Ç¬O¤@Ӧ줸²Õ¡A¤£©ö§PÂ_¦³¦h¤ÖÓ¦r¤¸¡C
½s¿è®Øª¬ºA§ïÅܩΨä¥L¬Y¨Ç±¡§Î§ïÅܮɡA·|¹ï¤÷µøµ¡µo¥X WM_COMMAND °T®§¡A¦Ó¨ä¤¤ wParam ªº²Ä 16¡ã31 ¬O³qª¾½X¡A§i¶D¤÷µøµ¡¡A½s¿è®Øµo¥Í¤F¤°»ò¨Æ¡C½s¿è®Øªº³qª¾½X³£¥H¡uEN_¡v°_ÀY¡A¬O edit notification ªº·N«ä¡C¥H EN_SETFOCUS ¬°¨Ò¡A·í¨Ï¥ÎªÌ¥H·Æ¹«¥ªÁäÂIÀ»½s¿è®Ø®É¡A½s¿è®Ø´N·|±o¨ìÁä½L¿é¤JµJÂI¡A¦¹¨è·|µo¥X WM_COMMAND °T®§¡A¦Ó¨ä¤¤ wParam ªº²Ä 16¡ã31 ¬O EN_SETFOCUS ³qª¾½X¡A¦Ó wParam ªº²Ä 0¡ã15 ¦ì¤¸¬O½s¿è®ØªºÃѧO½X¡AlParam ¬O½s¿è®Øªº¥N½X¡C½s¿è®Ø¨ä¥Lªº³qª¾½X¤]³£¬O¦p¦¹¡A´N¥u¦³ wParam ªº²Ä 16¡ã31 ¬O¤£¦Pªº³qª¾½X¡AwParam ²Ä 0¡ã15 ¦ì¤¸§¡¬°½s¿è®ØÃѧO½X¡BlParam §¡¬°½s¿è®Ø¥N½X¡C
¤Uªí¬O±`¥Îªº½s¿è®Ø³qª¾½X¡A»P¦b¤°»ò±¡§Î¤U·|µo¥Í³oºØ³qª¾½X¡C¨Æ¹ê¤W¡A½s¿è®Øªº³qª¾½X«Ü¦h¡A©³¤U¶È¦C¥X¤@¤p³¡¤À¡A¨ä¾lªº½Ð¬d¾\ MSDN¡C
³qª¾½X | ¼ÆÈ | »¡©ú |
EN_SETFOCUS | 100H | ½s¿è®Ø±o¨ì¿é¤JµJÂI |
EN_KILLFOCUS | 200H | ½s¿è®Ø¥¢¥h¿é¤JµJÂI |
EN_CHANGE | 300H | ·í½s¿è®Ø¤ºªº¤å¦rÅÜ°Ê¡A¥B¤w¸gÅã¥Ü¦n·sªº¤º®e¤§«á¤~µo¥X¦¹³qª¾½X |
EN_UPDATE | 400H | ½s¿è®Ø¤w¹ï¤å¦r¶i¦æ¤F³]©w¦rÅé¡B¤j¤p¡BÃC¦â¡B¦æ¶Z¡B¹ï»ô¤è¦¡µ¥³B²z¤§«á¡A¦ý¦bÅã¥Ü¤å¦r¤§«e¡Aµo°e EN_UPDATE¡A¨Ï±o¦b¥²n®É¥i¥H½Õ¾ã½s¿è®Ø¤j¤p |
EN_ERRSPACE | 500H | ·í°O¾ÐÅ餣¨¬¡AµLªk¤À°t¨¬°÷ªº°O¾ÐÅé¨Ó·s¼W¤å¦r¡B§R°£¤å¦rµ¥½Ð¨D®É¡Aµo¥X¦¹³qª¾½X |
«ö¶s¨Ì¥~Æ[¦³³\¦hºØÃþ«¬¡A¤£¦PªºÃþ«¬¡A¥~Æ[»P¥\¯à¤]¤£¦P¡A³o³£¬O¦]¨ä·®æ³y¦¨ªº¡C¤U¹Ïªºµøµ¡¬O¦b Windows 7 °õ¦æªºÀ³¥Îµ{¦¡²£¥Íªº¡A¨ä¤ºªº±±¨î¶µ³£¬O¤£¦P·®æªº«ö¶s¡C
¥k¤U¹Ï¤¤³Ì¤U±ªº¡u¨ú®ø¡v¬O¡u¤UÀ£¦¡«ö¶s¡v¡A¨ã¦³ BS_PUSHBUTTON ·®æ¡A¬O³Ì±`¨Ï¥Îªº«ö¶s¡C¥¦¬O¥ßÅé¬ð¥Xªº¯x§Î¡A¤º¦³¤å¦r©Î¹Ï®×¡F·í¨Ï¥ÎªÌ¥H·Æ¹«¥ªÁäÂIÀ»®É¡A¥i¥H°õ¦æ¬Y¨Ç¥\¯à¡C¦b¥¦¥kÃ䪺¬O¡u½T©w¡v«ö¶s¡A¥~Æ[»P¡u¨ú®ø¡v«ö¶sÃþ¦ü¡A¦ý¥~®Øªþªñ¥H°ª«G«×¤£¦P©ó¥|©PªºÃC¦âÅã¥Ü¡A³o¬O¡u¹w³]¤UÀ£¦¡«ö¶s¡v¡A¨ã¦³ BS_DEFPUSHBUTTON ·®æ¡C¦pªG¥¦¦b¹ï¸Ü²°¤º¦Ó¨Ï¥ÎªÌ¤S«ö¤U Enter Áä®É¡A´N¬Û·í©ó¥H·Æ¹«¥ªÁäÂIÀ»¦¹«ö¶s¡F¦ý¦pªG¤£¦b¹ï¸Ü²°¤¤¡A´NµL¦¹®ÄªG¡C
¹Ï¤¤³Ì¤U±ÁÙ¦³Ó¡u½T©w¡v¬O¡u¥±«ö¶s¡v¡A¨ã¦³ BS_FLAT ·®æªº«ö¶s¡A¦b¥ý«eªº Windows ¤¤¡A¥¦¥~Æ[²¼ä¡A¨S¦³¬ð¥XªºÃä®Ø©Î³±¼v®ÄªG¡A¬Ý°_¨Ó¤ñ¸û«ó¥¡F¦ý¦b Windows 7 ¬Ý°_¨Ó»P¡u¤UÀ£¦¡«ö¶s¡v¤@¼Ë¡A¨S¤°»ò°Ï§O¡C
¦b¡uÂ÷¶}¡v«ö¶s¤W±¦³Ó¡u»¡©ú¡v«ö¶s¡A¦b¡u»¡©ú¡v¤å¦r«e¤è¦³Ó½b¸¹¡A¡u»¡©ú¡v¤å¦r¤U¤è¦³´X¦æ¤p¦r¶i¤@¨BÄÄ©ú¦¹«ö¶s¥Î³~¡A³o¬O¨ã¦³ BS_COMMANDLINK ·®æªº¡u«ü¥OÃì±µ«ö¶s¡v¡A¦b Windows Vista ¤Î¨ä«á±ªºª©¥»¤~´£¨Ñªº¡C«Ø¥ß¡u«ü¥OÃì±µ«ö¶s¡v®É¡A²Ä¤@¦æªº¤j¦rºÙ¬°¥D¼ÐÃD¡A¨ä¾l¦æ³£¬O¤p¦rºÙ¬°°Æ¼ÐÃD¡A¥D¼ÐÃD»P°Æ¼ÐÃD»Ý²Õ¦X°_¨Ó¦¨¬°¤@Ó¥H¹sµ²§Àªº¦r¦ê¡A¤¤¶¡¥H¡u\n¡v¤À¹j¥D¼ÐÃD»P°Æ¼ÐÃD¡A©I¥s CreateWindowEx ®É¦¹¦r¦ê¦ì§}¬°²Ä¤TӰѼơC·í¨Ï¥ÎªÌ¥H·Æ¹«¥ªÁäÂIÀ»¡u«ü¥OÃì±µ«ö¶s¡v®É¡Aµo¥X±a¦³ BN_CLICKED ªº WM_COMMAND °T®§¡C
¦b¡u»¡©ú¡v«ü¥OÃì±µ«ö¶s¤W¤è¦³¤@Ó¡uµeµ§¼e«×¡v«ö¶s¡A¥¦¦³¤@±ø¤À³Î½u¤Î¦V¤U½bÀY¡C·í¨Ï¥ÎªÌ¥H·Æ¹«¥ªÁäÂIÀ»¦V¤U½bÀY¡A·|¥X²{¥\¯àªí¨Ñ¨Ï¥ÎªÌ¿ï¾Ü¡C³oºØ«ö¶sºÙ¬°¡u¤U©Ô¦¡¤À³Î«ö¶s¡v¡A¨ã¦³ BS_SPLITBUTTON ·®æ¡A¬O¦b Windows Vista ¤Î¨ä«á±ªºª©¥»¤~´£¨Ñªº¡C¤ñ¸û¯S§Oªº¬O¡A¡u¤U©Ô¦¡¤À³Î«ö¶s¡v¤À¬°¥ª¡B¥k¨â³¡¤À¡A¨Ï¥ÎªÌÂIÀ»³o¨â³¡¤À²£¥Í¤£¦Pªº³qª¾½X¡C·í¨Ï¥ÎªÌÂIÀ»¥kÃ䪺¦V¤U½bÀY®É¡A·|§â WM_NOTIFY °T®§¶Çµ¹¤÷µøµ¡¡A¤÷µøµ¡¥²¶·¨Æ¥ý«Ø¥ß¦n¼u¥X¥\¯àªí¡AµM«á¦b³o®É©I¥s TrackPopupMenu Åã¥Ü¼u¥X¥\¯àªí¡C¨Ï¥ÎªÌ¦b¼u¥X¥\¯àªí¿ï©w¬Yӿﶵ®É¡A¤S·|¹ï¤÷µøµ¡µo¥X WM_COMMAND °T®§¡A¤÷µøµ¡¤~°µ¥X³B²z¡C³o«h WM_COMMAND ¨ä¹ê¬O¦]¬°¨Ï¥ÎªÌÂI¿ï¼u¥X¥\¯àªí¤¤ªº¿ï¶µ¦Óµo¥Xªº¡Cµù¤G¦³Ó²²¤ªº¨Ò¤l¡C·í¨Ï¥ÎªÌÂIÀ»¥ªÃä¤å¦r®É¡Aµo¥X³qª¾½X¬° BN_CLICKED ªº WM_COMMAND °T®§¡C
¥k¤W¹Ï¤¤³Ì¤W±¦³¨âӥΤñ¥|©PÃC¦âµy·L²`ªº®Ø®Ø³ò¦í¡A¨ä¤@¦W¬°¡uÃC¦â¡v¡A¥t¤@Ó¦W¬°¡u§A·Qµe¤°»ò¡H¡v¡A¦b¡uÃC¦â¡v®Ø®Ø¤U±ªº¬O¡uÀ˵ø¡v¡A¤]¥Î¦P¼ËÃC¦â®Ø¦í¡A³o¤TÓ³£¬O¡u¸s²Õ®Ø¡v¡A³£¨ã¦³ BS_GROUPBOX ·®æ¡C¤@¯ë¦Ó¨¥¡A¥¦Ì¬O§â¥\¯àÃþ¦ü©Î¬ÛÃöªº±±¨î¶µ³ò¦í¡AÅý¨Ï¥ÎªÌ·Pı³o¨Ç³ò¦íªº±±¨î¶µ¬O¦P¤@Ãþ¡C
¦b¡uÃC¦â¡v¸s²Õ®Ø¤º¦³¥|Ó¡u³æ¿ï«ö¶s¡v¡A¤À§O¬O¡u¶Â¦â¡v¡B¡u¬õ¦â¡v¡B¡uºñ¦â¡v¡B¡uÂŦâ¡v¡C¦b¥¦Ì«e±¦³Ó°é°é¨Ñ¨Ï¥ÎªÌ°é¿ï¡A¦pªG¿ï¤¤ªº°é°é¤¤¶¡·|¦³¹ê¤ß¶ê¡C·í¨Ï¥ÎªÌ¿ï¾Ü¨Ï¥Î¬YºØÃC¦âµe¹Ï¡A´NµLªk¦P®É¥Î¥t¥~¤@ºØÃC¦âµe¹Ï¡F·íµM¦b³o¥H«á¡A¨Ï¥ÎªÌ¥i¯à¿ï¥Î¥t¥~¤@ºØÃC¦â¡A³o®É´NµLªk¥Îì¨ÓªºÃC¦âµe¹Ï¡C¤]´N¬O»¡¦P¤@®É¶¡¤º¡A¥u¯à¥Î¤@ºØÃC¦âµe¹Ï¡C¹³³oºØ¥u¯à¨Ï¥Î¨ä¤¤¤@ºØªº±¡§Î¡AºÙ¬°¡u¤¬¥¸¡vªº¡A©ÎªÌºÙ¬°³æ¿ïªº¡C³oÃþ«ö¶s¨ã¦³ BS_RADIOBUTTON ©Î BS_AUTORADIOBUTTON ·®æ¡A¤À§OºÙ¬°¡u³æ¿ï«ö¶s¡v»P¡u¦Û°Ê³æ¿ï«ö¶s¡v¡C¥¦Ìªº®t§O¦b©ó·í¨Ï¥ÎªÌ§ïÅÜ°é¿ï®É¡ABS_RADIOBUTTON ¥²¶·¦Û¦æ¼¶¼gµ{¦¡¡AÅý°é¿ï¤¤ªº¹ê¤ß¶ê¥u¦b¤@³BÅã¥Ü¦Ó¨ä¥LªÅ¥Õ¡A¦ý BS_AUTORADIOBUTTON «h¦Û°Ê§¹¦¨¡C
¦pªGÀ³¥Îµ{¦¡«Ø¥ßªº¨Ã«D¡u¦Û°Ê³æ¿ï«ö¶s¡v¡A¨º»ò¨Ï¥ÎªÌ¿ï¾Ü¨ä¤¤¤@Ó¡A¦Ón±N¦¹«ö¶s«eªº°é°éµe¤W¹ê¤ß¶ê¡A¨ä¾lªÅ¥Õ¡A¥i¥H©I¥s CheckRadioButton §¹¦¨¡C
¡uÀ˵ø¡v¤]¬O¤@Ó¸s²Õ®Ø¡A¦ý¨ä¤ºªº¡uÅã¥ÜÃC¦â¡v¡B¡uÅã¥Ü©Òµe¹Ï§Î¡v¡B¡uÅã¥Üµeµ§¼e«×¡vµ¥¬O¥Î¨Ó¦bª¬ºA¦CÅã¥Ü¸ê°T¡C¥¦Ì«e±¦³¤è§Î®Ø®Ø¡A¥i¨Ñ¨Ï¥ÎªÌ¤Ä¿ï¡A¦pªG¿ï¤¤ªº·|¦b®Ø®Ø¤º¥´¤Ä¡A¤Ä¿ï¨ä¤¤¤@¶µ»P¬O§_¤Ä¿ï¨ä¥¦¶µ¨Ã¤£¬Û¤z¡C©Ò¥H¥i¥H¥þ¤£¿ï¡B¿ï¨ä¤¤¥ô¤@Ó¡B©Î¥ô¨âÓ¡B©Î¥þ¿ï¡A¬GºÙ¬°¡u½Æ¿ï®Ø¡v©Î¡u¦Û°Ê½Æ¿ï®Ø¡v¡C«eªÌ¨ã¦³ BS_CHECKBOX ·®æ¡A«áªÌ¨ã¦³ BS_AUTOCHECKBOX ·®æ¡C®t§O¬O¡A·í¨Ï¥ÎªÌ¿ï¤¤«á¡A«áªÌ¯à¦Û°Êµe¤Ä¤Ä¡A¦Ó«eªÌ»Ýn¦Û¦æ¥Hµ{¦¡×§ï¡C
¦b¡uÀ˵ø¡v¸s²Õ®Ø¤U¤è¦³¤@Ó¡u¥þ³¡Åã¥Ü¡v«ö¶s¡A³o¬O¡u¤TºA«ö¶s¡v¡C¡u¤TºA«ö¶s¡v¬O¨ã¦³ BS_3STATE ·®æªº«ö¶s¡A¬O¤@ºØ¯S®íªº½Æ¿ï®Ø¡A¤TºA¬O«ü¤Ä¿ï¡B¤£½T©w¡B¨S¤Ä¿ï¤TºØ±¡§Î¡A«e±ªº¤è®Ø¤º¤À§O¥Î¤Ä¤Ä¡B¤è¶ô¡BªÅ¥Õªí¥Ü¡C¦ý¦pªG¨S¦³¾A·íµ{¦¡½X°t¦X¡AµL½×§A«ç»ò¥Î¤O¥H·Æ¹«¥ªÁäÂIÀ»¡A¤]³£²@µL®ÄªG¡C¥t¥~¤]¦³¡u¦Û°Ê¤TºA«ö¶s¡v¡A¬O¨ã¦³ BS_AUTO3STATE ·®æªº«ö¶s¡A¤£¶·ÃB¥~µ{¦¡½X°t¦X¡A¨CÂIÀ»¤@¦¸¤è®Ø´N½ü¬y¦b¤Ä¤Ä¡B¤è¶ô¡BªÅ¥Õ¶¡¤Á´«¡C
¹ê»ÚÀ³¥Î¤W¡A¦b¦³³\¦h¶µ¥Øn¿ï¾Ü®É¡A¦pªG¥þ¿ï¡B¥þ¤£¿ï©Î¿ï¾Ü¨ä¤¤¤@¨Ç¦Ó¥t¤@¨Ç¤£¿ï®É¡A´N¥i¥H¥Î¡u¤TºA«ö¶s¡v¤è«K¹F¦¨¡C¨Ò¦p¤W¹ÏªºÀ˵ø¸s²Õ®Ø¡A¥i¥H¿ï¾Ü¬O§_Åã¥ÜÃC¦â¡B¬O§_Åã¥Üµe¥X¦óºØ¹Ï§Î¡B¬O§_Åã¥Üµeµ§¼e«×¡C¦pªG¤TªÌ³£nÅã¥Ü¥i¥H«ö¡u¤TºA«ö¶s¡vª½¨ì¥X²{¤Ä¤Ä¡F¦pªG¤TªÌ³£¤£Åã¥Ü¥i¥H«ö¡u¤TºA«ö¶s¡vª½¨ì¥X²{ªÅ¥Õ¡F¦pªG¦³¨ÇnÅã¥Ü¡B¦³¨Ç¤£Åã¥Ü¡A¥i¥H«ö¡u¤TºA«ö¶s¡vª½¨ìÅã²{¤è¶ô¡C¦p¤W¹Ï¤¤ªºÅã¥Ü¥þ³¡¤TºA«ö¶s¤¤ªº´N¬OÅã²{¤è¶ô¡A¦]¬°¥u¿ï¤F«e¨â¶µ¡AÅã¥ÜÃC¦â©MÅã¥Ü©Òµe¹Ï§Î¡A³Ì«á¤@¶µÅã¥Üµeµ§¼e«×«h¤£Åã¥Ü¡C
«ö¶sªº·®æ¤¤¤]¦³ BS_OWNERDRAW¡A¥ç§Y¡u¾Ö¦³ªÌø»s«ö¶s¡v¡A§¹¥þ¥Ñ¤÷µøµ¡¶i¦æø»s¡A¥²¶·¦b³B²z WM_DRAWITEM °T®§®É¶i¦æø»s¡C³oì²z¸ò²Ä¤Q¤K³¹¾Ö¦³ªÌø»sªº¿ï¶µÃþ¦ü¡AŪªÌ¥iÁ|¤@¤Ï¤T¸Õ¸Õ¬Ý¼¶¼g¡u¾Ö¦³ªÌø»s«ö¶s¡v¡C
©³¤UÁÙ¦³¤@¨Ç·®æ¡A¨Ã¤£¬O³y¦¨¤£¦PÃþ«¬ªº«ö¶s¡A¤]¤@¨Ö»¡©ú¡C
BS_LEFT¡BBS_CENTER¡BBS_RIGHT ¨Ï«ö¶sªº¤å¦r¦V¥ª¹ï»ô¡B¤ô¥¸m¤¤¡B¦V¥k¹ï»ô¡A¹w³]ȬO BS_CENTER¡F¦pªG¬O³æ¿ï«ö¶s©Î½Æ¿ï®Ø¡A¨ä¤¤ªº°é°é©Î®Ø®Ø¤´¦b³Ì¥ªÃä¡A³Ñ¾lªº«ö¶s½d³ò¤~µ¹¤å¦r¨Ï¥Î¡F¸s²Õ®Ø¤]·|¨ü¨ì BS_LEFT¡BBS_CENTER¡BBS_RIGHT ªº¼vÅT¡A¦ý¬O«ü¥OÃì±µ«ö¶s¨Ã¤£¨ü³o¤TºØ·®æªº¼vÅT¡CBS_RIGHTBUTTON »P BS_LEFTTEXT ¥u¼vÅT³æ¿ï«ö¶s©Î½Æ¿ï®Ø¡A¨Ï¨ä¤å¦r¦b«ö¶s½d³òªº³Ì¥ªÃä¡A°é°é©Î®Ø®Ø¦b³Ì¥kÃä¡C
BS_TOP¡BBS_VCENTER¡BBS_BOTTOM ¨Ï«ö¶sªº¤å¦r¦V¤W¹ï»ô¡B¹]Áè¸m¤¤¡B¦V¤U¹ï»ô¡A¹w³]ȬO BS_VCENTER¡C¸s²Õ®Ø»P«ü¥OÃì±µ«ö¶s¨Ã¤£·|¨ü¨ì³o¤TºØ·®æªº¼vÅT¡C
BS_MULTILINE ¬O¦h¦æ«ö¶s¡A¦pªG¤å¦r¤Óªø¸IIJ¨ì«ö¶sÃä¬É¡A¥i¥H´«¦æ¡C©Ò¦³ªº«ö¶sÃþ«¬³£¨ü BS_MULTILINE ¼vÅT¡A«ü¥OÃì±µ«ö¶s쥻´N¬O¦h¦æªº¡A¤£»Ý²K¥[ BS_MULTILINE ·®æ¡C
¨Ï¥Î BS_ICON ©Î BS_BITMAP ·®æªº«ö¶s¡A·|¦b«ö¶s¤WÅã¥Ü¹Ï¥Ü©Î¦ì¤¸¹Ï¡C¤èªk¬O¥ý¦b¸ê·½´yzÀÉ©w¸q¹Ï¥Ü©Î¦ì¤¸¹Ï¡FµM«á©I¥s LoadIcon ©Î LoadBitmap ±o¨ì¹Ï¥Ü©Î¦ì¤¸¹Ï¥N½X¡F¦A¥H§t¦³ BS_ICON ©Î BS_BITMAP ·®æ¬°°Ñ¼Æ©I¥s CreateWindowEx «Ø¥ß«ö¶s¡A±o¨ì«ö¶s¥N½X¡F³Ì«á¤@¨B©I¥s SendMessage §â BM_SETIMAGE °T®§¶Ç°eµ¹«ö¶s¡C
ÁÙ¦³¤@Ó«ö¶s·®æ BS_NOTIFY¡Aµy«á©ó¡u¦³Ãö«ö¶sªº³qª¾½X¡v»¡©ú¡C
«ö¶s¦³¤TºØª¬ºA¡G①¬O§_¦³¿é¤JµJÂI¡B②¬O§_³B©ó«öÀ£¡B③¬O§_¿ï¨ú¡C
·í¨Ï¥ÎªÌ¥H·Æ¹«¥ªÁäÂIÀ»«ö¶s¡B«ö Tab Áä©Î¤è¦VÁä«á«ö Enter Áä¡A¥i¥HÅý«ö¶sÀò±o¿é¤JµJÂI¡C¦ý¨Ã¤£¬O©Ò¦³Ãþ«¬ªº«ö¶s³£¯àÀò±o¿é¤JµJÂI¡A¥u¦³½Æ¿ï®Ø¡B³æ¿ï«ö¶s¡B«öÀ£¶s»P¾Ö¦³ªÌø»s«ö¶s¤~¯à±o¨ì¿é¤JµJÂI¡C¦P¤@Ӯɶ¡¡A¥u¦³¤@Ó±±¨î¶µ¨ã¦³¿é¤JµJÂI¡A·í¨Ï¥ÎªÌÂIÀ»¥t¤@Ó±±¨î¶µ¡A¿é¤JµJÂI«KÂಾ¨ì·sÂIÀ»ªº±±¨î¶µ¤W¡Aì¨Óªº±±¨î¶µ´N¥¢¥h¿é¤JµJÂI¡C·í«ö¶s¨ã¦³Áä½LµJÂI®É¡A³q±`·|¦³µê½u¥]³ò«ö¶sªº¤å¦r¡B¹Ï¥Ü©Î¦ì¤¸¹Ï¡A¦pªG¬O«öÀ£¶s«h·|¦³ÃC¦â¸û²`ªºÃä®Ø¡C
«öÀ£¶s¡B½Æ¿ï®Ø¡B³æ¿ï«ö¶s¨ã¦³«öÀ£ª¬ºA¡A¨ä¥L«ö¶sµL¦¹ª¬ºA¡C«ö¶sªº«öÀ£ª¬ºA¥i¥H¬O«ö¤U©Î¥¼«ö¤U¡C·í«ö¤U«öÀ£¶s®É¡A«öÀ£¶s·|Åܬ°¥W¤Uªº«ö¶s¡FÃP¶}®ÉÅܦ¨¥¼«ö¤Uª¬ºA¡AÅܦ¨¥Y°_ªº¡C·í½Æ¿ï®Ø¡B³æ¿ï«ö¶s³Q«ö¤U®É¡AI´º·|ÅܦǡF¥¼«ö¤U®É¡A«ö¶sªºI´º¤£·|ÅܦǡC
¥u¦³½Æ¿ï®Ø¡B³æ¿ï«ö¶s¤~¨ã¦³¿ï¨úª¬ºA¡C³Q¿ï¨úªº½Æ¿ï®Ø©Î³æ¿ï«ö¶s¡A¤À§O·|¦b«e±ªº®Ø®Ø©Î¶ê°éÅã¥Ü¤Ä¤Ä©Î¹ê¤ß¶ê¡F¥¼³Q¿ï¨úªº«h¬OªÅ¥Õ¡C¤TºA«ö¶s¦h¤F¤@ºØª¬ºA¡A«e±¤w¸g´£¹L¡C
¨Ï¥ÎªÌ³Ì±`¹ï«ö¶s°µªº°Ê§@¬O¡A¥H·Æ¹«¥ªÁäÂIÀ»«ö¶s®É¡A³o®É·|µo¥X±a¦³ BN_CLICKED ³qª¾½Xªº WM_COMMAND °T®§µ¹¤÷µøµ¡¡A¦¹°T®§ªº wParam ²Ä 0¡ã15 ¦ì¤¸¬O«ö¶sÃѧO½X¡A16¡ã31 ¦ì¤¸´N¬O BN_CLICKED ³qª¾½X¡A¦Ó lParam ¬O«ö¶s¥N½X¡C¤÷µøµ¡ªºµøµ¡¨ç¦¡¥i¥H¨Ì¾Ú BN_CLICKED ¦Ó°µ¥X³B²z¡CµL½×¦óºØÃþ«¬ªº«ö¶s¡A³£·|µo¥X BN_CLICKED¡C
°£¤F¹ï«ö¶sÂIÀ»·|µo¥X³qª¾½X¤§¥~¡A¨ä¥L¹ï«ö¶sª¬ºAªº§ïÅܩΰʧ@¤]·|µo¥X³qª¾½X¡A³qª¾½X³£¦b WM_COMMAND °T®§ wParam ªº²Ä 16¡ã31 ¦ì¤¸¡A¨ä¾l³£¸ò BN_CLICK ¤@¼Ë¡A°£¤F BCN_HOTITEMCHANGE ¥H¥~¡C¤Uªí¬O«ö¶s·|²£¥Íªº³qª¾½X¥H¤Î»¡©ú¡G
³qª¾½X | ¼ÆÈ | »¡©ú |
BN_CLICKED | 0 | ¥H·Æ¹«ÂIÀ»«ö¶s |
BN_DBLCLK | 5 | »P BN_DOUBLECLICKED ¦P¸q¡A¥H·Æ¹«ÂùÀ»«ö¶s |
BN_DISABLE | 4 | «ö¶s³Q¸T¥Î |
BN_PUSHED | 2 | »P BN_HILITE ¦P¸q¡AÀ£«ö«ö¶s |
BN_UNPUSHED | 3 | »P BN_UNHILITE ¦P¸q¡AÃP¶}«ö¶s |
BN_KILLFOCUS | 7 | «ö¶s¥¢¥h¤FÁä½LµJÂI |
BN_SETFOCUS | 6 | «ö¶sÀò±o¤FÁä½LµJÂI |
BN_PAINT | 1 | À³Ã¸»s«ö¶s«e |
BCN_HOTITEMCHANGE | -1249 | ·Æ¹«´å¼Ð²¾¶i©ÎÂ÷¶}«ö¶s |
¨Ï¥ÎªÌ¥H·Æ¹«¥ªÁäÂIÀ»«ö¶s¡A¬Ý¦ü«Ü³æ¯Âªº°Ê§@¡A¨Æ¹ê¤W«ö¶sª¬ºA´N¦³¼Æ¦¸ÅܤơCº¥ý¡A·Æ¹«ÂI¨ì«ö¶s®É¡A«ö¶s·|±o¨ì¿é¤JµJÂI¡A¦P®ÉÅܦ¨«ö¤Uª¬ºA¡Cª`·N¡IÂIÀ»ªº°Ê§@¥]§tÀ£¤U¡A±µµÛÃP¶}¡A©Ò¥H¨Ï¥ÎªÌÃP¶}¥ªÁä®É¡A«ö¶s¤SÅܦ¨¥¼«ö¤Uª¬ºA¡C¤j³¡¤Àªº®ÉÔ¡AÀ³¥Îµ{¦¡¨Ã¤£¦b·N³o¨Ç²Ó¸`¡A¥u¦b·NÂIÀ»ªº¾ãÅé°Ê§@¡A¦]¦¹¤j³¡¤À®ÉÔ Windows ¨Ã¤£»Ýn§â«ö¶sªº©Ò¦³°Ê§@³£³qª¾µ¹¤÷µøµ¡¡A°£¤F BN_CLICKED ¥H¥~¡C
¦pªG¯uªº»Ýn®É¡A¥i¥H¨Ï«ö¶s¥[¤W BS_NOTIFY ·®æ¡A³o¼Ëªº«ö¶s´N¯àµo¥X BN_DISABLE¡BBN_PUSHED¡BBN_UNPUSHED¡BBN_KILLFOCUS¡BBN_SETFOCUS ©M BN_PAINT ³qª¾½X¡C¹ï©ó BN_DBLCLK ³qª¾½X¡AWindows ªº³B¸m¬O¡A¥u¦³³æ¿ï«ö¶s¤Î¾Ö¦³ªÌø»s«ö¶s¯à¥D°Êµo¥X BN_DBLCLK ³qª¾½X¡A¨ä¾lÃþ«¬ªº«ö¶s³£¥²¶·n¨ã¦³ BS_NOTIFY ·®æ¡A¤~·|µo¥X BN_DBLCLK ³qª¾½X¡C
BCN_HOTITEMCHANGE ¬O¦b Windows XP ¤Î¨ä¥H«áªº¨t²Î¤~¦³ªº³qª¾½X¡CBCN_HOTITEMCHANGE ¨Ã¤£¬O¦ì©ó WM_COMMAND °T®§ wParam ªº²Ä 16¡ã31 ¦ì¤¸¡A³oÂI»P¨ä¥L³qª¾½X¤£¦P¡CBCN_HOTITEMCHANGE ¬Oªþ¦b WM_NOTIFY °T®§¤¤¡A¦¹°T®§¦³ÂI½ÆÂø¡A¥H«á¦A»¡¡C
¤÷µøµ¡¯à°÷©I¥s SendMessage §â°T®§¶Çµ¹«ö¶s¡AÂÇ¥HÀò±o¸ê®Æ©Î¾Þ§@«ö¶s¡C©³¤U¬O¯àÂÇ¥Ñ SendMessage ¶Ç°eµ¹«ö¶sªº°T®§¡G
°T®§ | »¡©ú | wParam | lParam | ¦^¶ÇÈ |
BM_GETCHECK | Àò±o³æ¿ï«ö¶s©Î½Æ¿ï®Ø¬O§_³Q¿ï¨ú | ¤£¨Ï¥Î¡AÀ³³]¬° 0 | ¤£¨Ï¥Î¡AÀ³³]¬° 0 | ¦^¶ÇȬO¤U±¤TºØ¨ä¤¤¤§¤@¡G BST_CHECKED¡G¿ï¨ú BST_INDETERMINATE¡G¤£½T©w BST_UNCHECKED¡G¥¼¿ï¨ú |
BM_SETCHECK | ³]©w³æ¿ï«ö¶s©Î½Æ¿ï®Ø¬O§_³Q¿ï¨ú | n³]©wªº¿ï¨úª¬ºA¡A¦³¤TºØ±¡§Î¡G BST_CHECKED¡G¿ï¨ú BST_INDETERMINATE¡G¤£½T©w BST_UNCHECKED¡G¥¼¿ï¨ú | ¤£¨Ï¥Î¡AÀ³³]¬° 0 | 0 |
BM_GETSTATE | Àò±o«ö¶sª¬ºA | ¤£¨Ï¥Î¡AÀ³³]¬° 0 | ¤£¨Ï¥Î¡AÀ³³]¬° 0 | ¦^¶ÇȦ³¤U±´XºØ±¡§Î¡G BST_CHECKED¡G¤w¿ï¨ú BST_DROPDOWNPUSHED¡G³B©ó¤U©Ôª¬ºA¡A¶È¤U ¡@¡@¡@¡@¡@¡@¡@¡@¡@¡@¡@¡@¡@©Ô¦¡¤À³Î«ö¶s¤~¾A¥Î BST_FOCUS¡G«ö¶s¨ã¦³¿é¤JµJÂI BST_HOT¡G«ö¶s³B©ó§@¥Î¤¤ª¬ºA¡A¤]´N¬O»¡¡A·Æ ¡@¡@¡@¡@¡@ ¹«°±¯d¦b¤W¤è BST_INDETERMINATE¡G«ö¶s³B©ó¿ï¨ú¤£½T©wª¬ ¡@¡@¡@¡@¡@¡@¡@¡@¡@¡@¡@ºA¡A¶È¥Î©ó¤TºA«ö¶s BST_PUSHED¡G«ö¶s³B©ó³QÀ£¤Uª¬ºA BST_UNCHECKED¡G¨S¦³¯S®íª¬ºA¡A¬Û·í©ó¹s |
BM_SETSTATE | §ïÅÜ«ö¶sªº«öÀ£ª¬ºA | Y¬° 1¡Aªí¥ÜÀ£¤U«ö¶s Y¬° 0¡Aªí¥ÜÃP¶}«ö¶s | ¤£¨Ï¥Î¡AÀ³³]¬° 0 | µL |
BM_SETSTYLE | §ïÅÜ«ö¶s·®æ | ·sªº·®æ | Y¬° 1¡A«·sø»s«ö¶s Y¬° 0¡A¤£«·sø»s | µL |
BM_SETIMAGE | ³]©w«ö¶sªº¹Ï¥Ü©Î¦ì¤¸¹Ï | ¥i¥H¬O IMAGE_BITMAP ©Î IMAGE_ICON | ¨Ì¾Ú wParam¡AlParam ¬°¦ì¤¸¹Ï¥N½X©Î¹Ï¥Ü¥N½X | ì¥ýªº¦ì¤¸¹Ï¥N½X©Î¹Ï¥Ü¥N½X¡AYì¨Ó©|¥¼³]©w«h¦^¶ÇȬ° 0¡]°Ñ¦Òµù¤@¡^ |
BM_GETIMAGE | ¨ú±o«ö¶sªº¦ì¤¸¹Ï©Î¹Ï¥Ü¥N½X | ¥i¥H¬O IMAGE_BITMAP ©Î IMAGE_ICON | ¤£¨Ï¥Î¡AÀ³³]¬° 0 | ¨Ì¾Ú wParam¡A¦^¶ÇȬ°¦ì¤¸¹Ï©Î¹Ï¥Ü¥N½X |
BM_CLICK | ¼ÒÀÀ¨Ï¥ÎªÌÂIÀ»«ö¶s | ¤£¨Ï¥Î¡AÀ³³]¬° 0 | ¤£¨Ï¥Î¡AÀ³³]¬° 0 | µL |
BM_CLICK ·|¨Ï«ö¶s±µ¦¬ WM_LBUTTONDOWN ©M WM_LBUTTONUP °T®§¡A¨Ã¥B«ö¶sªº¤÷µøµ¡±µ¦¬±a¦³ BN_CLICKED ³qª¾½Xªº WM_COMMAND °T®§¡C
³oÓ¨Ò¤l¬O¦b¤@µøµ¡¤º¡A«Ø¥ß¤TºØÃþ§O¤Ó±±¨î¶µ¡A¨ä¤¤¨âÓ¬OÀRºA±±¶µ¡B¤@Ó½s¿è®Ø¥H¤Î¨âÓ«ö¶s¡C°õ¦æ®Éµe±¦p¥k¡A¨Ï¥ÎªÌ²Ä¤@¦¸¥H·Æ¹«¥ªÁäÂIÀ»½s¿è®Ø®É¡A·|¥X²{¥u¯à¿é¤Jªü©Ô§B¼Æ¦rªº´£¥Ü¹ï¸Ü²°¡A«ö¡u½T©w¡v«ö¶sÂ÷¶}´£¥Ü¹ï¸Ü²°¡A¥H«á´N¤£¦A¥X²{¤F¡Cµ¥¨Ï¥ÎªÌ¿é¤J¦n¦è¤¸¦~¥÷¤§«á¡A¦A«ö¡u¬d¸ß¡v«ö¶s¡A¤U±ªºÀRºA±±¨î¶µ·|Åã¥Ü¸Ó¦~¬°¶|¦~ÁÙ¬O¥¦~¡C¨Ï¥ÎªÌ¤]¥i¥H¥Î·Æ¹«¥ªÁäÂIÀ»¤W±ªºÀRºA±±¨î¶µ¡A·|¥X²{«ç»ò¥Ñ¦è¤¸¦~¥÷pºâ¥X¶|¦~ªº¹ï¸Ü²°¡C«ö¡uÂ÷¶}¡v«ö¶s°h¥Xµ{¦¡¡CLY.ASM ì©l½X¥i¦b³oùؤU¸ü¡C
©³¤U»¡©ú LY.ASM ªºµ{¦¡½X¡C
¥Dµ{¦¡µù¥Uµøµ¡Ãþ§O¡B«Ø¥ßµøµ¡¡BÅã¥Üµøµ¡¡AµM«á«Ø¥ß°T®§°j°é¡C³o¨Ç³£¬O¤@¯ë¹Lµ{¡A¬Ù²¤¤£»¡¡Aª½±µ¶i¤Jµøµ¡¨ç¦¡¡C
«Ø¥ß¤Ó±±¨î¶µªºµ{¦¡½X¡AÀ³©ñ¦bµøµ¡¨ç¦¡¡A³B²z WM_CREATE °T®§¤¤¡Cµ{¦¡½X¦p¤U¡G
.CONST szClassStatic DB "STATIC",0 ;ÀRºA±±¨î¶µÃþ§O¦WºÙ szClassEdit DB "EDIT",0 ;½s¿è®ØÃþ§O¦WºÙ szClassButton DB "BUTTON",0 ;«ö¶sÃþ§O¦WºÙ szAskYear DB "¿é¤J¦è¤¸¦~¥÷¡G",0 szInput DB "½Ð¿é¤J¦è¤¸¦~¥÷¡C",0 szInquire DB "¬d¸ß",0 szExit DB "Â÷¶}",0 ⁝ .case WM_CREATE ;«Ø¥ß¤TºØÃþ§O¤Ó±±¨î¶µ ;«Ø¥ß¡u¿é¤J¦è¤¸¦~¥÷¡G¡vÀRºA±±¨î¶µ¡A³oÀRºA±±¨î¶µ¨ã¦³ SS_NOTIFY ·®æ invoke CreateWindowEx,0,OFFSET szClassStatic,OFFSET szAskYear,\ WS_CHILD or WS_VISIBLE or SS_NOTIFY,\ 16,10,108,28,hWnd,IDS_ASK,hInstance,0 mov hStaAsk,rax ;«Ø¥ß¨ã¦³ ES_NUMBER ·®æªº½s¿è®Ø invoke CreateWindowEx,WS_EX_CLIENTEDGE,OFFSET szClassEdit,0,\ WS_CHILD or WS_VISIBLE or WS_BORDER or ES_LEFT or ES_NUMBER,\ 126,6,80,28,hWnd,IDE_YEAR,hInstance,0 mov hEdit,rax ;«Ø¥ß¡u½Ð¿é¤J¦è¤¸¦~¥÷¡C¡vÀRºA±±¨î¶µ invoke CreateWindowEx,0,OFFSET szClassStatic,OFFSET szInput,\ WS_CHILD or WS_VISIBLE,\ 16,48,145,28,hWnd,IDS_RESULT,hInstance,0 mov hStaRes,rax ;«Ø¥ß¡u¬d¸ß¡v¹w³]¤UÀ£¦¡«ö¶s invoke CreateWindowEx,0,OFFSET szClassButton,OFFSET szInquire,\ WS_CHILD or WS_VISIBLE or BS_DEFPUSHBUTTON,\ 36,82,52,28,hWnd,IDS_INQUIRE,hInstance,0 mov hBtnInquire,rax ;«Ø¥ß¡uÂ÷¶}¡v¤UÀ£¦¡«ö¶s invoke CreateWindowEx,0,OFFSET szClassButton,OFFSET szExit,\ WS_CHILD or WS_VISIBLE or BS_PUSHBUTTON,\ 128,82,52,28,hWnd,IDB_EXIT,hInstance,0 mov hBtnExit,rax ;³]©w½s¿è®Ø³Ì¤j¿é¤Jªø«×¬°4Ó¦r¤¸ invoke SendMessage,hEdit,EM_SETLIMITTEXT,4,0
«Ø¥ß³o¨Ç±±¨î¶µ¡A³£¬O©I¥s CreateWindowEx¡A®t§O¦b©óµøµ¡Ãþ§O¡Bµøµ¡ªº¤å¦r¡B·®æ¡B¦ì¸m¡B¤j¤p¡BÃѧO½X¡C©³¤U»¡©ú«ÂI¡G
n§âµøµ¡©ñ¦b¿Ã¹õ¥¿¤¤¥¡¡A»Ýn¤U±ªº¨âµ§¸ê®Æ¡G①µøµ¡¼e«×»P°ª«×¡B②¿Ã¹õ¼e«×»P°ª«×¡C«eªÌ¥i¥H©I¥s GetWindowRect ±o¨ì¡A«áªÌ¥i¥H©I¥s GetSystemMetrics ±o¨ì¡C
©I¥s GetWindowRect ¦¨¥\«á¡A²Ä¤GӰѼƬO·í«eµøµ¡¦û¦³¯x§Îªº¥ª¤W¨¤¤Î¥k¤U¨¤®y¼Ð¡A±N¨ä¬Û´î´N¬Oµøµ¡ªº¼e«×»P°ª«×¡C¥H SM_CXSCREEN ¬°°Ñ¼Æ©I¥s GetSystemMetrics¡A´N±o¨ì¿Ã¹õ¼e«×¡A¥H SM_CYSCREEN ¬°°Ñ¼Æ©I¥s GetSystemMetrics¡A´N±o¨ì¿Ã¹õ°ª«×¡C
¦³¤F³o¨Ç¸ê®Æ¤§«á¡A§â¿Ã¹õ¼e«×¥ý´î¥hµøµ¡¼e«×¡A©Ò±o¤§®t¦A°£¥H¤G¡A´N¬Oµøµ¡·s¦ì¸mªº X ®y¼Ð¡C¦P²z¡A§â¿Ã¹õ°ª«×´î¥hµøµ¡°ª«×¡A©Ò±o¤§®t¦A°£¥H¤G¡A´N¬Oµøµ¡·s¦ì¸mªº Y ®y¼Ð¡C³Ì«á©I¥s SetWindowPos ´N¯à±Nµøµ¡²¾¨ì¿Ã¹õ¥¿¤¤¥¡¤F¡C¥u»Ý§âµøµ¡²¾¨ì·sªº X¡BY ®y¼Ð¡A¤£½Õ¾ãµøµ¡¤j¤p¤]¤£½Õ¾ã Z ¶b¶¶§Ç¡A©Ò¥H³Ì«á¤@ӰѼƬO¡uSWP_NOZORDER or SWP_NOSIZE¡v¡Aµ{¦¡½X¦p¤U¡G
invoke SetWindowPos,hWnd,0,r8d,r9d,0,0,SWP_NOZORDER or SWP_NOSIZE
LY »P¨Ï¥ÎªÌ¤¬°Êªº¥Dn¹Lµ{³£¦b³B²z WM_COMMAND °T®§¤¤µo¥Í¡C¦b LY ¤¤n³B²zªº³qª¾½X¦³¡G①¨Ï¥ÎªÌ«ö¤U¨âÓ«ö¶s¤¤ªº¥ô¦ó¤@ӥͦ¨ªº³qª¾½X¡ABN_CLICKED¡C②¨Ï¥ÎªÌÂIÀ»¡u¿é¤J¦è¤¸¦~¥÷¡G¡vÀRºA±±¨î¶µªº³qª¾½X¡ASTN_CLICKED¡C③¨Ï¥ÎªÌÂIÀ»½s¿è®Ø®É¡A½s¿è®ØÀò±o¿é¤JµJÂI¡A³qª¾½X¬O EN_SETFOCUS¡C
²Ä①±¡ªp¡A¨Ï¥ÎªÌ«ö¡u¬d¸ß¡v©Î¡uÂ÷¶}¡v«ö¶s³£·|²£¥Í BN_CLICKED¡A©Ò¥H¥²¶·¦A¶i¤@¨B°Ï¤À¨Ï¥ÎªÌ¨ì©³¬O«ö¤Uþ¤@Ó«ö¶s¡C³o®É¥i¥H¥ÎÃѧO½X¨Ó¤À¿ë¡A¤]¥i¥H¥Î«ö¯Ã¥N½X¨Ó¤À¿ë¡C«ö¤U¡u¬d¸ß¡v«ö¶s«á¡ALY npºâ½s¿è®Ø¤ºªº¦è¤¸¦~¥÷¬O§_¬°¶|¦~¡A«ö¤U¡uÂ÷¶}¡v«ö¶s«h°h¥X LY µ{¦¡¡C
²Ä②±¡ªp¡A¨Ï¥ÎªÌÂIÀ»¨ã¦³ SS_NOTIFY ·®æªº¡u¿é¤J¦è¤¸¦~¥÷¡G¡vÀRºA±±¨î¶µ®É¡A·|µo¥X STN_CLICKED ªº WM_COMMAND °T®§¡C³B²z¦¹³qª¾½Xªº¤è¦¡¬O©I¥s MessageBox¡A¼u¥X¤@µøµ¡¡A§iª¾¨Ï¥ÎªÌ¦p¦ó¥Ñ¦è¤¸¦~¥÷±o¥X¸Ó¦~¬O§_¬°¶|¦~¡Cnª`·Nªº¬O¡ASTN_CLICKED »P BN_CLICKED ªº¼Æȳ£¬O 0¡A¦]¦¹¥²¶·©M«ö¶sªº BN_CLICKED ¦b¦P¤@Ó¡u.if/.elseif/.endif¡v°Ï¶ô¤º¡Aµ{¦¡½X¦p¤U¡G
.case WM_COMMAND mov rax,r8 ;R8W¡×ÃѧO½X shr rax,16 ;AX¡×³qª¾½X .if ax==BN_CLICKED .if r9==hBtnExit ;R9¡×±±¨î¶µ¥N½X jmp quit .elseif r9==hBtnInquire ⁝ ;pºâ½s¿è®Ø¤ºªº¦è¤¸¦~¥÷¬O§_¬°¶|¦~ .elseif r9==hStaAsk ⁝ ;©I¥s MessageBox¡A¼u¥X¹ï¸Ü²°»¡©ú¦p¦ó¥Ñ¦è¤¸¦~¥÷±o¥X¸Ó¦~¬O§_¬°¶|¦~ .endif .elseif ax==EN_SETFOCUS ⁝ ;©I¥s MessageBox¡A¼u¥X¹ï¸Ü²°§iª¾¥u¯à¿é¤Jªü©Ô§B¼Æ¦r .endif
¤£¯à¼g¦¨¤U±ªº¼Ë¤l¡A§_«hµL½×¨Ï¥ÎªÌ«ç¼Ë«ö¡u¿é¤J¦è¤¸¦~¥÷¡G¡vÀRºA±±¨î¶µ¡A¥Ã»·¤]¤£·|¼u¥X¹ï¸Ü²°§iª¾¦p¦ó¥Ñ¦è¤¸¦~¥÷±o¥X¸Ó¦~¬O§_¬°¶|¦~¡C
.case WM_COMMAND mov rax,r8 ;R8W¡×ÃѧO½X shr rax,16 ;AX¡×³qª¾½X .if ax==BN_CLICKED .if r9==hBtnExit ;R9¡×±±¨î¶µ¥N½X jmp quit .elseif r9==hBtnInquire ⁝ ;pºâ½s¿è®Ø¤ºªº¦è¤¸¦~¥÷¬O§_¬°¶|¦~ .endif .elseif ax==STN_CLICKED .if r9==hStaAsk ⁝ ;©I¥s MessageBox¡A¼u¥X¹ï¸Ü²°§iª¾¦p¦ó¥Ñ¦è¤¸¦~¥÷±o¥X¸Ó¦~¬O§_¬°¶|¦~ .endif .elseif ax==EN_SETFOCUS ⁝ ;©I¥s MessageBox¡A¼u¥X¹ï¸Ü²°§iª¾¥u¯à¿é¤Jªü©Ô§B¼Æ¦r .endif
¨Ï¥ÎªÌÂIÀ»½s¿è®Ø®É¡A½s¿è®ØÀò±o¿é¤JµJÂI¡A²£¥Í³qª¾½X¬O EN_SETFOCUS ªº WM_COMMAND °T®§¡CLY ¦b³o®ÉÔ¼u¥X¤@Ó¹ï¸Ü²°¡A´£¿ô¨Ï¥ÎªÌ¡A¦¹½s¿è®Ø¶È¯à¿é¤Jªü©Ô§B¼Æ¦r¡C¦]¬°¼u¥X¹ï¸Ü²°¡A©Ò¥H½s¿è®Ø·|¥¢¥h¿é¤JµJÂI¡A¦pªGn¿é¤J¦è¤¸¦~¥÷¡A¤Sn¦AÂIÀ»½s¿è®Ø¤@¦¸¡A½s¿è®Ø¤S·|±o¨ì¿é¤JµJÂI¡CY¦¹®É¤S¼u¥X´£¿ô¨Ï¥ÎªÌ¥u¯à¿é¤Jªü©Ô§B¼Æ¦rªº¹ï¸Ü²°¡A¨º»ò¨Ï¥ÎªÌ¥Ã»·¤]§O·Q¿é¤J¦è¤¸¦~¥÷¤F¡CLY ªº¸Ñ¨M¤èªk¬O©w¸q¤@Ó first ºX¼Ð¡Aì¥ý¦¹ºX¼Ð¬° 1¡A·í½s¿è®Ø²Ä¤@¦¸±o¨ì¿é¤JµJÂI®É¡A±N¨ä³]¬°¹s¡C³o¼Ë¥unÀˬd first ¬O§_¬°¤@¡A¥u¦³ first ¬°¤@®É¡Aªí¥Ü½s¿è®Ø±q¥¼±o¨ì¿é¤JµJÂI¹L¡A¤~¼u¥X¹ï¸Ü²°¡F§_«h©¿²¤¦¹³qª¾½X¡C
¥Ñ¦è¤¸¦~¤Àpºâ¸Ó¦~¬O§_¶|¦~ªº¨BÆJ¦p¤U¡G
¹ï©ó«e¨â¶µ³W«h¡A¤p¤ì°¸¥u¯à¦Ñ¦Ñ¹ê¹ê¦a¶i¦æ°£ªk¹Bºâ¡AÀˬd¾l¼Æ¬O§_¬°¹s¡A¨S¦³¨ä¥L¦nªº¤èªk¡F¦pªG¦³°ª¤H¯à¥[¥H«üÂI¡A·P¿E¤£ºÉ¡C¹ï©ó²Ä¤T¶µ¡AˬO¦³¤@ӫܲ³æªº¤èªk´N¯àÀˬd¬O§_¯à³Q¥|¾ã°£¡CÅýnÀˬdªº¦è¤¸¦~¥÷»P 3 ¶i¦æ AND ¹Bºâ¡A¦pªGµ²ªG¬°¹sªí¥Ü¯à³Q¥|¾ã°£¡Fµ²ªG¤£¬°¹sªí¥Ü¤£¯à³Q¥|¾ã°£¡C¦pªGn¨Ï¦è¤¸¦~¥÷¦b¹Bºâ¹Lµ{¤£ÅÜ¡A¨º»ò¤]¥i¥H§â AND ¹Bºâ§ï¦¨ TEST ¹Bºâ¡C
«e±´£¹L¡A¹ï¤G¶i¦ì¼Æ¦Ó¨¥¡A©¹¥ª²¾¤@¦ì¬Û·í©ó¼¥H¤G¡Aì¨Ó³Ì¥kÃ䪺 0 ©Î 1 ¥ª²¾¤F¡A·sªº³Ì¥kÃä¶ñ¤W 0¡F©¹¥ª²¾¨â¦ì¬Û·í©ó¼¥H¥|¡A³Ì¥kÃä¨â¦ì³£·|Åܦ¨¹s¡C¬JµM¦V¥ª²¾¤F¨â¦ì¬Û·í©ó¼¥H¥|¡A¦¹¼Æ´N¬O¦üªº¿¼Æ¡A¯à³Q¥|¾ã°£¡Cºî¦X¤Wzµ²ªG¡A¤@ӼƦpªG¬O¥|ªº¿¼Æ¡A¥¦ªº²Ä¹s¦ì¤¸©M²Ä¤@¦ì¤¸³£¬O¹s¡C³o¤]´N¬O¤@ӼƻP 3 ¶i¦æ AND ¹Bºâ¡A¦pªGµ²ªG¬°¹s¡Aªí¥Ü¦¹¼Æ¯à³Q¥|¾ã°£¡C©³¤U¬O³o¬q¹Lµ{ªºµ{¦¡½X¡G
szLeapYear DB "¦è¤¸%d¦~¬O¶|¦~¡C",0 szCommonYear DB "¦è¤¸%d¦~¬O¥¦~¡C",0 ⁝ invoke GetWindowText,hEdit,ADDR buffer,5 invoke StrToInt,ADDR buffer lea r10,szLeapYear mov r11,400 mov r8,rax ;RAX¡×¦è¤¸¦~¥÷ xor rdx,rdx div r11 or rdx,rdx ;¯à³Q400¾ã°£ªº¬O¶|¦~ jz @f mov rax,r8 mov r11,100 ;¯à³Q100¾ã°£¥B¤£¯à³Q400¾ã°£ªº¬O¥¦~ xor rdx,rdx div r11 or rdx,rdx jz comyr test r8,3 ;¨ä¾l¯à³Q4¾ã°£ªº¬O¶|¦~ jz @f comyr: lea r10,szCommonYear @@: invoke wsprintf,ADDR buffer,r10,r8d lea rdx,buffer blank: invoke SetWindowText,hStaRes,rdx
¥»³¹©Ò¥Î¨ìªº Win64 API¡G
EnanleWindow ¥i¥H§âµøµ¡©Î±±¨î¶µ³]¬°±Ò¥Î¡]enable¡^©Î¸T¥Î¡]disable¡^ª¬ºA¡C±Ò¥Î®É¡Aµøµ¡©Î±±¨î¶µ¥i¥H±µ¦¬Áä½L¥H¤Î·Æ¹«ªº¿é¤J¡F¸T¥Î®É¡Aµøµ¡©Î±±¨î¶µµLªk±µ¦¬Áä½L¥H¤Î·Æ¹«ªº¿é¤J¡CEnableWindow ªºì«¬¬O¡G
invoke EnableWindow,\ hWnd,\ ; handle to window bEnable ; flag for enabling or disabling input
hWnd ¬On³]¬°±Ò¥Î©Î¸T¥Îªºµøµ¡©Î±±¨î¶µ¥N½X¡CbEnable ¥u¯à¬O¹s©Î¤@¡A¹s¥Nªí¸T¥Î¡A¤@¥Nªí±Ò¥Î¡C¦pªGì¥ý¬O¸T¥Îªº¡A¦^¶ÇȬ°«D¹sÈ¡F¦pªGì¥ý¬O±Ò¥Îªº¡A¦^¶ÇȬ°¹s¡C
GetWindowRect ¯à°÷Àò±o¬YÓµøµ¡ªº¥ª¤W¨¤¤Î¥k¤U¨¤®y¼Ð¡AÂǦ¹¥ipºâµøµ¡¼e«×»P°ª«×¡C¨ä쫬¦p¤U¡G
invoke GetWindowRect,\ hWnd,\ ; handle of window lpRect ; address of structure for window coordinates
hWnd ¬OnÀò±o¤Ø¤oªºµøµ¡¤§¥N½X¡AlpRect ¬Oµ²ºcÅé RECT ªº¦ì§}¡A¦pªG GetWindowRect °õ¦æ¦¨¥\¡ARECT µ²ºcÅé·|¦s¦³ hWnd ¥ª¤W¨¤»P¥k¤U¨¤ªº¿Ã¹õ®y¼Ð¡A¥B¦^¶ÇȬ°¤@¡C¦pªG°õ¦æ¥¢±Ñ¡A¦^¶ÇȬ°¹s¡C
GetWindowText ¯à°÷Àò±oµøµ¡¼ÐÃDÄ椺ªº¤å¦r¡A¤]¥i¥HÀò±o±±¨î¶µªº¤å¦r¡A¦ýµLªkÀò±o¥t¤@ÓÀ³¥Îµ{¦¡µøµ¡¤º±±¨î¶µªº¤å¦r¡CGetWindowText ªº¥Îªk¬O¡G
invoke GetWindowText,\ hWnd,\ ; handle of window or control with text lpString,\ ; address of buffer for text nMaxCount ; maximum number of characters to copy
hWnd ¬Oµøµ¡©Î±±¨î¶µ¤§¥N½X¡AGetWindowText ·|Àò±o¸Óµøµ¡¼ÐÃDÄæ©Î±±¨î¶µ¤ºªº¤å¦r¦r¦ê¡ClpString ¬°¦r¦ê¦ì§}¡AGetWindowText ·|§â©ÒÀò±oªº¦r¦ê¦s¤J¦¹¦ì§}¤¤¡CnMaxCount ¬O³Ì¦h±o¨ì¦h¤Ö¦r¤¸¡A¥]§tµ²§Àªº¹s¡A¦pªGµøµ¡¼ÐÃDÄæ©Î±±¨î¶µ¤ºªº¤å¦r¶W¹L nMaxCount¡A¨º»ò¶W¹Lªº³¡¤À·|³QºIÂ_¡A¦Ó¤£¦s¤J lpString ©Ò«üªº¦ì§}¡C
¦pªG GetWindowText °õ¦æ¦¨¥\¡A¦^¶ÇȬ°¯u¥¿Àò±oªº¦r¤¸¼Æ¡A¤£§tµ²§Àªº¹s¡F¦pªGµøµ¡¨S¦³¼ÐÃDÄæ¡B©Î¼ÐÃDÄæ¨S¦³¤å¦r¡A©Î¬Oµøµ¡¥N½X©Î±±¥ó¶µ¥N½XµL®Ä¡A¦^¶ÇȬ°¹s¡C
SetWindowPos §ó§ï¤lµøµ¡¡B¼u¥Xµøµ¡©Î³»¯Åµøµ¡¡]top-level windows¡^ªº¤j¤p¡B¦ì¸m©M Z ¶b¶¶§Ç¡]¨£µù¤T¡^¡C¨ä쫬¬°¡G
invoke SetWindowPos,\ hWnd,\ ; handle of window hWndInsertAfter,\; placement-order handle X,\ ; horizontal position Y,\ ; vertical position cx,\ ; width cy,\ ; height uFlags ; window-positioning flags
¦U°Ñ¼Æ»¡©ú¦p¤U¡G
hWndInsertAfter | ¼ÆÈ | »¡©ú |
HWND_TOP | 0 | ±Nµøµ¡¸m©ó¦PÃþ«¬µøµ¡ªº³Ì¤W±¡C¦¹³BªºÃþ«¬¥u¦³¨âºØ¡G³Ì¤W¼hµøµ¡»P«D³Ì¤W¼hµøµ¡¡C |
HWND_BOTTOM | 1 | ±Nµøµ¡©ñ¦b Z ¶b¶¶§Ç³Ì¤U±¡CY hWnd 쥻¨ã¦³ WS_EX_TOPMOST¡A³]©w HWND_BOTTOM «á·|¥¢¥h WS_EX_TOPMOST ©µ¦ù·®æ¡C |
HWND_TOPMOST | ¡Ð1 | ±Nµøµ¡Åܬ°³Ì¤W¼hµøµ¡¡A¥B¸m©ó³Ì¤W¼hµøµ¡ªº³Ì¤W±¡A§Y¨Ï¤£³B©ó¬¡°Êª¬ºA¡A¤]¤´µM¦p¦¹¡C |
HWND_NOTOPMOST | ¡Ð2 | ±Nµøµ¡Åܬ°«D³Ì¤W¼hµøµ¡¡A¥B¸m©ó©Ò¦³«D³Ì¤W¼hµøµ¡ªº³Ì¤W±¡A¦ý¤´¦b³Ì¤W¼hµøµ¡ªº¤U±¡C |
uFlags | ¼ÆÈ | »¡©ú |
SWP_NOSIZE | 1 | «O«ùì¨Óµøµ¡¼e«×»P°ª«×¡A©¿²¤ cx¡Bcy |
SWP_NOMOVE | 2 | «O«ùì¨Óµøµ¡¦ì¸m¡A©¿²¤ X¡BY |
SWP_NOZORDER | 4 | «O«ùì¨Ó Z ¶b¶¶§Ç¡A©¿²¤ hWndInsertAfter |
SWP_NOREDRAW | 8 | ¤£«·sø»s§ó§ïªº³¡¤À¡C¦pªG³]¸m¦¹ºX¼Ð¡A«h¤£·|µo¥Í«Ã¸¡A¥]§t¤u§@°Ï¡B«D¤u§@°Ï¡]¥]¬A¼ÐÃDÄæ©M±²¶b¡^¥H¤Î¦]µøµ¡²¾°Ê¦Ó¼ÉÅSªº¤÷µøµ¡ªº³¡¤À¡C³]¸m¦¹ºX¼Ð®É¡AÀ³¥Îµ{¦¡¥²¶·«ü©w¸Óµøµ¡©Î¤÷µøµ¡µL®Ä°Ï°ì¡A¤~¯à«·sø»s |
SWP_NOACTIVATE | 10H | ¨Ïµøµ¡Åܬ°¤£¬¡°Êªº¡C¦pªG¥¼³]¸m¦¹ºX¼Ð¡A«hµøµ¡§Y¨Ï²¾°Ê¨ì¬YÓµøµ¡¤U±¡A¤´³B©ó¬¡°Êª¬ºA |
SWP_FRAMECHANGED | 20H | §Y¨Ïµøµ¡¤j¤p¥¼§ó§ï¡A¤]·|¦Vµøµ¡µo°e WM_NCCALCSIZE °T®§¡F¦pªG¥¼«ü©w¦¹ºX¼Ð¡A¶È¦bµøµ¡¤j¤pÅܧó®Éµo°e WM_NCCALCSIZE¡C¥¦»P SWP_DRAWFRAME ¬Û¦P |
SWP_SHOWWINDOW | 40H | Åã¥Üµøµ¡ |
SWP_HIDEWINDOW | 80H | ¤£Åã¥Üµøµ¡ |
SWP_NOCOPYBITS | 100H | ¥á±ó¤u§@°Ï¥þ³¡¤º®e¡C¦pªG¥¼«ü©w¦¹ºX¼Ð¡A«h¦b½Õ¾ãµøµ¡¤j¤p©Î«·s©w¦ì«á¡A·|«O¦s¤u§@°Ïªº¤º®e¦s½Æ»s¦^¤u§@°Ï |
SWP_NOOWNERZORDER | 200H | ¤£§ïÅܾ֦³ªÌµøµ¡ªº Z ¶b¶¶§Ç¡A»P SWP_NOREPOSITION ¬Û¦P |
SWP_NOREPOSITION | 400H | ªý¤îµøµ¡±µ¦¬ WM_WINDOWPOSCHANGING °T®§ |
SWP_DEFERERASE | 2000H | ¨¾¤î¥Í¦¨ WM_SYNCPAINT °T®§ |
SWP_ASYNCWINDOWPOS | 4000H | Windows ·|¬°¨CÓ°õ¦æºü¡]thread¡^«Ø¥ß¦U¦Ûªº°T®§¦î¦C¡C¦pªG©I¥s SetWindowPos ªº°õ¦æºü»P¤÷µøµ¡ªº°õ¦æºü¤£¦P¡A¨º»ò°T®§¦î¦C¤]¤£¦P¡AWindows ¨t²Î·|±N°T®§µo¥¬¨ì¤÷µøµ¡ªº°õ¦æºü¡C³o¼Ë¥i¥H¨Ï©I¥s SetWindowPos ªº°õ¦æºü¤£¶·µ¥«Ý SetWindowPos §¹¦¨¡A´N¯àÄ~Äò³B²z¨ä¥L¤u§@¡C¡]¦³Ãö°õ¦æºün«Ü¤[ªº¥H«á¦A»¡©ú¡^ |
¦pªG SetWindowPos °õ¦æ¦¨¥\¡A¦^¶ÇȬ°¤@¡FY¥¢±Ñ¡A¦^¶ÇȬ°¹s¡C
À³¥Îµ{¦¡¥i¥H§â BM_SETIMAGE ¶Çµ¹«ö¶s¡A¨Ï«ö¶sÅã¥Ü¹Ï¥Ü©Î¦ì¤¸¹Ï¡C¤è¦¡¦p¤U¡G
invoke SendMessage,hButton,BM_SETIMAGE,wParam,lParam
¨ä¤¤ wParam ¥u¯à¬O IMAGE_ICON¡BIMAGE_BITMAP ¤GªÌ¨ä¤¤¤§¤@¡AlParam ¬O¨Ì¾Ú wParam ¦Ó¿ï¾ÜnÅã¥Ü¦b«ö¶s¤Wªº¹Ï¥Ü¥N½X©Î¦ì¤¸¹Ï¥N½X¡C
¥i¥H§â¤å¦r»P¹Ï¤ù¡]¦¹³Bªº¹Ï¤ù¥i¯à¬O¹Ï¥Ü©Î¦ì¤¸¹Ï¡^¦P®ÉÅã¥Ü©ó«ö¶s¤W¡A¨ú¨M©ó«ö¶s¬O§_¨ã¦³ BS_ICON ©Î BS_BITMAP ·®æ¡A¥H¤Î¬O§_©I¥s¤F¥H BM_SETIMAGE ¬°°Ñ¼Æªº SendMessage¡C¨£¤Uªí¡G
¬O§_¨ã¦³ BS_ICON ©Î BS_BITMAP | ¬O§_¥H BM_SETIMAGE ¬°°Ñ¼Æ©I¥s SendMessage | µ²ªG |
¬O | ¬O | ¥uÅã¥Ü¹Ï¤ù |
§_ | ¬O | ¦P®ÉÅã¥Ü¤å¦r»P¹Ï¤ù |
¬O | §_ | ¥uÅã¥Ü¤å¦r |
§_ | §_ | ¥uÅã¥Ü¤å¦r |
°£¦¹¤§¥~¡An¦P®ÉÅã¥Ü¤å¦r¤Î¹Ï¤ùÁÙ¦³Ó±ø¥ó¡A¥²¶·¦b¸ê·½´yzÀɨϥΠDIALOG °Ï¶ô¡A¨Ã¥B¥Î DIALOG °Ï¶ôùرªº CONTROL¡BPUSHBUTTON¡BDEFPUSHBUTTON «Ø¥ß«ö¶s¡A¤£¯à©I¥s CreateWindowEx «Ø¥ß«ö¶s¡]¤U¤@³¹·|´£¨ì¨Ï¥Î DIALOG °Ï¶ô«Ø¥ß±±¨î¶µ¡^¡C
©³¤U»¡©ú¦p¦ó«Ø¥ß¤U©Ô¦¡¤À³Î«ö¶s¡A¥H¤Î¸Ó«ö¶sµo¥X WM_NOTIFY °T®§®É¦p¦ó³B²z¼u¥X¥\¯àªí¡A³Ì«á¦p¦ó³B²zÂI¿ï¸Ó¼u¥X¥\¯àªí¤¤¿ï¶µ®Éµo¥Xªº WM_COMMAND °T®§¡C¨Ò¤l¤¤¶È¦C¥X¬ÛÃöªºµ{¦¡½X¡A¦Ó¬Ù²¤¨ä¥Lµ{¦¡½X¡C
BS_SPLITBUTTON EQU 12 .CONST szClass DB "BUTTON",0 szText DB "½Ð¿ï¾Ü",0 szOne DB "1",0 szTwo DB "2",0 szThree DB "3",0 .DATA hBtn DQ ? ;¤U©Ô¦¡¤À³Î«ö¶sªº¥N½X hMenu DQ ? ;¼u¥X¥\¯àªí¥N½X .CODE WndProc PROC hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM LOCAL rect:RECT .switch uMsg .case WM_CREATE ;«Ø¥ßÃѧO½X¬°5000ªº¤U©Ô¦¡¤À³Î«ö¶s invoke CreateWindowEx,0,OFFSET szClass,OFFSET szText,WS_CHILD or WS_VISIBLE\ or BS_SPLITBUTTON,10,10,150,28,hWnd,5000,hInstance,0 mov hBtn,rax ;«Ø¥ß¼u¥X¥\¯àªí¡A¨Ã¥[¤J¡u1¡v¡B¡u2¡v¡B¡u3¡v¤Tӿﶵ call CreatePopupMenu mov hMenu,rax invoke AppendMenu,hMenu,MF_STRING,1,OFFSET szOne invoke AppendMenu,hMenu,MF_STRING,2,OFFSET szTwo invoke AppendMenu,hMenu,MF_STRING,3,OFFSET szThree .case WM_NOTIFY ASSUME r10:PTR NMHDR mov r10,lParam .if [r10].code==BCN_DROPDOWN .if r8w==5000 ;·í¨Ï¥ÎªÌ«ö¤U¤U©Ô¦¡¤À³Î«ö¶s®É¡A©ó¤U©Ô¦¡¤À³Î«ö¶s¤U¤èÅã¥Ü¼u¥X¥\¯àªí¡A¥H¨Ñ¿ï¾Ü invoke GetWindowRect,[r10].hwndFrom,ADDR rect invoke TrackPopupMenu,hMenu,TPM_LEFTALIGN or TPM_TOPALIGN or TPM_VERNEGANIMATION,\ rect.left,rect.bottom,0,hWnd,0 ASSUME r10:NOTHING .endif .endif .case WM_COMMAND mov rax,r8 ;R8W¡×ÃѧO½X shr rax,16 ;Y AX¡×0¡A¨Ï¥ÎªÌ¿ï¾Ü¬Yӿﶵ¡FAX ¤£¬° 0¡A¬°±±¨î¶µ³qª¾½X .if ax==0 .if r8w==1 ;¨Ï¥ÎªÌ¿ï¾Ü¼u¥X¿ï¶µ¤¤ªº¡u1¡v .elseif r8w==2 ;¨Ï¥ÎªÌ¿ï¾Ü¼u¥X¿ï¶µ¤¤ªº¡u2¡v .elseif r8w==3 ;¨Ï¥ÎªÌ¿ï¾Ü¼u¥X¿ï¶µ¤¤ªº¡u3¡v .endif .endif
¦b Windows §@·~¨t²Îªº®à±¤W¡A¥i¯à·|¥X²{«Ü¦hÓµøµ¡¡C³o¨Çµøµ¡¥i¯à«Å|¦b¤@°_¡A¦³¨Ç¦b¤W±¡A¯à³Q¨Ï¥ÎªÌ¬Ý¨£¡F¦³¨Ç³Q¨ä¥Lµøµ¡¾×¦í¡A¨Ï¥ÎªÌ¥u¬Ý¨£µøµ¡ªº¤@³¡¤À¡F¤]¦³®ÉÔ¬O¤@Óµøµ¡ÅQ¦û¾ãӮౡA¨ä¥Lµøµ¡³£³Q¨ä¾B¾×¡CWindows ¬O«ç»ò¨M©wþÓµøµ¡¦b³Ì¤W±¡A¨Ï¥ÎªÌ¯à¬Ý¨£¥þ»ª¡FþÓµøµ¡¦b©³¤U¡A³Q¾B¦í¥u¯à¬Ý¨£¤@³¡¥÷©Î¥þ¬Ý¤£¨ì©O¡H
¹q¸£¿Ã¹õ¬O¤G«×ªÅ¶¡ªº¥±¡A¥H¥ª¤W¨¤¬°ìÂI¡A¨ä X ¶b¥¿¤è¦V±qìÂI¦V¥k¤ô¥¤è¦V©µ¦ù¡AY ¶b¥¿¤è¦V«h±qìÂI¦V¤U©µ¦ù¡C¦pªG®à±¤W¦P®É¦³³\¦hµøµ¡«Å|®É¡An¯à°Ï¤À¨CÓµøµ¡«e«á¦ì¸mªºÃö«Y¡A´Nn§â¿Ã¹õ·Q¹³¦¨¤T«×ªÅ¶¡¡A¤]´N¬O·Q¹³¦¨¨ã¦³°ª«×¡CWindows §@·~¨t²Î¥H²Ä¤TÓ®y¼Ð¶b¡AZ ¶bªí¥Ü°ª«×¡A¨ä¥¿¤è¦V¥Ñ¿Ã¹õ©¹¨Ï¥ÎªÌ¤è¦V©µ¦ù¡A¦p¥k¹Ï¡CÁöµM Z ¶b¤è¦V쥻¬O¤ô¥ªº¡A¦ýn§â¥¦·Q¹³¦¨°ª«×¡A¶V©¹¿Ã¹õ©Ò¦bªº¦a¤è¬O¤U¤è¡A¶V©¹¨Ï¥ÎªÌ¤è¦V¬O¶V©¹¤W¤è¡C
Windows §@·~¨t²Î·|¹ï©Ò¦³Åã¥Ü¦b¿Ã¹õ¤Wªºµøµ¡¡A½á¤©¤@ÓºÙ¬°¡uZ ¶b¶¶§Ç¡vªº¼ÆÈ¡A¨Ã±N¦¹¼ÆÈ«O¦s©ó¤@±i¦Cªí¤¤¡CWindows ´N¨Ì¾Ú¡uZ ¶b¶¶§Ç¡v¨M©wþ¤@Óµøµ¡¦b¤W±¡Aþ¤@Ó¦b¤U±¡C¦b³o¤@³¹ùØ¡A¤p¤ì°¸¥Î¤W¡B¤U¤è¥Nªí Z ¶b¶¶§Ç¡AZ ¶b¶¶§Ç³Ì¤W±ªºµøµ¡·|¾B¦í¤U±ªºµøµ¡¡A¨Ï¥ÎªÌ¯à¬Ý¨ì³Ì¤W±µøµ¡ªº¥þ»ª¡C
¦Ó¨M©w¡uZ ¶b¶¶§Ç¡vªº¤èªk¡A»Pµøµ¡ªº©Ê½è©M¨Ï¥ÎªÌ°Ê§@¦³Ãö¡A¥ý¸ÑÄÀ´XÓµøµ¡ªº©Ê½è¡G
¸ÑÄÀ§¹³o¨Ç°ò¥»ªºµøµ¡©Ê½è«á¡A¥i¥H¨Ó½Í½Í¨M©w Z ¶b¶¶§Çªº³W«h¤F¡A´N¥u¦³¤U±´XÓ³W«h¡G
Á|Ó¨Ò¤l»¡©ú³o¨Ç³W«h¡C¤p¤ì°¸±`±`¤@Ãä¥Î UltraEdit ¼gµ{¦¡¡A¤@Ãä¥Î¤õª°¯WÂsÄý¾¹Å¥ YouTube ¤Wªºµ¼Ö¡A¦Ó¥B¬O¥H¤l¥Àµe±Å¥µ¼Ö¶¶«K¤]¯àªY½à¼v¤ù¡C¤p¤ì°¸¦b UltraEdit ¤¤¥HÁä½L¿é¤Jµ{¦¡½X¦Ó¤£¬O¦b¤l¥Àµe±¿é¤Jµ{¦¡½X¡A¦ý¤l¥Àµe±¨ÌµM·|¾B¦í UltraEdit µøµ¡¡F©Ò¥H¤l¥Àµe±¬O³Ì¤W¼hµøµ¡¡A¦Ó¥B¬O«D¬¡°Êªºµøµ¡¡FUltraEdit «h¬O«D³Ì¤W¼hµøµ¡¡A¥¦¬O³»¯Åµøµ¡¡]¦]¬° UltraEdit ¨S¦³¤÷µøµ¡¡^¡A¤]¬O¬¡°Êªºµøµ¡¡C
°²³]²{¦b¦A±Ò°Ê Edge ÂsÄý¾¹¡A¤@¼Ë¥Î¤l¥Àµe±¬Ý YouTube ¤Wªº¼v¤ù¡A³oÓ¤l¥Àµe±¤]¬O³Ì¤W¼hµøµ¡¡A¥¦·|Âл\¦b¤õª°¯WÂsÄý¾¹ªº¤l¥Àµe±¤W¡A¦]¬° Edge ÂsÄý¾¹«á±Ò°Ê¡A©Ò¥H¥¦ªº Z ¶b¶¶§Ç·|¦b¤õª°¯WÂsÄý¾¹ªº¤l¥Àµe±¤§¤W¡C