Sie sind auf Seite 1von 21

td_win32asm_021.

asm
;==============================================================================
;
Test Departments WINDOWS 32 BIT x86 ASSEMBLY examples
021
;==============================================================================
;==============================================================================
; ==> Part 021 : creating a customize toolbar with bitmaps and tooltiptext
;-----------------------------------------------------------------------------; This is a teamwork between :
; Ren Tournois
--> http://betov.free.fr/SpAsm.html
; SpAsm source + exe
; Test Department --> http://crahkob.com/td
; MASM32 source + exe
;
;
; Test Department
td@crahkob.com
;
; enjoy
;==============================================================================
; Assembler directives
;-----------------------------------------------------------------------------.386
; specifies the processor our program want run on
.Model Flat ,StdCall
; always the same for Win95 (32 Bit)
option casemap:none
; case sensitive !!!
;==============================================================================
; Include files where API functins resist you want use, set the correct path
;-----------------------------------------------------------------------------include D:\Masm32\include\windows.inc
includelib kernel32.lib
includelib user32.lib
includelib comctl32.lib
;==============================================================================
; Declaration of used API functions,take a look into WIN32.HLP and *.inc files
;-----------------------------------------------------------------------------GetModuleHandleA
PROTO :DWORD
LoadIconA
PROTO :DWORD,:DWORD
LoadCursorA
PROTO :DWORD,:DWORD
RegisterClassExA
PROTO :DWORD
CreateWindowExA
PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,
:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
ShowWindow
PROTO :DWORD,:DWORD
UpdateWindow
PROTO :DWORD
GetMessageA
PROTO :DWORD,:DWORD,:DWORD,:DWORD
TranslateMessage
PROTO :DWORD
DispatchMessageA
PROTO :DWORD
PostQuitMessage
PROTO :DWORD
DefWindowProcA
PROTO :DWORD,:DWORD,:DWORD,:DWORD
ExitProcess
PROTO :DWORD
MessageBoxA
PROTO :DWORD,:DWORD,:DWORD,:DWORD
SendMessageA
PROTO :DWORD,:DWORD,:DWORD,:DWORD
InitCommonControls
PROTO
CreateToolbarEx
PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,
:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
Page 1

td_win32asm_021.asm
lstrcpy

PROTO :DWORD,:DWORD

;==============================================================================
; .const = the constants area starts here,constants are defined and fixed
;-----------------------------------------------------------------------------.const
; - Parameter MAIN WINDOW CallBack Procedure ( API=RegisterClassExA ) WP1_CallBack
equ [ebp+4]
;return address
WP1_hWnd
equ [ebp+8]
;handle of window who receives message
WP1_uMsg
equ [ebp+12]
;the message number
WP1_wParam
equ [ebp+16]
;extra info about the message
WP1_lParam
equ [ebp+20]
;extra info about the message
;==============================================================================
; .Data = the data area starts here, datas are defined but not fixed
;-----------------------------------------------------------------------------.Data
IconName
db "TDIcon",0
;icon name in rc file
MenuName
db "TDMenu",0
;menu name in rc file
ClassName
db "TDWinClass",0
;name of windows class
WindowName
db "Test Department",0
;window name titel bar
MB1Titel
db "Toolbar Help",0
;message box name
MB1Text
db "Doubleclick the toolbar to enter customize mode.",0
MB2Titel
db "Message Box",0
;message box name
MB2Text
db "Toolbar Button clicked",0;message box text
toolbar00_str_00
db "Stoned",0
;toolbar button text
toolbar00_str_01
db "World",0
;
toolbar00_str_02
db "van Gogh",0
;
toolbar00_str_03
db "Apple",0
;
toolbar00_str_04
db "Ball",0
;
toolbar00_str_05
db "Sandra",0
;
toolbar00_str_06
db "Pamela",0
;toolbar button text
toolbar00_str_07
db "Balloon",0
;toolbar button text
toolbar00_str_08
db "Insect",0
;
toolbar00_str_09
db "Timer",0
;
toolbar00_str_10
db "Mona Lisa",0
;
toolbar00_str_11
db "Wizzard",0
;
toolbar00_str_12
db "Book",0
;
toolbar00_str_13
db "Exit",0
;toolbar button text
toolbar00_hWnd
dd 0h
;handle of the toolbar
align 4
; - TBBUTTON structure ( API=CreateToolbarEx ) - ARRAY !!!
iBitmap_s0
dd 0h
;zero-based index of button image
idCommand_s0
dd 0h
;ID or, if fsStyle=TBSTYLE_SEP, zero
fsState_s0
db 4h
;state flags,4h=TBSTATE_ENABLED
fsStyle_s0
db 1h
;button style,1h=TBSTYLE_SEP
bReserved_s0
dw 1h dup (0)
;reserved bytes,error in WIN32.HLP ?
dwData_s0
dd 0h
;application-defined value
iString_s0
dd 0h
;zero-based index of button string
iBitmap_00
idCommand_00

dd 0h
dd 0C0h

;zero-based index of button image


;ID of button, WM_COMMAND uMsg/wParam
Page 2

fsState_00
fsStyle_00
bReserved_00
dwData_00
iString_00

db
db
dw
dd
dd

4h
0h
1h dup (0)
0h
0h

iBitmap_01
idCommand_01
fsState_01
fsStyle_01
bReserved_01
dwData_01
iString_01

dd
dd
db
db
dw
dd
dd

1h
0C1h
4h
0h
1h dup (0)
0h
0h

iBitmap_02
idCommand_02
fsState_02
fsStyle_02
bReserved_02
dwData_02
iString_02

dd
dd
db
db
dw
dd
dd

