I have not done a tutorial about the assembler programming language for a while, so today I had a good reason to write this tutorial.
The tutorial focuses on using Calendar Control (MSAA UI Element Reference).
The source code of the window made in FASM is used into this tutorial.
I added the window class name for a monthly calendar which is defined as SysMonthCal32.
The file if.inc is used for message selection.
When we close the program, a closing dialog is displayed.
To run the Go to today click is displayed but I did not implement execution code.
The IDD_DLG parameter is random and I put the year of my birth to be more fun.
The program contains comments to understand the source code.
For execution, you need to add it to the FASM editor and run it with the F9 key.
You also have the executable version in the Downloads section of the main page menu.
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 | format PE GUI 5.0 entry start include 'win32a.inc' include 'macro\if.inc' ; start the program section '.code' code readable executable start: ; get handle of program ; ------------------------------ invoke GetModuleHandle,NULL mov [hInstance],eax ; An instance of the structure carrying information used to load common ; control classes. mov [iccex.dwSize],sizeof.INITCOMMONCONTROLSEX mov [iccex.dwICC],ICC_DATE_CLASSES invoke InitCommonControlsEx,iccex ;start dialogue invoke DialogBoxParam,[hInstance],IDD_DLG,NULL,DialogProc,NULL ;stop the program invoke ExitProcess,0 proc DialogProc uses ebx esi edi, @hDlg , @uMsg , @wParam , @lParam .if [@uMsg] = WM_CLOSE ; show the end message invoke MessageBox,[@hDlg],MsgEnd,ClassName,MB_OK+MB_ICONINFORMATION ; stop the program invoke EndDialog,[@hDlg],0 .elseif [@uMsg] = WM_INITDIALOG invoke SendMessage,[@hDlg],WM_SETICON,ICON_SMALL,eax .else mov eax,0 ret .endif mov eax,1 ret endp ; data section '.data' data readable writeable ClassName db ' Exit calendar 2017',0 MsgEnd db ' free-tutorial.org @2017 ',0 align 4 hInstance dd ? iccex INITCOMMONCONTROLSEX ;include files section '.idata' import data readable writeable library kernel32,'KERNEL32.DLL',\ user32,'USER32.DLL',\ comctl32,'COMCTL32.DLL' ; Apis Windows dans fichiers dlls ; ------------------------------- include 'api/kernel32.inc' include 'api/user32.inc' include 'api/comctl32.inc' ; include resources ( like icons dialogs ) section '.rsrc' resource data readable directory RT_DIALOG,dialogs IDD_DLG = 1976 resource dialogs,\ IDD_DLG,LANG_ENGLISH+SUBLANG_DEFAULT,dlg dialog dlg,'Calendar 2017',0,0,139,106,WS_SYSMENU+WS_VISIBLE+DS_CENTER+WS_CAPTION+\ WS_MINIMIZEBOX ;The window class name for a month calendar control is MONTHCAL_CLASS, ;which is defined as "SysMonthCal32" in Commctrl.h. dialogitem 'SysMonthCal32','',0,3,0,132,103,WS_VISIBLE,WS_EX_CLIENTEDGE enddialog ;end the source code |