±`±`¦³³\¦h²³æªºµ{¦¡¡A¨Ï¥ÎªÌ¥un¿é¤J¤å¦r©Î¼Æ¦r¡A¦Óµ{¦¡¯à®Ú¾Ú¨Ï¥ÎªÌ¿é¤Jªº¸ê®Æ¡Apºâµ²ªG¡A³oºØµ{¦¡¬O¤@ºØ¡y¹ï¸Ü²°¡z¡C³o¤@³¹¡A¤p¤ì°¸±NÂǥѼ¶¼g§PÂ_¦è¤¸¬Y¦~¬O§_¬°¶|¦~ ( ¦ó¿×¶|¦~¡H½Ð°Ñ¦Òµù¤@ ) ¨Ó¤¶²Ð¦p¦ó¼¶¼g¹ï¸Ü²°¡C¦¹¹ï¸Ü²°µ{¦¡¦W¬° LEAPYEAR.EXE¡A°õ¦æ«áµe±¦p¤U¡G
¨ä¹ê¹ï¸Ü²°¨ä¹ê´N¬O¥]§t³\¦h¤lµøµ¡ªºµøµ¡¡A¦Ó³o¨Ç¤lµøµ¡¡A¤]ºÙ¤§¬°¡y±±¨î¤¸¥ó ( controls )¡z( ©Î²ºÙ¡y±±¥ó¡z )¡C¥H¤W± LEAPYEAR.EXE ©ÒÅã¥Üªºµøµ¡¦Ó¨¥¡A³oÓµøµ¡¥]§t¤F¥|Ó¤lµøµ¡¡A¤À§O¬O
½s¸¹ | ¤l¡@µø¡@µ¡ | µøµ¡Ãþ§O |
1 | ¡y¿é¤J¦è¤¸¦~¼Æ¡G¡z¦r¦ê | static |
2 | ½s¿è®Ø | edit |
3 | ¡y¬d¸ß¡z«ö¶s | button |
4 | ¡yÂ÷¶}¡z«ö¶s | button |
©Ò¥H¤p¤ì°¸¥un¦b LEAPYEAR.EXE ©Ò«Ø¥ßªºµøµ¡¤¤ ( ¦¹µøµ¡ºÙ¬°¡y¤÷µøµ¡¡z )¡A³sÄò©I¥s¥|¦¸ CreatWindowEx API «Ø¥ß¥|Ó¤lµøµ¡´N¥i¥H¤F¡A¦Ó³o¥|Ó¤lµøµ¡¦U¦³¦Uªº¦ì¸m¡Bµøµ¡¥N½X¡Bµøµ¡Ãþ§Oµ¥µ¥¡A¦]¦¹¦b©I¥s CreateWindowEx «Ø¥ß¤lµøµ¡®É¡A¥²¶·¤À§O«ü©w³o¨Ç¼ÆÈ¡C¤@¯ë¦Ó¨¥¡A¤j¦h¦b¨t²Îµo¥X WM_CREATE °T®§®É¡A¤]´N¬Oè«Ø¥ß¤÷µøµ¡«á´N¥ß§Y«Ø¥ß¨ä¤lµøµ¡¡C
·L³n¤½¥q¦b Win32 ¨t²Îùؤw¸g¹w¥ý©w¸q¦n´XºØ±`¥Îªºµøµ¡Ãþ§O¡Aµ{¦¡³]p®v¥un®³¨Ó¨Ï¥Î§Y¥i¡A¦Ó¤£»Ýn¦A¸g¥Ñ RegisterClassEx µù¥U¡Cn¨Ï¥Î³o¨Ç¤w¹w¥ý©w¸qªºµøµ¡®É¡A¥u»Ý¦b©I¥s CreateWindowEx API ®É¡A§â¥¿½Tªºµøµ¡Ãþ§O¶ñ¤J lpClassName °Ñ¼Æ§Y¥i¡A³o¼Ë´N¸`¬Ù¤Fµ{¦¡³]p®vªº³\¦h¤u§@¡C¥Î³o¨Ç¤w¹w¥ý©w¸q¦nªºµøµ¡Ãþ§O©Ò«Ø¥ßªº¤lµøµ¡´NºÙ¬°±±¨î¤¸¥ó¡A±`¥Îªº¦³¤U±´XºØ¡G
µøµ¡Ãþ§O | ¦W¡@ºÙ | »¡¡@¡@¡@©ú |
button | «ö¶sÃþ§O | ¦bµøµ¡ùØÅã¥Ü¤@Óªø¤è§Î°Ï°ì·í§@«ö¶s¡A¨Ï¥ÎªÌ¥i¥H«ö¤U«ö¶s©ÎÃP¶}«ö¶s¡C |
edit | ½s¿è®ØÃþ§O | ¦bµøµ¡ùثإߤ@Ó½s¿è®Øªº¤lµøµ¡¡A¥i¥HÅý¨Ï¥ÎªÌ¿é¤J¤å¦r©Î¼Æ¦r¡C |
static | ÀRºAÃþ§O | «Ø¥ß¤@Óªø¤è§Î°Ï°ìªº¤lµøµ¡¡A¥i¥HÅã¥Ü¦r¦ê¡A³oºØ¤lµøµ¡µLªkÅý¨Ï¥ÎªÌ°µ¿é¥X¿é¤J°Ê§@¡C |
listbox | ²M³æÃþ§O | «Ø¥ß¤@¶ôªø¤è§Î°Ï°ì¡A¨ä¤¤¦³³\¦h¦r¦ê¥i¨Ñ¨Ï¥ÎªÌ¿ï¾Ü¡A¨Ò¦p¶}±ÒÀÉ®×®ÉÅã¥Ü²{¦³Àɮתº¤lµøµ¡¡C |
combobox | ½Æ¦XÃþ§O | ¬O½s¿è®Ø©M²M³æªºµ²¦X¡A³q±`¦³¤@¶ô°Ï°ìÅã¥Ü²M³æ¨Ñ¨Ï¥ÎªÌ¿ï¾Ü¡A©ÎªÌ«ö¤U¥kÃ䪺¤U©Ô¶s«á¤~Åã¥Ü²M³æ¡C |
scrollbar | ±²¶b¤¸¥ó | ¤@ªø±ø§Îªº°Ï°ì¡A¤W±¦³¤@·Æ°Ê±ì¥i¨Ñ¨Ï¥ÎªÌ©ì°Ê¦¹·Æ°Ê±ì¨Ó¿ï¾Ü¾A·íªº¼ÆÈ¡A¨Ò¦p½Õ¾ãµ¶qªº¤j¤p¡C |
ÁÙ°O±o CreateWindowEx ªºì«¬¶Ü¡H
HWND CreateWindowEx( DWORD dwExStyle, // extended window style LPCTSTR lpClassName, // pointer to registered class name LPCTSTR lpWindowName, // pointer to window name DWORD dwStyle, // window style int x, // horizontal position of window int y, // vertical position of window int nWidth, // window width int nHeight, // window height HWND hWndParent, // handle to parent or owner window HMENU hMenu, // handle to menu, or child-window identifier HINSTANCE hInstance, // handle to application instance LPVOID lpParam // pointer to window-creation data );
·í«Ø¥ß¤lµøµ¡®É¡A¦³´XÓ¦a¤è¶·ª`·N¡C
¦b LEAPYEAR µ{¦¡¤¤ªº½s¿è®Ø¥u¤¹³\¨Ï¥ÎªÌ¿é¤J¦è¤¸¦~¥÷¡A©Ò¥H¥u¯à¬O¼Æ¦r¡A¤£¥i¥H¬O^¤å¦r¥À©Î¨ä¥L²Å¸¹¡A©Ò¥H¦b²Ä 156 ¦æªº dwStyle ÁÙ«ü©w¤F¤@Ó·®æ¡AES_NUMBER¡A¨Ó¹F¨ì¤Wz¥Øªº¡C³o¨Ç¥H©w¸qªºµøµ¡Ãþ§O³£¦³¨ä·®æ¥i¨Ñ¨Ï¥Î¡A¤p¤ì°¸±N¦bµy«á´X³¹¤º¤¶²Ð¡A©ÎªÌ½Ð¦Û¦æ°Ñ¦Ò Win32 µ{¦¡¤â¥U¡C
©³¤U¬O LEAPYEAR.ASM ªºì©lÀÉ¡G
.386 .model flat,stdcall option casemap:none include windows.inc include user32.inc include kernel32.inc includelib user32.lib includelib kernel32.lib EditID equ 1001h ;11 ±±¨î¤¸¥ó¡A½s¿è®Øªº ID StrID equ 1002h ;12 ±±¨î¤¸¥ó¡A¦r¦êªº ID ButtonExitID equ 1003h ;13 ±±¨î¤¸¥ó¡AÂ÷¶}ªº ID ButtonInquireID equ 1004h ;14 ±±¨î¤¸¥ó¡A¬d¸ßªº ID IDM_Exit equ 2101h ;15 ¿ï³æ¡AÂ÷¶}ªº ID IDM_Clear equ 2102h ;16 ¿ï³æ¡A²M°£ªº ID IDM_Inquire equ 2103h ;17 ¿ï³æ¡A¬d¸ßªº ID IDM_Help equ 2104h ;18 ¿ï³æ¡A»¡©úªº ID WndProc proto :HWND,:UINT,:WPARAM,:LPARAM .DATA ClassName db 'SimpleWinClass',0 AppName db '¬O§_¶|¦~¡H',0 AskExit db '¬O§_°h¥X¦¹µ{¦¡¡H',0 AskExitTitle db '¸ß°Ý',0 AskYear db '¿é¤J¦è¤¸¦~¼Æ¡J',0 EditClass db 'edit',0 ;28 µøµ¡Ãþ§O¡Aedit ButtonClass db 'button',0 ;29 µøµ¡Ãþ§O¡Abutton StrClass db 'static',0 ;30 µøµ¡Ãþ§O¡Astatic ButtonInquire db '¬d¸ß',0 ButtonExit db 'Â÷¶}',0 MenuName db 'LEAPYEAR',0 HelpText db '§A¥i¥H¦b½s¿è®ØùØ¿é¤J¦è¤¸¦~¼Æ¡A',0dh,0ah db 'LEAP YEAR ·|pºâ¸Ó¦~¬O§_¬°¶|¦~¡C',0 HelpTitle db '»¡©ú',0 ResultTitle db '¬d¸ßµ²ªG',0 Leap_Year db '¶|¦~' Common_Year db '¥¦~' ResultStr db '¦è¤¸ ', 20 dup (0) ;40 Åã¥Üµ²ªGªº¦r¦ê hInstance HINSTANCE ? hwnd HWND ? hMenu HMENU ? hEdit HWND ? hStr HWND ? hExitButton HWND ? hInquireButton HWND ? wc WNDCLASSEX <30h,?,?,0,0,?,?,?,?,0,offset ClassName,?> msg MSG <?> year db 10 dup (?) .CODE start: invoke GetModuleHandle,NULL mov hInstance,eax mov wc.style,CS_HREDRAW or CS_VREDRAW mov wc.lpfnWndProc,offset WndProc mov eax,hInstance mov wc.hInstance,eax mov wc.hbrBackground,COLOR_BTNFACE+1 ;59 ³]©w¤÷µøµ¡I´º¦â invoke LoadIcon,NULL,IDI_APPLICATION mov wc.hIcon,eax mov wc.hIconSm,eax invoke LoadCursor,NULL,IDC_ARROW mov wc.hCursor,eax invoke LoadMenu,hInstance,offset MenuName mov hMenu,eax invoke RegisterClassEx,offset wc ;67 µù¥U¤÷µøµ¡¤§µøµ¡Ãþ§O invoke CreateWindowEx,NULL,offset ClassName,\ ;68 «Ø¥ß¤÷µøµ¡ offset AppName,WS_OVERLAPPEDWINDOW,0,\ 0,250,150,NULL,hMenu,hInstance,NULL mov hwnd,eax invoke ShowWindow,hwnd,SW_SHOWNORMAL invoke UpdateWindow,hwnd .while TRUE invoke GetMessage,offset msg,NULL,0,0 .break .if !eax invoke TranslateMessage,offset msg ;78 Âà´«¨Ï¥ÎªÌ¿é¤Jªº«öÁä invoke DispatchMessage,offset msg .endw mov eax,msg.wParam invoke ExitProcess,eax ;--------------------------------------- ;pºâ¦~¥÷¬O§_¬°¶|¦~¡A¦¹°Æµ{¦¡¨ú±o year ©Ò«üªº¦~¥÷¦r ;85 ;¤¸¡Apºâ¬O§_¬°¶|¦~¡A¨Ã¨Ïµ²ªG¶ñ¤J ResultStr ¦r¦êùØ ;86 calc_year proc push esi push edi sub dx,dx ;89 DX ±N¦s¦³ 16 ¶i¦ìªº¦è¤¸¦~¥÷ mov esi,offset year mov edi,offset ResultStr+5 mov ax,dx mov cl,10 nxt0: lodsb or al,al jz ok0 stosb ;97 §â¨C¦ì¦è¤¸¦~¥÷ªº ASCII ¦r¤¸¦s¤J ResultStr sub al,'0' ;98 pºâ¨C¦ì¦è¤¸¦~¥÷ªº 16 ¶i¦ì¼Æ xchg ax,dx mul cl add dx,ax jmp nxt0 ok0: mov al,' ' stosb ;105 ¦s¤JªÅ¥Õ¦r¤¸¨ì ResultStr ¦r¦ê mov esi,offset HelpText+50 lodsd ;107 ¦s¤J¡y¦~¬O¡z4 Ӧ줸²Õ¨ì ResultStr ¦r¦ê stosd mov si,dx ;110 DX¡BSI ¦s¦³ 16 ¶i¦ì¤§¦è¤¸¦~¥÷ mov cx,400 mov ax,dx sub dx,dx div cx or dx,dx jz leap mov ax,si sub dx,dx mov cx,100 div cx or dx,dx jz common mov ax,si mov cx,4 sub dx,dx div cx or dx,dx jz leap ;Y¬°¶|¦~ ESI «ü¦V¡y¶|¦~¡z¦r¦ê¡A¤Ï¤§«ü¦V¡y¥¦~¡z¦r¦ê common: mov esi,offset Common_Year jmp ok1 leap: mov esi,offset Leap_Year ok1: lodsd stosd mov esi,offset HelpText+62 lodsw stosw ;140 ¦s¤J¡y¡C¡z©ó ResultStr ¦r¦ê sub al,al ;141 ¦s¤J NULL ©ó ResultStr ¦r¦ê stosb pop edi pop esi ret calc_year endp ;--------------------------------------- WndProc proc hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM .if uMsg==WM_CREATE ;149 «Ø¥ß¥|Ó±±¨î¤¸¥ó invoke CreateWindowEx,WS_EX_LEFT,addr StrClass,\ addr AskYear,WS_CHILD or WS_VISIBLE or ES_LEFT,\ 10,22,145,28,hWnd,StrID,hInstance,NULL mov hStr,eax invoke CreateWindowEx,WS_EX_CLIENTEDGE,addr EditClass,\ NULL,WS_CHILD or WS_VISIBLE or WS_BORDER or ES_LEFT\ or ES_AUTOHSCROLL or ES_NUMBER,156,18,80,28,\ hWnd,EditID,hInstance,NULL mov hEdit,eax invoke CreateWindowEx,NULL,addr ButtonClass,addr ButtonInquire\ ,WS_CHILD or WS_VISIBLE or BS_DEFPUSHBUTTON,48,60,\ 52,28,hWnd,ButtonInquireID,hInstance,NULL mov hInquireButton,eax invoke CreateWindowEx,NULL,addr ButtonClass,addr ButtonExit\ ,WS_CHILD or WS_VISIBLE or BS_DEFPUSHBUTTON,148,60,\ 52,28,hWnd,ButtonExitID,hInstance,NULL mov hExitButton,eax invoke SetFocus,hEdit ;167 ¨Ï½s¿è®Ø¦¨¬°¥¿¦b§@¥Î¤¤ªºµøµ¡ .elseif uMsg==WM_COMMAND mov edx,wParam .if lParam==0 ;171 «ö¤U¿ï³æ©Î§Ö±¶Áä .if dx==IDM_Exit jmp close .elseif dx==IDM_Clear invoke SetWindowText,hEdit,NULL .elseif dx==IDM_Inquire jmp inquire .elseif dx==IDM_Help invoke MessageBox,hWnd,offset HelpText,\ offset HelpTitle,MB_OK .endif .else ;182 «ö¤U±±¨î¤¸¥ó .if dx==ButtonExitID jmp close .elseif dx==ButtonInquireID inquire: invoke GetWindowText,hEdit,offset year,5 call calc_year invoke MessageBox,hWnd,offset ResultStr,\ offset ResultTitle,MB_OK .endif .endif ;191 .elseif uMsg==WM_CLOSE close: invoke MessageBox,NULL,offset AskExit,\ offset AskExitTitle,MB_YESNO or MB_ICONQUESTION .if eax==IDYES invoke DestroyWindow,hWnd .endif .elseif uMsg==WM_DESTROY invoke PostQuitMessage,NULL .else def: invoke DefWindowProc,hWnd,uMsg,wParam,lParam ret .endif xor eax,eax ret WndProc endp end start
©³¤U¬O LEAPYEAR.RC ¸ê·½´yzÀɪº¤º®e¡G
#define IDM_Exit 8449 #define IDM_Clear 8450 #define IDM_Inquire 8451 #define IDM_Help 8452 LEAPYEAR MENU { POPUP "ÀÉ®×(&F)" { MENUITEM "Â÷¶}(&X)",IDM_Exit } POPUP "½s¿è(&E)" { MENUITEM "²M°£(&C)",IDM_Clear MENUITEM "¬d¸ß(&E)",IDM_Inquire } MENUITEM "»¡©ú(&H)",IDM_Help }
©³¤U¬O makefile ÀÉ¡ALEAPYEAR.MAK Àɪº¤º®e¡G
ALL:LEAPYEAR.EXE LEAPYEAR.EXE : LEAPYEAR.ASM LEAPYEAR.RES ml /coff LEAPYEAR.ASM /link /SUBSYSTEM:WINDOWS LEAPYEAR.RES LEAPYEAR.RES : LEAPYEAR.RC rc LEAPYEAR.RC
²ÕĶ³oÓµ{¦¡¡A¥u»Ý¦b DOS ¼Ò¦¡¤U¿é¤J
d:\homepage\source>nmake -f LEAPYEAR.MAK [Enter]
Microsoft (R) Program Maintenance Utility Version 1.50
Copyright (c) Microsoft Corp 1988-94. All rights reserved.
rc LEAPYEAR.RC
ml /coff LEAPYEAR.ASM /link /SUBSYSTEM:WINDOWS LEAPYEAR.RES
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997. All rights reserved.
Assembling: LEAPYEAR.ASM
Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
/SUBSYSTEM:WINDOWS /SUBSYSTEM:WINDOWS
"LEAPYEAR.obj"
"/OUT:LEAPYEAR.exe"
"LEAPYEAR.RES"
d:\homepage\source>
§Y¥i¡ANMAKE ·|¦Û°ÊÀ°§Ú̲ÕĶ¤Î³sµ²¦n¡C
LEAPYEAR.ASM ªº²Ä 11 ¨ì²Ä 14 ¦æ¬O±±¨î¤¸¥óªºÃѧO½X ( ID )¡A³o¨ÇÃѧO½X±N¤À§O¶ñ¦b WM_CREATE °T®§¤¤¡A¬°«Ø¥ßªº¥|Ó¤l±±¨î¤¸¥ó¦Ó©I¥s CreateWindowEx ªº hMenu °Ñ¼ÆùØ¡A±z¥i¥H¨ìµ{¦¡²Ä 152¡B157¡B161 ¤Î²Ä 165 ¦æÆ[¹î¬O§_¤¬¬Û°t¦X¡C
µ{¦¡²Ä 15 ¨ì²Ä 18 ¦æ¬O¿ï³æªºÃѧO½X¡A³o¨ÇÃѧO½X¥²¶·©M¸ê·½´yzÀÉ¡ALEAPYRAE.RC¡AùØ©w¸q¿ï³æªºÃѧO½X¬Û¦P¡A¦ý¬O¦]¬°¦b LEAPYEAR.RC ùبϥΤQ¶i¦ì¦Ó¦b LEAPYEAR.ASM ùبϥΤQ¤»¶i¦ì¡A©Ò¥H¥²¶·´«ºâ¨Ï¨âªÌ¼ÆȬۦP§Y¥i¡C·íµM±z¤]¥i¥H¤£¥²³o»ò³Â·Ð¡A¨Ï¥¦Ì¦P®É±Ä¥Î¤Q¶i¦ì©Î¦P®É±Ä¥Î¤Q¤»¶i¦ì¡A¦b¸ê·½ÀÉùؤQ¤»¶i¦ìªí¥Üªk±Ä¥Î C/C++ ®æ¦¡¡A¤]´N¬O¦b¼Æ¦r«e¥[¤W¡y0x¡z´NÅܦ¨¤Q¤»¶i¦ì¡A¨Ò¦p¡G
#define IDM_Exit 0x2101 #define IDM_Clear 0x2102 #define IDM_Inquire 0x2103
LEAPYEAR.ASM ªº²Ä 28 ¦æ¨ì²Ä 30 ¦æ¬O¨t²Î¤w¹w¥ý©w¸qªºµøµ¡Ãþ§O¦W¡A±N¨Ó¦b²Ä 150¡B154¡B159¡B163 ¦æ©I¥s CreateWindowEx ®É¡A¥²¶·¶ñ¤J CreateWindowEx ªº lpClassName ùØ¡C
²Ä 40 ¦æªº ResultStr ¦r¦ê¬O¥Î¨Ó¦L¥X³Ì«áªºµ²ªG¡G
µ{¦¡²Ä 55 ¦æ¨ì²Ä 67 ¦æ¬O³]©w WNDCLASSEX µ²ºcÅ骺¨CÓÄæ¦ì¡A¨Ã¦V¨t²Îµù¥U SimpleWinClass µøµ¡Ãþ§O ( ²Ä 23 ¦æ )¡A¨ä¤¤²Ä 59 ¦æ¬O³]©w¤÷µøµ¡ªºI´º¦â¡ACOLOR_BTNFACE+1¡Cµ{¦¡²Ä 78 ¦æ©I¥s TranslateMessage ¬O¥²nªº¡A§_«hµLªk¥Ñ edit ±±¨î¤¸¥ó¿é¤J¥ô¦ó¦r¤¸¡C
©³¤U§ÚÌ¥ý¬Ý¬Ý²Ä 148 ¦æ¶}©lªºµøµ¡¨ç¦¡¡CLEAPYEAR ³B²z¥|Ó°T®§¡AWM_CREATE¡BWM_COMMAND¡BWM_CLOSE ©M WM_DESTROY¡A§Ú§âµJÂI¶°¤¤¦b WM_CREATE ©M WM_COMMAND¡C
«e±¤w¸g´£¨ì¡Aµ{¦¡³]p®v¦b¼¶¼gµ{¦¡®É¡A¥i§Q¥Î¨t²Î¤w¸g©w¸q¦nªº±±¨î¤¸¥ó§@¬°¤lµøµ¡¡A¸`¬Ù³\¦h¤u§@¡A³o¨Ç¤lµøµ¡³£¦b¤÷µøµ¡è«Ø¥ß®É¤]¥ß§Y«Ø¥ß¡C©Ò¥H¤@¯ë¦Ó¨¥¡A§Ú̦b³B²z WM_CREATE °T®§®É«Ø¥ß³o¥|Ó¤lµøµ¡¡C¦¹¥~¡A¤p¤ì°¸§Æ±æ¯à°¨¤W´NÅý¨Ï¥ÎªÌ¿é¤J¦~¥÷¡A©Ò¥H¦b²Ä 167 ¦æ§Q¥Î SetFocus §â½s¿è®Ø³]¬°¿é¤JµJÂI¡A¥H±µ¦¬Áä½L¿é¤J¡C
³oÓ API ³]©wÁä½L¿é¤J¨ì¨º¤@Óµøµ¡¡A¨ä쫬¬°¡G
HWND SetFocus( HWND hWnd // handle of window to receive focus );
SetFocus ¦pªG³]©w¦¨¥\¡A·|¶Ç¦^ì¿é¤JµJÂIªºµøµ¡¥N½X¡A¨Ã¥B¹ïì¿é¤JµJÂIªºµøµ¡°e¥X WM_KILLFOCUS¡A¹ï³]©w¿é¤JµJÂIªºµøµ¡°e¥X WM_SETFOCUS¡FY¥¢±Ñ«h¶Ç¦^ NULL¡C
·í¨Ï¥ÎªÌ«ö¤U±±¨î¤¸¥ó¡B§Ö±¶Áä©ÎÂI¿ï¿ï³æ®É¡A³£·|²£¥Í WM_COMMAND °T®§¡C§ÚÌÂÇ¥Ñ lParam ¨Ó¤À¿ë«ö¤U±±¨î¤¸¥ó¡B«ö¤U¿ï³æ©Î¬O«ö¤U§Ö±¶Áä¡A¦pªG«ö¤U±±¨î¤¸¥ó«h lParam ¬°¤lµøµ¡¥N½X¡A§_«h¬°¹s ( ½Ð°Ñ¦Ò²Ä¤»³¹¦³Ãö WM_COMMAND ªº»¡©ú )¡C¨Æ¹ê¤W¡A¤£¶È«ö¶s±±¨î¤¸¥ó·|µo¥X WM_COMMAND °T®§¡Aµ´¤j³¡¥÷ªº±±¨î¤¸¥ó³£¬O¾a WM_COMMAND ±N°T®§¶Ç»¼¶Ç»¼µ¹¤÷µøµ¡¡C
·í¨Ï¥ÎªÌ«ö¤U«ö¶s±±¨î¤¸¥ó«á¡A«ö¶s±±¨î¤¸¥ó¶Çµ¹¤÷µøµ¡ªº WM_COMMAND °T®§¤¤¡A¦b wParam °Ñ¼Æùئs¦³¨Ï¥ÎªÌ¹ï«ö¶sªº°Ê§@¡A±`¥Îªº¦³¨âºØ¡GBN_CLICKED ©M BN_DOUBLECLICKED¡A«eªÌªí¥Ü¨Ï¥ÎªÌ´¿«ö¤U¹L«ö¶s¡A«áªÌªí¥Ü¨Ï¥ÎªÌ´¿³sÄò«Ü§Ö¦a«ö¤U«ö¶s¡A¤S¼u°_¨Ó¨â¦¸¡Cªþ±a¤@´£¡A¤÷µøµ¡¤]¥i¹ï«ö¶s±±¨î¤¸¥óµo¥X WM_COMMAND °T®§¡A¸Ô²Ó±¡§Î½Ð°Ñ¾\²Ä¤Q³¹¡C
·í½T©w¨Ï¥ÎªÌ¬O«ö¤U«ö¶s«á¡AÁÙn¦AÀˬd¨Ï¥ÎªÌ¬O«ö¤U¨º¤@Ó«ö¶s¡A¥i¥HÀˬd wParam ¸û§Cªº 16 ¦ì¤¸¡A³o 16 Ӧ줸Â泫ö¶sªº ID¡A¤]´N¬Oµ{¦¡²Ä 13¡B14 ¦æ©Ò©w¸qªº¡y¬d¸ß¡z¤Î¡yÂ÷¶}¡z³o¨âÓ«ö¶s ID¡C
©Ò¥H§A¥i¥H¬Ý¨ì²Ä 171 ¦æ¨ì 191 ¦æ¬O¤@Ó IF¡ÐELSE¡ÐENDIF °Ï¶ô¡A³o¬qµ{¦¡¥Î¨ÓÀˬd¨Ï¥ÎªÌÂI¿ï¿ï³æ©ÎªÌ«ö¤U«ö¶s¡C¦pªGÂI¿ï¿ï³æ«h°õ¦æ²Ä 172 ¨ì 181 ¦æ¡A³o´X¦æ¤S¬O¤@Ó IF¡ÐELSE¡ÐENDIF °Ï¶ô¡A³oÓ IF¡ÐELSE¡ÐENDIF °Ï¶ô«h¬O¨Ì¨Ï¥ÎªÌ©ÒÂI¿ïªº¿ï³æ°õ¦æ¦UÓ¤£¦Pªº¥\¯à¡C¦pªG¨Ï¥ÎªÌ«ö¤U«ö¶s«h°õ¦æ²Ä 183 ¨ì 190 ¦æ¡A³o´X¦æ¤]¬O¤@Ó IF¡ÐELSE¡ÐENDIF °Ï¶ô¡A³oӰ϶ô«h¬O¨Ì¨Ï¥ÎªÌ©Ò«ö¤Uªº«ö¶s°õ¦æ¡y¬d¸ß¡z©Î¡yÂ÷¶}¡zªº°Ê§@¡C
¿ï³æùتº¥\¯à¤j¦h´£¹L¡A¶È¦³¤@Ó SetWindowText API ¡C
SetWindowText ¬O¥Î¨Ó³]©wµøµ¡¼ÐÃD¤å¦rªº¡A°²¦p©Ò«ü©wªºµøµ¡¬O¤l±±¨î¤¸¥óªº¸Ü¡A¨º»ò´N·|§ïÅܳoÓ¤l±±¨î¤¸¥óªº¤å¦r¡A¨Ò¦p¡G¦pªG¬O«ö¶sªº¸Ü¡A´N§ïÅÜ«ö¶s¤Wªº¤å¦r¡F¦pªG¬O½s¿è®Øªº¸Ü¡A´N·|§ïÅܽs¿è®Ø¤ºªº¤å¦r¡F¦pªG¬OÀRºA±±¨î¤¸¥ó¡A´N§ïÅܨä¤å¦r¡CSetWindowText ªºì«¬¬O¡G
BOOL SetWindowText( HWND hWnd, // handle of window or control LPCTSTR lpString // address of string );
hWnd ¬O·Q§ïÅܼÐÃDªºµøµ¡¥N½X¡ClpString ¬O«ü¦V§ïÅܫ᪺¦r¦ê¦ì§}¡A¦¹¦r¦ê¥H NULL µ²§À¡C¦pªG SetWindowText °õ¦æ¦¨¥\¡AEAX ¶Ç¦^«D¹sÈ¡A¥¢±Ñ«h¶Ç¦^ NULL¡C
·í¨Ï¥ÎªÌ«ö¤U¡y²M°£¡z¿ï³æ®É¡A´N°õ¦æ¦bµ{¦¡²Ä 175 ¦æªº SetWindowText¡A¦Ó¨Ï½s¿è®Ø¤ºªº¤å¦r³]¬°ªÅ¦r¦ê¡A¹F¨ì²M°£¦r¦êªº¥Øªº¡C
»P³]©w¦r¦ê¬Û¤Ïªº¬O GetWindowText API¡C©Ò¥H·í°õ¦æ¡y¬d¸ß¡z®É¡A´N¬O°õ¦æ GetWindowText¡C´«¥y¸Ü»¡¡An¨ú±oµøµ¡¼ÐÃD¤å¦r©Î¬O¨ú±o¤l±±¨î¤¸¥óªº¤å¦r¡A¥i¥H¨Ï¥Î GetWindowText API¡C
GetWindowText API ¨ú±o«ü©wµøµ¡ªº¼ÐÃDÄæ¦r¦ê¡A°²¦p©Ò«ü©wªºµøµ¡¬O±±¨î¤¸¥óªº¸Ü¡A«h¨ú±o¨ä¤º®e¡C쫬¦p¤U¡F
int GetWindowText( HWND hWnd, // handle of window or control with text LPTSTR lpString, // address of buffer for text int nMaxCount // maximum number of characters to copy );
hWnd ¬On¨ú±oµøµ¡¼ÐÃDÄ椺®eªºµøµ¡¥N½X¡AlpString ¬O«ü©w©Ò¨ú±oªº¼ÐÃD¤º®e¦s©ñ³B¦ì§}¡AnMaxCount ¬On¨ú±oªº¼ÐÃD¤º®eªø«×¡A¥H¦ì¤¸²Õ¬°³æ¦ì¡C¦]¬°²{¦b¦è¤¸¦~¥÷³Ì¦h¤]¤£¹L¥|¦ì¼Æ¡A©Ò¥H LEAPYEAR ¶È¶È¨ú±o«e¥|¦ì¦Ó¤w¡A§Y¨Ï¨Ï¥ÎªÌ¿é¤J¶W¹L¥|¦ì¼Æ¡Aµ{¦¡¤]¶È¶È¨ú±o«e¥|¦ì¼Æ¡CLEAPYEAR «ü©w GetWindowText §â¨Ï¥ÎªÌ©Ò¿é¤Jªº¦r¦ê¦s¤J year ¦r¦êùØ¡C
°²¦p±z·Q¨ú±o¥þ³¡¿é¤J¦r¦êªº¸Ü¡A´N±o¥ýª¾¹D¿é¤Jªº¦r¦êªø«×¡A¤]¥i¥H¥Î GetWindowTextLength API ±o¨ì¦r¦êªø«×¡C
int GetWindowTextLength( HWND hWnd // handle of window or control with text );
hWnd ¬On¨ú±oµøµ¡¼ÐÃD©Î±±¨î¤¸¥ó¤º®eªºµøµ¡¥N½X¡Cªð¦^®É¨ä¤º®eªø«×¥H¦ì¤¸²Õ¬°³æ¦ì¦s©ó EAX ùØ¡Anª`·Nªº¬O¡A³oùتº EAX ¥i¤£¥]§tµ²§À¦r¤¸¡ANULL¡C
±µ¤U¨Ó«K¬O©I¥s calc_year °Æµ{¦¡¡A¦¹°Æµ{¦¡¬O¥Î¨Ó§â¥Ñ GetWindowTexet ¶Ç¦^ªº¦è¤¸¦~¥÷¦r¦êÂà´«¦¨¤Q¤»¶i¦ì¼Æ¡A¦Apºâ¦¹¤Q¤»¶i¦ì¼Æªº¦è¤¸¦~¥÷¬O§_¬°¶|¦~¡A³Ì«á¦s©ó ResultStr ¦r¦êùØ¡C¦A¨Ó«K¬O§â ResultStr ¦r¦ê¥æ¥Ñ MessageBox API Åã¥Ü¦b¿Ã¹õ¤W¡C
°²¦p±z¨Ì·Ó¤p¤ì°¸¦¹³¹ªº¤èªk¥h¼¶¼g¹ï¸Ü²°µ{¦¡¡A¨Ò¦pÄá¤ó»PµØ¤ó·Å«×ªº´«ºâ¡B¤½¤Ø»P^§`ªº´«ºâ¡B¤½¤ç»P½Sªº´«ºâ¡B¿é¤J¶ê¥b®|¨D¶ê±¿n¡B¿é¤Jªø¤è§Îªø»P¼e¨D¨ä±¿nµ¥µ¥¤pµ{¦¡¡A±z±Nµo²{±z·|ªá³\¦h®É¶¡¦b¦w±Æ³o¨Ç±±¨î¤¸¥óªº¦ì¸m¤W¡C¨ä¹ê³oÓ¤u§@¥i¥H¸g¥Ñ³\¦h¹ï¸Ü®Ø½s¿èµ{¦¡À°§Ú̧¹¦¨¡A³o¼Ë´N·|¸`¬Ù³\¦h®É¶¡¡C¤U¤@³¹±N¤¶²Ð³o¨Ç¡C
¦¹³B©Ò«üªº¶§¾ä¬O¥H¤Ó¶§¹B¦æ¬°°Ñ¦Ò©Ò¨î©wªº¾äªk¡A¦¹ºØ¾äªkÁÙ¥i¤À¬°¥¦~»P¶|¦~¡A¥¦~¨C¦~¤À¦¨ 12 Ó¤ë¡A¨CÓ¤ë±q 28 ¤Ñ¨ì 31 ¤Ñ¤£µ¥¡A¦@ 365 ¤Ñ¡G
¤@¤ë Jan. |
¤G¤ë Feb. |
¤T¤ë Mar. |
¥|¤ë Apr. |
¤¤ë May |
¤»¤ë Jun. |
¤C¤ë Jul. |
¤K¤ë Aug. |
¤E¤ë Sep. |
¤Q¤ë Oct. |
¤Q¤@¤ë Nov. |
¤Q¤G¤ë Dec. |
31 ¤Ñ | 28 ¤Ñ | 31 ¤Ñ | 30 ¤Ñ | 31 ¤Ñ | 30 ¤Ñ | 31 ¤Ñ | 31 ¤Ñ | 30 ¤Ñ | 31 ¤Ñ | 30 ¤Ñ | 31 ¤Ñ |
¶|¦~¤@¦~¦³ 366 ¤Ñ¡A¶|¦~ªº¤G¤ëÅܬ° 29 ¤Ñ¡A¨ä¾l©M¥¦~¤@¼Ë¡C¨º»ò¨º¤@¦~¬O¶|¦~©O¡H¶§¾ä¾äªk¬O¨C¥|¦~³]¸m¤@Ó¶|¦~¡A¦]¦¹¥H¦è¤¸¦~¼Æ¯à³Q¥|¾ã°£ªº¬°¶|¦~¡A¨Ò¦p¦è¤¸ 1988¡B1992¡B1996 §¡¬°¶|¦~¡A¦ý¬O¹³¦è¤¸ 1700¡B1800¡B1900¡B2100 ¦~¯à³Q¥|¾ã°£«o¤£¯à³Q 400 ¾ã°£ªº«o¤£¬O¶|¦~¡A¦Ó¦è¤¸ 1600¡B2000¡B2400 ¦~¡A¯à³Q 400 ¾ã°£ªº¤~¬O¶|¦~¡C¬Ý°_¨Ó¦n¹³«Ü½ÆÂø¡A¤p¤ì°¸µy·L¾ã²z¤@¤U¡AÀ³¸Ó¥i¥H«K²³æ¤@ÂI¡G¦è¤¸¦~¼Æ«á±¬O 00 ªº¡A¨Ò¦p 1700¡B1800¡B1900¡B2000 ¦~µ¥»Ýn¯à³Q 400 ¾ã°£ªº¤~¬O¶|¦~¡A§_«h¬O¥¦~¡F¦Ó¦è¤¸¦~¼Æ«á±¤£¬O 00 ªº¡A¥un¯à³Q¥|¾ã°£ªº´N¬O¶|¦~¡A¤£¯à³Q¥|¾ã°£ªº´N¬O¥¦~¡C
¬°¤°»ò¶|¦~ªºpºâ¤è¦¡¦p¦¹½ÆÂø©O¡H³o¬O¦]¬°¦a²y¶¤Ó¶§¤½Âà»P¦a²y¦ÛÂ઺®É¶¡¨Ã«D«ê¦n¾ã¼Æ¡A¦a²y¶¤Ó¶§¤@°é¶O®É 365.2422 ¤é¡A¦ý§Ú̾äªk¤Wªº¥¦~¥u¦³ 365 ¤Ñ¡A°²¦p¤£¥h³B²z¥Lªº¸Ü¡A¨º»ò¨C¥|¦~¤é¾ä¤Wªº¤é´Á´N·|¤ñ¦a²y¤½Âà§Ö 0.9688 ¤Ñ¡A¤j¬ù¤@¤Ñ¡A40 ¦~´N§Ö¤F 10 ¤Ñ¡A400 ¦~´N§Ö¤F 100 ¤Ñ¡A¤j¬ù§Ö¤@©u¤F¡A³o®É¦pªG¾äªk¦A¤£×¥¿¡A¨º»ò¥¿È´H·¨ë°©ªº¤@¤ë¶©¥V¤Ñ®ð®É¡A¤é¾ä¤W«oÅã¥Üªº¬O¥|¤ë¬K·xªá¶}®É¡A©ó¬O³y¦¨¤é¾ä©M¹ê»Ú®ðÔ¹HIªº±¡§Î¡A¥j¤H©Ò¿×¡y¤»¤ë³·¡z¤j·§´N¬O¾äªk¤£·Ç½TªºÃö«Y§a¡H( ¦ý¦³®É§Ú«o¹çÄ@¯u¦³©_ޮɡA¦Ñ¤Ñ¤]¸Óµoµo·O´d )
¨¥Âk¥¿¶Ç¡A°²¦p¨C¥|¦~¦h¤@¤Ñ¡A´N·|©M¹ê»Ú±¡§Î¬Û²Å¡A¦ý§Y¨Ï¦p¦¹¡AÁÙ¬O¦³»~®t¡A¦]¬°¾äªk¤Ö¤F 0.9688 ¤Ñ¡A©Ò¥H§Ö¤F 0.9688 ¤Ñ¡A²{¦b¦pªG¨C¥|¦~¦h¤@¤Ñ¡A´N·|Åܦ¨¾äªk¨C¥|¦~ºC¤F 0.0312 ¤Ñ¡A¦]¦¹¨C¥|¦Ê¦~´NºC¤F 3.12 ¤Ñ¡A¦b 400 ¦~¤º¥²¶·´î¥h¤T¤Ñ¡A³o¤T¤Ñ´N³]©w¦b¹³ 100¡B200¡B300 µLªk¬° 400 ¾ã°£ªº¦~¼ÆùØ¡C³o´N¬O¶§¾ä¾äªkªº¥Ñ¨Ó¡C