2h
0C2h
4h
0h
1h dup (0)
0h
0h

iBitmap_03
idCommand_03
fsState_03
fsStyle_03
bReserved_03
dwData_03
iString_03

dd
dd
db
db
dw
dd
dd

3h
0C3h
4h
0h
1h dup (0)
0h
0h

iBitmap_04
idCommand_04
fsState_04
fsStyle_04
bReserved_04
dwData_04
iString_04

dd
dd
db
db
dw
dd
dd

4h
0C4h
4h
0h
1h dup (0)
0h
0h

iBitmap_05
idCommand_05
fsState_05
fsStyle_05
bReserved_05
dwData_05
iString_05

dd
dd
db
db
dw
dd
dd

5h
0C5h
4h
0h
1h dup (0)
0h
0h

iBitmap_s1
idCommand_s1
fsState_s1
fsStyle_s1
bReserved_s1
dwData_s1
iString_s1

dd
dd
db
db
dw
dd
dd

0h
0h
4h
1h
1h dup (0)
0h
0h

td_win32asm_021.asm
;state flags,4h=TBSTATE_ENABLED
;button style,0h=TBSTYLE_BUTTON
;reserved bytes,error in WIN32.HLP ?
;application-defined value
;zero-based index of button string

;zero-based index of button image


;ID or, if fsStyle=TBSTYLE_SEP, zero
;state flags,4h=TBSTATE_ENABLED
;button style,1h=TBSTYLE_SEP
;reserved bytes,error in WIN32.HLP ?
;application-defined value
;zero-based index of button string
Page 3

td_win32asm_021.asm
iBitmap_06
idCommand_06
fsState_06
fsStyle_06
bReserved_06
dwData_06
iString_06

dd
dd
db
db
dw
dd
dd

6h
0C6h
4h
0h
1h dup (0)
0h
0h

iBitmap_07
idCommand_07
fsState_07
fsStyle_07
bReserved_07
dwData_07
iString_07

dd
dd
db
db
dw
dd
dd

7h
0C7h
4h
0h
1h dup (0)
0h
0h

iBitmap_08
idCommand_08
fsState_08
fsStyle_08
bReserved_08
dwData_08
iString_08

dd
dd
db
db
dw
dd
dd

8h
0C8h
4h
0h
1h dup (0)
0h
0h

iBitmap_09
idCommand_09
fsState_09
fsStyle_09
bReserved_09
dwData_09
iString_09

dd
dd
db
db
dw
dd
dd

9h
0C9h
4h
0h
1h dup (0)
0h
0h

iBitmap_10
idCommand_10
fsState_10
fsStyle_10
bReserved_10
dwData_10
iString_10

dd
dd
db
db
dw
dd
dd

0Ah
0CAh
4h
0h
1h dup (0)
0h
0h

iBitmap_11
idCommand_11
fsState_11
fsStyle_11
bReserved_11
dwData_11
iString_11

dd
dd
db
db
dw
dd
dd

0Bh
0CBh
4h
0h
1h dup (0)
0h
0h

iBitmap_12
idCommand_12
fsState_12
fsStyle_12

dd
dd
db
db

0Ch
0CCh
4h
0h

;zero-based index of button image


;ID of button, WM_COMMAND uMsg/wParam
;state flags,4h=TBSTATE_ENABLED
;button style,0h=TBSTYLE_BUTTON
;reserved bytes,error in WIN32.HLP ?
;application-defined value
;zero-based index of button string

Page 4

td_win32asm_021.asm
bReserved_12
dwData_12
iString_12

dw 1h dup (0)
dd 0h
dd 0h

iBitmap_13
idCommand_13
fsState_13
fsStyle_13
bReserved_13
dwData_13
iString_13

dd
dd
db
db
dw
dd
dd

0Dh
0CDh
4h
0h
1h dup (0)
0h
0h

;zero-based index of button image


;ID of button, WM_COMMAND uMsg/wParam
;state flags,4h=TBSTATE_ENABLED
;button style,0h=TBSTYLE_BUTTON
;reserved bytes,error in WIN32.HLP ?
;application-defined value
;zero-based index of button string

;==============================================================================
; .Data? = the data? area starts here, not defined and not fixed
;-----------------------------------------------------------------------------.data?
align 4
; - WndClassEx Structure ( API=RegisterClassExA ) cbSize
dd ?
;size in bytes of this structure
style
dd ?
;window style
lpfnWndProc
dd ?
;address of user proc function
cbclsExtra
dd ?
;extra bytes to allocate set to 0
cbWndExtra
dd ?
;extra bytes class directive, rc file
hInstance
dd ?
;program handle(API=GetModuleHandleA)
hIcon
dd ?
;handle of icon (API=LoadIconA)
hcursor
dd ?
;handle of cursor (API=LoadCursor)
hbrBackground
dd ?
;background color, 0=transparent
lpszMenuName
dd ?
;name of menu class in resource file
lpszClassName
dd ?
;name of windows this window class
hIconSm
dd ?
;iconhandle 0=search in resource file
align 4
; - Msg Structure ( API=GetMessageA ) - member POINT = POINT structure
hWnd
dd ?
;handle of window who receives message
message
dd ?
;the message number
wParam
dd ?
;extra info about the message
lParam
dd ?
;extra info about the message
time
dd ?
;time the message was posted
xpt
dd ?
;cursor x-position, POINT struc
ypt
dd ?
;cursor x-position, POINT struc
;==============================================================================
; .CODE = our code area starts here
Main = label of our program code
;-----------------------------------------------------------------------------.Code
Main:
;==============================================================================
; Always get your program ID first (API=GetModuleHandleA)
;-----------------------------------------------------------------------------push
0h
;lpModuleHandle, 0=get program handle
call
GetModuleHandleA
;- API Function mov
hInstance,eax
;return value in eax=handle of program
Page 5

