.486
.model		flat, stdcall

include		rsrc.inc
include		e:\coding\masm32\include\windows.inc
include		e:\coding\masm32\include\kernel32.inc
include		e:\coding\masm32\include\user32.inc
include		e:\coding\masm32\include\comctl32.inc

includelib	e:\coding\masm32\lib\kernel32.lib
includelib	e:\coding\masm32\lib\user32.lib
includelib	e:\coding\masm32\lib\comctl32.lib

DlgWndProc 	PROTO ,:DWORD,:DWORD,:DWORD,:DWORD

.data

tb		TBBUTTON <STD_FILEOPEN, TB_OPEN,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0>
		TBBUTTON <STD_FILESAVE, TB_SAVE,0,TBSTYLE_BUTTON,0,0>
		TBBUTTON <0,0,TBSTATE_ENABLED,TBSTYLE_SEP,0,0>
		TBBUTTON <STD_DELETE,TB_EXIT,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0>
TB_NROFBUTTONS	EQU ($-offset tb) / size TBBUTTON

szTipOpen	db 'Open File',0
szTipSave	db 'Save File',0
szTipExit	db 'Exit Appication',0

.data?

hInst		dd ?

.code

start:

	invoke	InitCommonControls
	invoke	GetModuleHandle, NULL
	mov	hInst, eax
	invoke	DialogBoxParam, hInst, DLG_MAIN, 0, addr DlgWndProc, 0
	invoke	ExitProcess, 0

DlgWndProc	PROC uses esi ecx edi hWnd:DWORD, wMsg:DWORD, wParam:DWORD, lParam:DWORD
	.IF wMsg==WM_INITDIALOG
		; Cerate Toolbar
		invoke CreateToolbarEx, hWnd, WS_CHILD+WS_BORDER+WS_VISIBLE+TBSTYLE_TOOLTIPS+CCS_ADJUSTABLE, \
					TOOLBAR, TB_NROFBUTTONS, HINST_COMMCTRL, IDB_STD_SMALL_COLOR, addr tb, \
					TB_NROFBUTTONS, 16, 16, 16, 16, size TBBUTTON
		
		; Done
		jmp	@Return1
	.ELSEIF wMsg==WM_COMMAND
		mov	eax,[wParam]
		.IF (ax==IDCANCEL) || (ax==TB_EXIT)
			invoke	EndDialog, [hWnd], 0
		.ELSEIF ax==TB_OPEN
			; Code for open button
		.ELSEIF ax==TB_SAVE
			; code for save button
		.ENDIF
		jmp	@Return1
	.ELSEIF wMsg==WM_NOTIFY
		mov ebx,[lParam]
		.IF dword ptr [ebx+8] == TTN_NEEDTEXT
			mov eax,dword ptr [ebx+4]
			.IF eax==TB_OPEN
				mov dword ptr [ebx+12], offset szTipOpen
			.ELSEIF eax==TB_SAVE
				mov dword ptr [ebx+12], offset szTipSave
			.ELSEIF eax==TB_EXIT
				mov dword ptr [ebx+12], offset szTipExit
			.ENDIF
		.ENDIF
	.ENDIF
@Return0:
	xor	eax,eax
	ret
@Return1:
	mov	eax,1
	ret
DlgWndProc	ENDP


end start
