;-tbar.asm------------------------------------------------------------------- ; x86 - Dos & Win32 - Assembly Language Programming ; ; ; ; Written by: John A Lyons ; ; Email : sysop@megablast.8k.com ; ; Page : http://www.asmsource.8k.com/ ; ; Compiler : Masm32 v6.13 Microsoft Macro Assembler ; ; Date : 17-Jan-2001 ; ; Purpose : Incorporates a toolbar into our program, and print out the ; ; selected code. Demonstrates CreatToolbarEx function ; ; ; ; Thanks to GE2001@yahoo.com and his program td_win32asm_022 ; ; available at http://surf.to/TestD. ; ; ; ;---------------------------------------------------------------------------- ; Compile with nmake ; .386 .MODEL FLAT , STDCALL include windows.inc include user32.inc include kernel32.inc include gdi32.inc include comctl32.inc includelib user32.lib includelib kernel32.lib includelib gdi32.lib includelib comctl32.lib EXTRN wsprintfA:PROC .data ClassName db "SimpleWinClass",0 AppName db "Tbar",0 TestString db "Toolbar",0 num db "%lu",0 hInstance HINSTANCE ? CommandLine LPSTR ? hwnd HWND ? toolbarhand DWORD ? counter DWORD ? buff db 200 dup(0) toolinfo dd 0h,0C0h db TBSTATE_ENABLED db TBSTYLE_BUTTON dw 0 dd 0,0 dd 1h,0c1h db TBSTATE_ENABLED db TBSTYLE_BUTTON dw 0 dd 0,0 dd 2h,0c2h db TBSTATE_ENABLED db TBSTYLE_BUTTON dw 0 dd 0,0 dd 3h,0c3h db TBSTATE_ENABLED db TBSTYLE_BUTTON dw 0 dd 0,0 .code WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:SDWORD LOCAL wc:WNDCLASSEX LOCAL msg:MSG mov wc.cbSize,SIZEOF WNDCLASSEX mov wc.style, CS_HREDRAW or CS_VREDRAW mov wc.lpfnWndProc, OFFSET WndProc mov wc.cbClsExtra,NULL mov wc.cbWndExtra,NULL push hInstance pop wc.hInstance mov wc.hbrBackground,COLOR_WINDOW+1 mov wc.lpszMenuName,NULL mov wc.lpszClassName,OFFSET ClassName invoke LoadIcon,NULL,IDI_APPLICATION mov wc.hIcon,eax mov wc.hIconSm,0 invoke LoadCursor,NULL,IDC_ARROW mov wc.hCursor,eax invoke RegisterClassEx, addr wc INVOKE CreateWindowEx,NULL,ADDR ClassName,ADDR AppName,\ WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,CW_USEDEFAULT, 300,100, ;size NULL,NULL,\ hInst,NULL mov hwnd,eax push 14h ; push 14h ; push 14h push 1fh push 1fh push 0h push 0h ; push 6h push 4h push OFFSET toolinfo push 80h push hInstance ; push 14 push 4h push 300h push 54000521h push hwnd call CreateToolbarEx mov toolbarhand,eax INVOKE ShowWindow, hwnd,SW_SHOWNORMAL INVOKE UpdateWindow, hwnd .WHILE TRUE INVOKE GetMessage, ADDR msg,NULL,0,0 .BREAK .IF (!eax) INVOKE TranslateMessage, ADDR msg INVOKE DispatchMessage, ADDR msg .ENDW mov eax,msg.wParam ret WinMain endp count proc push esi mov eax,0 noc2: cmp [esi],byte ptr 0 je noc1 inc esi inc eax jmp noc2 noc1: mov [counter],eax pop esi ret count endp WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM LOCAL hdc:HDC LOCAL ps:PAINTSTRUCT mov eax,uMsg .IF eax==WM_DESTROY invoke PostQuitMessage,NULL .ELSEIF eax==WM_PAINT invoke BeginPaint,hWnd, ADDR ps mov hdc,eax invoke TextOut,hdc,0,0,ADDR TestString,(SIZEOF TestString) -1 invoke EndPaint,hWnd, ADDR ps .ELSEIF eax==WM_SIZE ; push 0h ; push 0h ; push 421h ; push toolbarhand ; call SendMessageA invoke SendMessageA,toolbarhand,421h,0,0 .ELSEIF eax==WM_COMMAND invoke GetDC,hWnd mov hdc,eax mov eax,wParam push eax push offset num push offset buff call wsprintfA add esp,0ch lea esi,buff call count invoke TextOut,hdc,0,50,esi,counter invoke EndPaint,hWnd, ADDR ps .ELSE invoke DefWindowProc,hWnd,uMsg,wParam,lParam ret .ENDIF xor eax,eax ret WndProc endp start: invoke GetModuleHandle, NULL mov hInstance,eax invoke GetCommandLine invoke WinMain, hInstance,NULL,CommandLine, SW_SHOWDEFAULT invoke ExitProcess,eax end start