td_win32asm_021.asm
;==============================================================================
; API "CreateToolbarEx" is part of common controls, force to init...
;-----------------------------------------------------------------------------call
InitCommonControls
;- API Function ;==============================================================================
; The API function "RegisterClassExA" registers a window class
; This API needs a "WNDCLASSEX" structure so we fill it with correct values
;-----------------------------------------------------------------------------mov
cbSize,30h
;size in bytes of WNDCLASSEX structure
mov
style,3h
;window style
mov
lpfnWndProc,OFFSET WP1
;address of user lpfnWndProc function
mov
cbclsExtra,0h
;extra bytes to allocate set to 0
mov
cbWndExtra,0h
;class directive in rc file
mov
hbrBackground,2h
;background,1=background(parameter+1)
mov
lpszMenuName,OFFSET MenuName
;menu name in resource file
mov
lpszClassName,OFFSET ClassName ;name of windows class
mov
hIconSm,0h
;iconhandle 0=search in rc file
;-----------------------------------------------------------------------------; API "LoadIconA" loads an icon defined in the resource file and store the
; handle in the "WNDCLASSEX" structure
;-----------------------------------------------------------------------------push
OFFSET IconName
;icon-string or icon resource id
push
hInstance
;our program handle
call
LoadIconA
;- API Function mov
hIcon,eax
;handle of newly loaded icon
;-----------------------------------------------------------------------------; API "LoadCursorA" loads a default system cursor, in this case we must set
; hInstance to 0 and lpCursorName to a default system cursor value, here 32512
; Then we store the cursor handle in the "WNDCLASSEX" structure
;-----------------------------------------------------------------------------push
32512
;lpCursorName,default value in dezimal
push
0h
;hInstance, 0=default system cursor
call
LoadCursorA
;- API Function mov
hcursor,eax
;handle of the cursor
;-----------------------------------------------------------------------------; Now, after filled the "WNDCLASSEX" structure we call API "RegisterClassEx"
;-----------------------------------------------------------------------------push
OFFSET cbSize
;pointer to WNDCLASSEX structure
call
RegisterClassExA
;- API Function ;==============================================================================
; API "CreateWindowExA" creates an overlapped, pop-up, or child window with an
; extended style. The return value in EAX is the handle of the new window.
; This API sends a WM_CREATE message to the window procedure (WP1) !
;-----------------------------------------------------------------------------push
0h
;lpParam, extra pointer data 0=no data
push
hInstance
;hInstance, handle of our program
push
0h
;hMenu, handle window menu 0=class menu
push
0h
;hWndParent, handle parent window 0=no
push
000000F8h
;intnHeight, window height pixel
push
0000020Ah
;intnWidth, window width pixel
Page 6

push
push
push
push
push
push
call
mov

000000A0h
000000B0h
04CA0000h
OFFSET WindowName
OFFSET ClassName
0100h
CreateWindowExA
hWnd,eax

td_win32asm_021.asm
;inty, vertical position window
;intx, horizontal position window
;dwStyle, 0=no sysmenu/close buttons
;lpWindowName, pointer to window name
;lpClassName, pointer to class name
;dwExStyle, extra window style 0=no
;- API Function ;hwnd,return value=handle of window

;==============================================================================
; API "ShowWindow" function sets the specified window's show state.
;-----------------------------------------------------------------------------push
1h
;nCmdShow, show state 1=SW_SHOWNORMAL
push
hWnd
;hwnd, handle of window
call
ShowWindow
;- API Function ;==============================================================================
; API "UpdateWindow" updates the area of the specified window by sending a
; WM_PAINT message to the window if the window's update region is not empty.
;-----------------------------------------------------------------------------push
hWnd
;hwnd, handle of window
call
UpdateWindow
;- API Function ;==============================================================================
; API "GetMessageA" retrieves a message & places it in the specified structure.
;-----------------------------------------------------------------------------LoopGetMessage:
push
0h
;wMsgFilterMax, highest message value
push
0h
;wMsgFilterMin, lowest message value
push
0h
;hWnd, handle of window who gets msg.
push
OFFSET hWnd
;lpMsg, pointer to MSG structure
call
GetMessageA
;- API Function cmp
eax,0h
;check if return value=0 (exit)
je
ExitPrg
;if return value is 0 goto LABEL
;==============================================================================
; API "TranslateMessage" translates key code into ASCII character messages
;-----------------------------------------------------------------------------push
OFFSET hWnd
;lpMSG, pointer to msg structure
call
TranslateMessage
;- API Function - keyboard code
;==============================================================================
; API "DispatchMessageA" function dispatches a message to a window procedure.
;-----------------------------------------------------------------------------push
OFFSET hWnd
;lpMSG, pointer to msg structure
call
DispatchMessageA
;- API Function jmp
LoopGetMessage
;check for message again, goto LABEL
;==============================================================================
; Next we terminate our program (API=ExitProcess)
;-----------------------------------------------------------------------------ExitPrg:
push
hInstance
;push our programm handle to exit
Page 7

call

ExitProcess

td_win32asm_021.asm
;- API Function -

;##############################################################################
; The Window Procedure (API=RegisterClassExA) for this registered window.
;-----------------------------------------------------------------------------WP1:
push
ebp
;create stack frame
mov
ebp,esp
;
pushad
;push all register to the stack
mov
eax,WP1_uMsg
;move the message number to eax
;==============================================================================
; WM_CREATE (value=01h) message received ?, posted by main API=CREATEWINDOWEX
;-----------------------------------------------------------------------------WP1_uMsg_01h:
cmp
eax,1h
;check if WM_CREATE message recieved
jne
WP1_uMsg_02h
;if not goto label
;-----------------------------------------------------------------------------; API "CreateToolbarExA" creates a child window ( TOOLBAR ).
; Set "uStructSize" to 14h, not 12h because bReserved bytes, bug in WIN32.HLP ?
; Take a look to TBBUTTON structure in the .DATA area above.
; Parameter "ws" defines the child windows style; it also enables tooltiptext.
; In "wID" we PUSH the ID of the child window ( a value of your your choice ).
; Take a look into WIN32.HLP ( CreateToolbarEx ) and Windows.inc.
; The return value in EAX is the handle of the created toolbar.
;-----------------------------------------------------------------------------push
14h
;uStructSize,size TBBUTTON structure
push
14h
;dyBitmap,height pixels of the images
push
14h
;dxBitmap,width pixels of the images
push
0h
;dyButton,height pixels of the buttons
push
0h
;dxButton,width pixels of the buttons
push
8h
;iNumButtons,Number buttons in toolbar
push
OFFSET iBitmap_s0
;lpButtons,pointer TBBUTTON structure
push
80h
;wBMID,ID for the bitmap resource
push
hInstance
;hBMInst,instance bitmap resource
push
1h
;nBitmaps,number of button image file
push
300h
;wID,control identifier for toolbar
push
54000520h
;ws,windows styles in WIN32.HLP
;CCS_ADJUSTABLE = 20h for customize
push
WP1_hWnd
;hwnd,handle owner window 0=no owner
call
CreateToolbarEx
;- API Function mov
toolbar00_hWnd,eax
;handle of toolbar child window
;-----------------------------------------------------------------------------; API "ShowWindow" function sets the specified window's show state.
;-----------------------------------------------------------------------------push
5h
;nCmdShow, show state 5h=SW_SHOW
push
toolbar00_hWnd
;hwnd, handle of window
call
ShowWindow
;- API Function jmp
WP1_return
;==============================================================================
; WM_DESTROY (value=02h) message received ?
;-----------------------------------------------------------------------------Page 8

td_win32asm_021.asm
WP1_uMsg_02h:
cmp
eax,2h
;check if value=2h (WM_DESTROY)
jne
WP1_uMsg_05h
;if not 2h go to LABEL
call
My_CleanSystem
;- SubRoutine ;-----------------------------------------------------------------------------; API "PostQuitMessage" indicates to Windows a request to terminate
;-----------------------------------------------------------------------------push
0h
;nExitCode, exit code=wParam
call
PostQuitMessage
;- API Function popad
;pop all register back from stack
xor
eax,eax
;set eax to 0 to exit our program
mov
esp,ebp
;delete stack frame
pop
ebp
;
ret
10h
;return and clear stack
;==============================================================================
; WM_Size (value=05h) message, used to resize the window area
;-----------------------------------------------------------------------------WP1_uMsg_05h:
cmp
eax,05h
;check if WP_SIZE message recieved
jne
WP1_uMsg_4Eh
;if not goto label
;-----------------------------------------------------------------------------; API "SendMessageA" sends a message, TB_AUTOSIZE to fit toolbar and bitmaps
;-----------------------------------------------------------------------------push
0h
;lParam, second message parameter
push
0h
;wParam, first message parameter (ID)
push
421h
;uMsg, send TB_AUTOSIZE message
push
toolbar00_hWnd
;hwnd, handle of destination window
call
SendMessageA
;- API Function jmp
WP1_return
;==============================================================================
; WM_NOTIFY (value=4Eh) message, here used to show the toolbar tip !
; With a WM_NOTIFY message Windows gives you pointer to a NMHDR structure.
;-----------------------------------------------------------------------------WP1_uMsg_4Eh:
cmp
eax,4Eh
;check if WM_NOTIFY message recieved
jne
WP1_uMsg_111h
;if not goto label
;-----------------------------------------------------------------------------; The NMHDR structure contains information about a notification message.
; The TOOLTIPTEXT structure identifies a tool for which text is to be displayed
; and receives the text for the tool.
; We must fill it with the CORRECT values ...
; The POINTER to this structure is specified as lParam member of WM_NOTIFY.
; This POINTER is given to us with the WM_NOTIFY message by Windows.
;-----------------------------------------------------------------------------; - NMHDR structure ; hwndFrom = [WP1_lParam+0]
;handle to control sending message
; idFrom
= [WP1_lParam+4]
;identifier of control sending message
; code
= [WP1_lParam+8]
;notification code
; - TOOLTIPTEXT structure ; hdr
= placeholder for NMHDR
;required for all WM_NOTIFY messages
; lpszText = [WP1_lParam+12]
;Pointer string or resource ID
Page 9

td_win32asm_021.asm
; szText[80]= [WP1_lParam+16]
;buffer for text, alternate to lpszText
; hinst
= [WP1_lParam+20]
;handle instance, 0 if lpszText=pointer
; uFlags
= [WP1_lParam+24]
;Flag indicates how to interpret idFrom
;-----------------------------------------------------------------------------mov
ebx,WP1_lParam
;pointer to struc, given by windows !
mov
eax,[ebx+8]
;move code ( NMHDR structure ) into eax
cmp
eax,0FFFFFDF8h
;check if code TTN_NEEDTEXT received
jne
TB_customize_1
;if not goto label
mov
eax,[ebx+4]
;move idFrom ( NMHDR structure ) to eax
cmp
eax,0C0h
;is it toolbar button ID=0C1h
jne
next_01
;if not goto label
mov
[ebx+12],OFFSET toolbar00_str_00;move our text pointer to lpszText
;lpsz is part of TOOLTIPTEXT structure
next_01:
cmp
eax,0C1h
;is it toolbar button ID=0C2
jne
next_02
;if not goto label
mov
[ebx+12],OFFSET toolbar00_str_01;move our text pointer to lpszText
next_02:
cmp
eax,0C2h
;is it toolbar button ID=0C3
jne
next_03
;if not goto label
mov
[ebx+12],OFFSET toolbar00_str_02;move our text pointer to lpszText
next_03:
cmp
eax,0C3h
;is it toolbar button ID=0C4
jne
next_04
;if not goto label
mov
[ebx+12],OFFSET toolbar00_str_03;move our text pointer to lpszText
next_04:
cmp
eax,0C4h
;is it toolbar button ID=0C5
jne
next_05
;if not goto label
mov
[ebx+12],OFFSET toolbar00_str_04;move our text pointer to lpszText
next_05:
cmp
eax,0C5h
;is it toolbar button ID=0C6
jne
next_06
;if not goto label
mov
[ebx+12],OFFSET toolbar00_str_05;move our text pointer to lpszText
next_06:
cmp
eax,0C6h
;is it toolbar button ID=0C8
jne
next_07
;if not goto label
mov
[ebx+12],OFFSET toolbar00_str_06;move our text pointer to lpszText
next_07:
cmp
eax,0C7h
;is it toolbar button ID=0C2
jne
next_08
;if not goto label
mov
[ebx+12],OFFSET toolbar00_str_07;move our text pointer to lpszText
next_08:
cmp
eax,0C8h
;is it toolbar button ID=0C3
jne
next_09
;if not goto label
mov
[ebx+12],OFFSET toolbar00_str_08;move our text pointer to lpszText
next_09:
cmp
eax,0C9h
;is it toolbar button ID=0C4
jne
next_10
;if not goto label
mov
[ebx+12],OFFSET toolbar00_str_09;move our text pointer to lpszText
next_10:
cmp
eax,0CAh
;is it toolbar button ID=0C5
jne
next_11
;if not goto label
mov
[ebx+12],OFFSET toolbar00_str_10;move our text pointer to lpszText
Page 10

td_win32asm_021.asm
next_11:
cmp
eax,0CBh
;is it toolbar button ID=0C6
jne
next_12
;if not goto label
mov
[ebx+12],OFFSET toolbar00_str_11;move our text pointer to lpszText
next_12:
cmp
eax,0CCh
;is it toolbar button ID=0C8
jne
next_13
;if not goto label
mov
[ebx+12],OFFSET toolbar00_str_12;move our text pointer to lpszText
next_13:
cmp
eax,0CDh
;is it toolbar button ID=0C8
jne
next_14
;if not goto label
mov
[ebx+12],OFFSET toolbar00_str_13;move our text pointer to lpszText
next_14:
jmp
WP1_return
;go out of here
TB_customize_1:
;-----------------------------------------------------------------------------; The NMHDR structure contains information about a notification message.
; The TBNOTIFY structure contains information used to process notification
; messages from a toolbar.
; The POINTER to this structure is specified as lParam member of WM_NOTIFY.
; This POINTER is given to us with the WM_NOTIFY message by Windows.
;-----------------------------------------------------------------------------; - NMHDR structure ; hwndFrom = [WP1_lParam+0]
;handle to control sending message
; idFrom
= [WP1_lParam+4]
;identifier of control sending message
; code
= [WP1_lParam+8]
;notification code
; - TBNOTIFY structure ; hdr
= placeholder for NMHDR
;required for all WM_NOTIFY messages
; IItem
= [WP1_lParam+12]
;index button associated with notifica.
; iBitmap
= [WP1_lParam+16]
;tbbutton, TBBUTTON structure
; idCommand = [WP1_lParam+20]
;
; fsState
= [WP1_lParam+24]
;
; fsStyle
= [WP1_lParam+25]
;
; bReserved = [WP1_lParam+26]
;
; dwData
= [WP1_lParam+28]
;
; iString
= [WP1_lParam+32]
;
; cchText
= [WP1_lParam+36]
;count of characters in the button text
; pszText
= [WP1_lParam+40]
;address of the button text
;-----------------------------------------------------------------------------cmp
eax,0FFFFFD3Eh;0-700-6
;check if code TBN_QUERYINSERT received
jne
TB_customize_2
jmp
WP1_return_1
TB_customize_2:
cmp
eax,0FFFFFD3Dh;0-700-7
jne
TB_customize_3
jmp
WP1_return_1

;check if code TBN_QUERYDELETE received

TB_customize_3:
cmp
eax,0FFFFFD3Ch;0-700-8
;check if code TBN_TOOLBARCHANGE recei.
jne
TB_info_00
;-----------------------------------------------------------------------------Page 11

td_win32asm_021.asm
; API "SendMessageA", TB_SETBUTTONSIZE sets the size of the buttons to be added
;-----------------------------------------------------------------------------push
00140014h
;lParam, dxbutton, dybutton
push
0h
;wParam, first message parameter
push
41Fh
;uMsg, send TB_SETBUTTONSIZE message
push
toolbar00_hWnd
;hwnd, handle of destination window
call
SendMessageA
;- API Function jmp
WP1_return
TB_info_00:
cmp
eax,0FFFFFD44h;0-700-0
;check if code TBN_GETBUTTONINFO recei.
jne
WP1_return_1
mov
eax,[ebx+12]
;check IItem, index !
cmp
eax,0h
jne
TB_info_01
mov
eax,iBitmap_00
;fill TBBUTTON structure !
mov
[ebx+16],eax
mov
eax,idCommand_00
mov
[ebx+20],eax
mov
al,fsState_00
mov
[ebx+24],al
mov
al,fsStyle_00
mov
[ebx+25],al
mov
ax,bReserved_00
mov
[ebx+26],ax
mov
eax,dwData_00
mov
[ebx+28],eax
mov
eax,iString_00
mov
[ebx+32],eax
mov
eax,6h
mov
[ebx+36],eax
;-----------------------------------------------------------------------------; API "lstrcpy" copies a string to a buffer
;-----------------------------------------------------------------------------push
OFFSET toolbar00_str_00
;lpString2, address of string to copy
push
[ebx+40]
;lpString1, address of buffer
call
lstrcpy
;- API Function jmp
WP1_return_1
TB_info_01:
cmp
eax,1h
jne
TB_info_02
mov
eax,iBitmap_01
mov
[ebx+16],eax
mov
eax,idCommand_01
mov
[ebx+20],eax
mov
al,fsState_01
mov
[ebx+24],al
mov
al,fsStyle_01
mov
[ebx+25],al
mov
ax,bReserved_01
mov
[ebx+26],ax
mov
eax,dwData_01

;check IItem, index


;fill TBBUTTON structure ...

Page 12

td_win32asm_021.asm
mov
[ebx+28],eax
mov
eax,iString_01
mov
[ebx+32],eax
mov
eax,5h
mov
[ebx+36],eax
;-----------------------------------------------------------------------------; API "lstrcpy" copies a string to a buffer
;-----------------------------------------------------------------------------push
OFFSET toolbar00_str_01
;lpString2, address of string to copy
push
[ebx+40]
;lpString1, address of buffer
call
lstrcpy
;- API Function jmp
WP1_return_1
TB_info_02:
cmp
eax,2h
jne
TB_info_03
mov
eax,iBitmap_02
mov
[ebx+16],eax
mov
eax,idCommand_02
mov
[ebx+20],eax
mov
al,fsState_02
mov
[ebx+24],al
mov
al,fsStyle_02
mov
[ebx+25],al
mov
ax,bReserved_02
mov
[ebx+26],ax
mov
eax,dwData_02
mov
[ebx+28],eax
mov
eax,iString_02
mov
[ebx+32],eax
mov
eax,8h
mov
[ebx+36],eax
;-----------------------------------------------------------------------------; API "lstrcpy" copies a string to a buffer
;-----------------------------------------------------------------------------push
OFFSET toolbar00_str_02
;lpString2, address of string to copy
push
[ebx+40]
;lpString1, address of buffer
call
lstrcpy
;- API Function jmp
WP1_return_1
TB_info_03:
cmp
eax,3h
jne
TB_info_04
mov
eax,iBitmap_03
mov
[ebx+16],eax
mov
eax,idCommand_03
mov
[ebx+20],eax
mov
al,fsState_03
mov
[ebx+24],al
mov
al,fsStyle_03
mov
[ebx+25],al
mov
ax,bReserved_03
mov
[ebx+26],ax
Page 13

td_win32asm_021.asm
mov
eax,dwData_03
mov
[ebx+28],eax
mov
eax,iString_03
mov
[ebx+32],eax
mov
eax,5h
mov
[ebx+36],eax
;-----------------------------------------------------------------------------; API "lstrcpy" copies a string to a buffer
;-----------------------------------------------------------------------------push
OFFSET toolbar00_str_03
;lpString2, address of string to copy
push
[ebx+40]
;lpString1, address of buffer
call
lstrcpy
;- API Function jmp
WP1_return_1
TB_info_04:
cmp
eax,4h
jne
TB_info_05
mov
eax,iBitmap_04
mov
[ebx+16],eax
mov
eax,idCommand_04
mov
[ebx+20],eax
mov
al,fsState_04
mov
[ebx+24],al
mov
al,fsStyle_04
mov
[ebx+25],al
mov
ax,bReserved_04
mov
[ebx+26],ax
mov
eax,dwData_04
mov
[ebx+28],eax
mov
eax,iString_04
mov
[ebx+32],eax
mov
eax,4h
mov
[ebx+36],eax
;-----------------------------------------------------------------------------; API "lstrcpy" copies a string to a buffer
;-----------------------------------------------------------------------------push
OFFSET toolbar00_str_04
;lpString2, address of string to copy
push
[ebx+40]
;lpString1, address of buffer
call
lstrcpy
;- API Function jmp
WP1_return_1
TB_info_05:
cmp
eax,5h
jne
TB_info_06
mov
eax,iBitmap_05
mov
[ebx+16],eax
mov
eax,idCommand_05
mov
[ebx+20],eax
mov
al,fsState_05
mov
[ebx+24],al
mov
al,fsStyle_05
mov
[ebx+25],al
mov
ax,bReserved_05
Page 14

td_win32asm_021.asm
mov
[ebx+26],ax
mov
eax,dwData_05
mov
[ebx+28],eax
mov
eax,iString_05
mov
[ebx+32],eax
mov
eax,6h
mov
[ebx+36],eax
;-----------------------------------------------------------------------------; API "lstrcpy" copies a string to a buffer
;-----------------------------------------------------------------------------push
OFFSET toolbar00_str_05
;lpString2, address of string to copy
push
[ebx+40]
;lpString1, address of buffer
call
lstrcpy
;- API Function jmp
WP1_return_1
TB_info_06:
cmp
eax,6h
jne
TB_info_07
mov
eax,iBitmap_06
mov
[ebx+16],eax
mov
eax,idCommand_06
mov
[ebx+20],eax
mov
al,fsState_06
mov
[ebx+24],al
mov
al,fsStyle_06
mov
[ebx+25],al
mov
ax,bReserved_06
mov
[ebx+26],ax
mov
eax,dwData_06
mov
[ebx+28],eax
mov
eax,iString_06
mov
[ebx+32],eax
mov
eax,6h
mov
[ebx+36],eax
;-----------------------------------------------------------------------------; API "lstrcpy" copies a string to a buffer
;-----------------------------------------------------------------------------push
OFFSET toolbar00_str_06
;lpString2, address of string to copy
push
[ebx+40]
;lpString1, address of buffer
call
lstrcpy
;- API Function jmp
WP1_return_1
TB_info_07:
cmp
eax,7h
jne
TB_info_08
mov
eax,iBitmap_07
mov
[ebx+16],eax
mov
eax,idCommand_07
mov
[ebx+20],eax
mov
al,fsState_07
mov
[ebx+24],al
mov
al,fsStyle_07
mov
[ebx+25],al

;fill TBBUTTON structure !

Page 15

td_win32asm_021.asm
mov
ax,bReserved_07
mov
[ebx+26],ax
mov
eax,dwData_07
mov
[ebx+28],eax
mov
eax,iString_07
mov
[ebx+32],eax
mov
eax,7h
mov
[ebx+36],eax
;-----------------------------------------------------------------------------; API "lstrcpy" copies a string to a buffer
;-----------------------------------------------------------------------------push
OFFSET toolbar00_str_07
;lpString2, address of string to copy
push
[ebx+40]
;lpString1, address of buffer
call
lstrcpy
;- API Function jmp
WP1_return_1
TB_info_08:
cmp
eax,8h
;check IItem, index
jne
TB_info_09
mov
eax,iBitmap_08
;fill TBBUTTON structure ...
mov
[ebx+16],eax
mov
eax,idCommand_08
mov
[ebx+20],eax
mov
al,fsState_08
mov
[ebx+24],al
mov
al,fsStyle_08
mov
[ebx+25],al
mov
ax,bReserved_08
mov
[ebx+26],ax
mov
eax,dwData_08
mov
[ebx+28],eax
mov
eax,iString_08
mov
[ebx+32],eax
mov
eax,6h
mov
[ebx+36],eax
;-----------------------------------------------------------------------------; API "lstrcpy" copies a string to a buffer
;-----------------------------------------------------------------------------push
OFFSET toolbar00_str_08
;lpString2, address of string to copy
push
[ebx+40]
;lpString1, address of buffer
call
lstrcpy
;- API Function jmp
WP1_return_1
TB_info_09:
cmp
eax,9h
jne
TB_info_10
mov
eax,iBitmap_09
mov
[ebx+16],eax
mov
eax,idCommand_09
mov
[ebx+20],eax
mov
al,fsState_09
mov
[ebx+24],al
mov
al,fsStyle_09
Page 16

td_win32asm_021.asm
mov
[ebx+25],al
mov
ax,bReserved_09
mov
[ebx+26],ax
mov
eax,dwData_09
mov
[ebx+28],eax
mov
eax,iString_09
mov
[ebx+32],eax
mov
eax,5h
mov
[ebx+36],eax
;-----------------------------------------------------------------------------; API "lstrcpy" copies a string to a buffer
;-----------------------------------------------------------------------------push
OFFSET toolbar00_str_09
;lpString2, address of string to copy
push
[ebx+40]
;lpString1, address of buffer
call
lstrcpy
;- API Function jmp
WP1_return_1
TB_info_10:
cmp
eax,0Ah
jne
TB_info_11
mov
eax,iBitmap_10
mov
[ebx+16],eax
mov
eax,idCommand_10
mov
[ebx+20],eax
mov
al,fsState_10
mov
[ebx+24],al
mov
al,fsStyle_10
mov
[ebx+25],al
mov
ax,bReserved_10
mov
[ebx+26],ax
mov
eax,dwData_10
mov
[ebx+28],eax
mov
eax,iString_10
mov
[ebx+32],eax
mov
eax,9h
mov
[ebx+36],eax
;-----------------------------------------------------------------------------; API "lstrcpy" copies a string to a buffer
;-----------------------------------------------------------------------------push
OFFSET toolbar00_str_10
;lpString2, address of string to copy
push
[ebx+40]
;lpString1, address of buffer
call
lstrcpy
;- API Function jmp
WP1_return_1
TB_info_11:
cmp
eax,0Bh
jne
TB_info_12
mov
eax,iBitmap_11
mov
[ebx+16],eax
mov
eax,idCommand_11
mov
[ebx+20],eax
mov
al,fsState_11
mov
[ebx+24],al
Page 17

td_win32asm_021.asm
mov
al,fsStyle_11
mov
[ebx+25],al
mov
ax,bReserved_11
mov
[ebx+26],ax
mov
eax,dwData_11
mov
[ebx+28],eax
mov
eax,iString_11
mov
[ebx+32],eax
mov
eax,7h
mov
[ebx+36],eax
;-----------------------------------------------------------------------------; API "lstrcpy" copies a string to a buffer
;-----------------------------------------------------------------------------push
OFFSET toolbar00_str_11
;lpString2, address of string to copy
push
[ebx+40]
;lpString1, address of buffer
call
lstrcpy
;- API Function jmp
WP1_return_1
TB_info_12:
cmp
eax,0Ch
jne
TB_info_13
mov
eax,iBitmap_12
mov
[ebx+16],eax
mov
eax,idCommand_12
mov
[ebx+20],eax
mov
al,fsState_12
mov
[ebx+24],al
mov
al,fsStyle_12
mov
[ebx+25],al
mov
ax,bReserved_12
mov
[ebx+26],ax
mov
eax,dwData_12
mov
[ebx+28],eax
mov
eax,iString_12
mov
[ebx+32],eax
mov
eax,4h
mov
[ebx+36],eax
;-----------------------------------------------------------------------------; API "lstrcpy" copies a string to a buffer
;-----------------------------------------------------------------------------push
OFFSET toolbar00_str_12
;lpString2, address of string to copy
push
[ebx+40]
;lpString1, address of buffer
call
lstrcpy
;- API Function jmp
WP1_return_1
TB_info_13:
cmp
eax,0Dh
jne
WP1_return_0
mov
eax,iBitmap_13
mov
[ebx+16],eax
mov
eax,idCommand_13
mov
[ebx+20],eax
mov
al,fsState_13
Page 18

td_win32asm_021.asm
mov
[ebx+24],al
mov
al,fsStyle_13
mov
[ebx+25],al
mov
ax,bReserved_13
mov
[ebx+26],ax
mov
eax,dwData_13
mov
[ebx+28],eax
mov
eax,iString_13
mov
[ebx+32],eax
mov
eax,4h
mov
[ebx+36],eax
;-----------------------------------------------------------------------------; API "lstrcpy" copies a string to a buffer
;-----------------------------------------------------------------------------push
OFFSET toolbar00_str_13
;lpString2, address of string to copy
push
[ebx+40]
;lpString1, address of buffer
call
lstrcpy
;- API Function jmp
WP1_return_1
;==============================================================================
; WM_COMMAND (value=111h) message recieved ?
;-----------------------------------------------------------------------------WP1_uMsg_111h:
cmp
eax,111h
;check if WM_COMMAND message recieved
jne
WP1_uMsg_112h
;if not goto label
mov
eax,WP1_wParam
;extra info about the message in ax
cmp
ax,1h
;ID of "&Help" item in rc file
jne
WP1_wParam_00C0h
;if not 1h goto LABEL
;-----------------------------------------------------------------------------; API "MessageBoxA" creates a message box, we get the Toolbar Help
;-----------------------------------------------------------------------------push
0h
;uType, style, 4=MB_OK Button
push
OFFSET MB1Titel
;lpCaption,pointer to title text
push
OFFSET MB1Text
;lpText,pointer to text message box
push
WP1_hWnd
;handle of owner window 0=no owner
call
MessageBoxA
;- API Function jmp
WP1_return
;
;-----------------------------------------------------------------------------; Extra message info toolbar, button (BITMAP BUTTON ID=0C0h - 0CDh) clicked
;-----------------------------------------------------------------------------WP1_wParam_00C0h:
cmp
ax,0C0h
;ID of first toolbar button
jb
WP1_return
;if below 0C0h goto LABEL
cmp
ax,0CDh
;ID of last toolbar button
ja
WP1_return
;if above 0CDh goto LABEL
;-----------------------------------------------------------------------------; API "MessageBoxA" creates one message box for all toolbar buttons
;-----------------------------------------------------------------------------push
0h
;uType, style, 0=MB_OK Button
push
OFFSET MB2Titel
;lpCaption,pointer to title text
push
OFFSET MB2Text
;lpText,pointer to text message box
push
WP1_hWnd
;handle of owner window 0=no owner
call
MessageBoxA
;- API Function Page 19

td_win32asm_021.asm
jmp

WP1_return

;==============================================================================
; WM_SYSCOMMAND (value=112h) message recieved ?
;-----------------------------------------------------------------------------WP1_uMsg_112h:
cmp
eax,112h
;check if WM_COMMAND message recieved
jne
WP1_return
;if not goto label
mov
eax,WP1_wParam
;extra info about the message
cmp
eax,0F060h
;SC_CLOSE=0F060h received ?
jne
WP1_return
;
call
My_CleanSystem
;- SubRoutine jmp
WP1_return
;==============================================================================
; API "DefWindowProcA" calls the window procedure to provide default processing
; for any window messages that an application does not process.
; This function ensures that every message is processed.
; It is called with the same parameters received by the window procedure.
;-----------------------------------------------------------------------------WP1_return:
popad
;pop all register from stack
push
WP1_lParam
;extra info about the message
push
WP1_wParam
;extra info about the message
push
WP1_uMsg
;the message number
push
WP1_hWnd
;handle of window who receives message
call
DefWindowProcA
;- API Function mov
esp,ebp
;delete stack frame
pop
ebp
;
ret
10h
;return and clear stack
;==============================================================================
; Leaving the window procedure returning TRUE (1) or FALSE (0) in EAX.
;-----------------------------------------------------------------------------WP1_return_0:
popad
;pop all register from stack
mov
eax,0h
;set EAX to FALSE (0)
mov
esp,ebp
;delete stack frame
pop
ebp
;
ret
10h
;return and clear stack
WP1_return_1:
popad
;pop all register from stack
mov
eax,1h
;set EAX to TRUE (1)
mov
esp,ebp
;delete stack frame
pop
ebp
;
ret
10h
;return and clear stack
;##############################################################################
;******************************************************************************
; My own subroutine(s) for a compacter code resist here ...
;-----------------------------------------------------------------------------My_CleanSystem:
Page 20

td_win32asm_021.asm
ret
;******************************************************************************
;==============================================================================
; end Main = end of our program code
;-----------------------------------------------------------------------------end Main
;end of our program code, entry point
;==============================================================================
; To create the exe file use this commands with your Microsoft Assembler/Linker
;-----------------------------------------------------------------------------; ml.exe /c /coff td_win32asm_021.asm
;asm command
; rc.exe /v rsrc.rc
;rc command
; cvtres.exe /machine:ix86 rsrc.res
; link.exe /subsystem:windows td_win32asm_021.obj rsrc.obj
;link command
;==============================================================================

Page 21

Das könnte Ihnen auch gefallen