.386
.model	flat,stdcall
option	casemap:none
include \masm32\include\comctl32.inc
includelib \masm32\lib\comctl32.lib
include \masm32\include\debug.inc
includelib \masm32\lib\debug.lib
include		demo.inc

.code
start:
	invoke GetModuleHandle, NULL
	mov hInstance,eax
	invoke GetCommandLine
	
	mov	iccex.dwSize,sizeof(INITCOMMONCONTROLSEX)
	mov	iccex.dwICC,ICC_BAR_CLASSES or ICC_WIN95_CLASSES
	invoke InitCommonControlsEx,addr iccex
	invoke DialogBoxParam,hInstance,1001,0,addr DlgProc,0
	invoke ExitProcess,eax
;=====================================================================

DlgProc	proc hWnd:HWND,iMsg:DWORD,wParam:WPARAM, lParam:LPARAM

    LOCAL BtnStruct :XXBUTTON
    LOCAL hBtn      :HWND
    LOCAL Rct       :RECT
	
	.if	iMsg == WM_INITDIALOG

        invoke memfill, ADDR BtnStruct, sizeof(XXBUTTON), 0 ; BtnStruct set null

;========================About========================================
		mov BtnStruct.hIcon_normal, $invoke ( LoadIcon, hInstance, IDI_ABOUT )
		mov BtnStruct.hIcon_hover, FALSE
		mov BtnStruct.m_flat, TRUE
		mov BtnStruct.m_border, TRUE
		mov BtnStruct.m_IconAlign, BS_LEFT
		invoke LoadCursor, NULL, IDC_HAND
		mov BtnStruct.hCursor_hover, eax
		mov hBtn, $invoke ( GetDlgItem, hWnd, IDC_ABOUT )
		invoke RedrawButton, hBtn, ADDR BtnStruct
;========================Left Icon ===================================	
		mov BtnStruct.hIcon_normal, $invoke ( LoadIcon, hInstance, IDI_OK )
		mov BtnStruct.m_flat, FALSE
		mov BtnStruct.m_IconAlign, BS_LEFT
		mov BtnStruct.hCursor_hover, 0
		mov hBtn, $invoke ( GetDlgItem, hWnd, IDC_BUTTONLEFT )
		invoke RedrawButton, hBtn, ADDR BtnStruct
;========================Right Icon====================================		
		mov BtnStruct.m_IconAlign, BS_RIGHT
		mov hBtn, $invoke ( GetDlgItem, hWnd, IDC_BUTTONRIGHT )
		invoke RedrawButton, hBtn, ADDR BtnStruct
;========================Top Icon======================================		
		mov BtnStruct.hIcon_normal, $invoke ( LoadIcon, hInstance, IDI_CANSEL )
		mov BtnStruct.m_IconAlign, BS_TOP
		mov hBtn, $invoke ( GetDlgItem, hWnd, IDC_BUTTONTOP )
		invoke RedrawButton, hBtn, ADDR BtnStruct						
;========================Only Icon - Left==============================		
		mov BtnStruct.hIcon_normal, $invoke ( LoadIcon, hInstance, IDI_LEFT )
		mov BtnStruct.m_flat, TRUE
		mov hBtn, $invoke ( GetDlgItem, hWnd, IDC_SLEFT )
		invoke RedrawButton, hBtn, ADDR BtnStruct
;========================Only Icon - Right=============================		
		mov BtnStruct.hIcon_normal, $invoke ( LoadIcon, hInstance, IDI_RIGHT )
		mov hBtn, $invoke ( GetDlgItem, hWnd, IDC_SRIGHT )
		invoke RedrawButton, hBtn, ADDR BtnStruct
;========================Only Text=====================================		
		mov BtnStruct.hIcon_normal, 0
		mov hBtn, $invoke ( GetDlgItem, hWnd, IDC_TEXT )
		invoke RedrawButton, hBtn, ADDR BtnStruct		
;========================Disabled======================================		
		mov BtnStruct.hIcon_normal, $invoke ( LoadIcon, hInstance, IDI_OK )
		mov BtnStruct.m_flat, FALSE
		mov BtnStruct.m_IconAlign, BS_LEFT
		mov hBtn, $invoke ( GetDlgItem, hWnd, IDC_DISABLED )
		invoke RedrawButton, hBtn, ADDR BtnStruct
;========================Flat Disabled=================================		
		mov BtnStruct.hIcon_normal, $invoke ( LoadIcon, hInstance, IDI_OK )
		mov BtnStruct.m_flat, TRUE
		mov BtnStruct.m_IconAlign, BS_TOP
		mov hBtn, $invoke ( GetDlgItem, hWnd, IDC_FLATDISABLED )
		invoke RedrawButton, hBtn, ADDR BtnStruct			
;========================Lamp Flat=====================================		
		mov BtnStruct.hIcon_normal, $invoke ( LoadIcon, hInstance, IDI_LAMP2 )
		mov BtnStruct.hIcon_hover, $invoke ( LoadIcon, hInstance, IDI_LAMP1 )
		mov BtnStruct.m_flat, TRUE
		mov hBtn, $invoke ( GetDlgItem, hWnd, IDC_LAMP )
		invoke RedrawButton, hBtn, ADDR BtnStruct			
;========================Lamp2=========================================		
		mov BtnStruct.hIcon_normal, $invoke ( LoadIcon, hInstance, IDI_LAMP2 )
		mov BtnStruct.hIcon_hover, $invoke ( LoadIcon, hInstance, IDI_LAMP1 )
		mov BtnStruct.m_border, FALSE
		mov hBtn, $invoke ( GetDlgItem, hWnd, IDC_LAMP2 )
		invoke RedrawButton, hBtn, ADDR BtnStruct
			
;========================Light Text ===================================
		mov BtnStruct.hIcon_normal, NULL
		mov BtnStruct.hIcon_hover, NULL
		mov BtnStruct.m_border, TRUE
		mov BtnStruct.m_IconAlign, BS_LEFT
		
		mov BtnStruct.m_flat, FALSE
		
		RGB 0, 0, 255
		mov BtnStruct.hover_clr, eax
		RGB 128, 128, 0
		mov BtnStruct.push_clr, eax		
		RGB 128, 0, 96
		mov BtnStruct.normal_clr, eax
		
		mov hBtn, $invoke ( GetDlgItem, hWnd, IDC_NTEXT )
		invoke RedrawButton, hBtn, ADDR BtnStruct
;========================Link==========================================
		mov BtnStruct.hIcon_normal, NULL
		mov BtnStruct.hIcon_hover, NULL
		mov BtnStruct.m_border, FALSE
		
		invoke CreateFontIndirect, ADDR lgFnt
		mov hFnt, eax
		mov BtnStruct.hFont_normal, eax
		
		invoke CreateFontIndirect, ADDR lgFntFocus
   	    mov hFntFocus, eax
		mov BtnStruct.hFont_hover, eax	
		
		invoke LoadCursor, NULL, IDC_HAND
		mov BtnStruct.hCursor_hover, eax		
				
		invoke FindResource, NULL, IDW_HOVER, RT_RCDATA
		invoke LoadResource, NULL, eax
		mov BtnStruct.Sound_hover, eax
				
		mov hBtn, $invoke ( GetDlgItem, hWnd, IDC_LINK )
		invoke RedrawButton, hBtn, ADDR BtnStruct
		
;========================Bitmap buttons=================================		
;=======================================================================		
;============================Noise======================================
@@:		

        invoke memfill, ADDR BtnStruct, sizeof(XXBUTTON), 0 ; BtnStruct set null
        
		mov BtnStruct.hIcon_normal, NULL
		mov BtnStruct.hIcon_hover, NULL
		mov BtnStruct.m_border, TRUE
		mov BtnStruct.hFont_normal, NULL
		mov BtnStruct.hFont_hover, NULL
		mov BtnStruct.hCursor_hover, NULL		
		mov BtnStruct.Sound_hover, NULL
		mov BtnStruct.hover_clr, NULL
		mov BtnStruct.push_clr, NULL	
		mov BtnStruct.normal_clr, NULL
				
		mov hBtn, $invoke ( GetDlgItem, hWnd, IDC_NOISE )
		invoke GetWindowRect, hBtn, ADDR Rct
        invoke CreateFillBmp, FILL_NOISE, ADDR Rct, 30, 15, 0, 0            
        mov BtnStruct.hBitmap_normal, eax
        mov hBmpNoiseNormal, eax
        mov BtnStruct.hBitmap_hover, edx
        mov hBmpNoiseHover, edx
		
		invoke RedrawButton, hBtn, ADDR BtnStruct
		
;========================Soft Bump=====================================				
				
		mov hBtn, $invoke ( GetDlgItem, hWnd, IDC_SOFTBUMP )
		invoke GetWindowRect, hBtn, ADDR Rct
        invoke CreateFillBmp, FILL_SOFTBUMP, ADDR Rct, 8, 10, 0, 0            
        mov BtnStruct.hBitmap_normal, eax
        mov hBmpSoftBumpNormal, eax
        mov BtnStruct.hBitmap_hover, edx
        mov hBmpSoftBumpHover, edx
        
		invoke RedrawButton, hBtn, ADDR BtnStruct

;========================V Bump========================================				
				
		mov hBtn, $invoke ( GetDlgItem, hWnd, IDC_VBUMP )
		invoke GetWindowRect, hBtn, ADDR Rct
		RGB 55,55,255
        invoke CreateFillBmp, FILL_VBUMP, ADDR Rct, 8, 20, 5, eax           
        mov BtnStruct.hBitmap_normal, eax
        mov hBmpVBumpNormal, eax
        mov BtnStruct.hBitmap_hover, edx
        mov hBmpVBumpHover, edx
        
		invoke RedrawButton, hBtn, ADDR BtnStruct
		
;========================H Bump========================================				
				
		mov hBtn, $invoke ( GetDlgItem, hWnd, IDC_HBUMP )
		invoke GetWindowRect, hBtn, ADDR Rct
		RGB 55,55,255
        invoke CreateFillBmp, FILL_HBUMP, ADDR Rct, 8, 20, 5, eax            
        mov BtnStruct.hBitmap_normal, eax
        mov hBmpHBumpNormal, eax
        mov BtnStruct.hBitmap_hover, edx
        mov hBmpHBumpHover, edx
        
		invoke RedrawButton, hBtn, ADDR BtnStruct		
		
;========================H Shade========================================				
				
		mov hBtn, $invoke ( GetDlgItem, hWnd, IDC_HSHADE )
		invoke GetWindowRect, hBtn, ADDR Rct
		RGB 55,55,255
        invoke CreateFillBmp, FILL_HSHADE, ADDR Rct, 8, 20, 5, eax            
        mov BtnStruct.hBitmap_normal, eax
        mov hBmpHShadeNormal, eax
        mov BtnStruct.hBitmap_hover, edx
        mov hBmpHShadeHover, edx
        
		invoke RedrawButton, hBtn, ADDR BtnStruct
		
;========================V Shade========================================				
				
		mov hBtn, $invoke ( GetDlgItem, hWnd, IDC_VSHADE )
		invoke GetWindowRect, hBtn, ADDR Rct
		RGB 55,55,255
        invoke CreateFillBmp, FILL_VSHADE, ADDR Rct, 8, 20, 5, eax            
        mov BtnStruct.hBitmap_normal, eax
        mov hBmpVShadeNormal, eax
        mov BtnStruct.hBitmap_hover, edx
        mov hBmpVShadeHover, edx
        
		invoke RedrawButton, hBtn, ADDR BtnStruct					

;========================Diagonal Shade=================================				
				
		mov hBtn, $invoke ( GetDlgItem, hWnd, IDC_DIAGSHADE )
		invoke GetWindowRect, hBtn, ADDR Rct
		RGB 80,255,220
        invoke CreateFillBmp, FILL_DIAGSHADE, ADDR Rct, 8, 20, 10, eax
        mov BtnStruct.hBitmap_normal, eax
        mov hBmpDShadeNormal, eax
        mov BtnStruct.hBitmap_hover, edx
        mov hBmpDShadeHover, edx
        
        RGB 0, 50, 255
		mov BtnStruct.hover_clr, eax
		RGB 168, 0, 96
		mov BtnStruct.normal_clr, eax
         
		invoke RedrawButton, hBtn, ADDR BtnStruct
		
;========================Hard Bump======================================				
				
		mov hBtn, $invoke ( GetDlgItem, hWnd, IDC_HARDBUMP )
		invoke GetWindowRect, hBtn, ADDR Rct
        invoke CreateFillBmp, FILL_HARDBUMP, ADDR Rct, 8, 10, 0, 0
        
        mov BtnStruct.hover_clr, 0
		mov BtnStruct.push_clr, 0	
		mov BtnStruct.normal_clr, 0
                    
        mov BtnStruct.hBitmap_normal, eax
        mov hBmpHardBumpNormal, eax
        mov BtnStruct.hBitmap_hover, edx
        mov hBmpHardBumpHover, edx
        
		invoke RedrawButton, hBtn, ADDR BtnStruct
		
;========================Metal==========================================				
				
		mov hBtn, $invoke ( GetDlgItem, hWnd, IDC_METAL )
		invoke GetWindowRect, hBtn, ADDR Rct
        invoke CreateFillBmp, FILL_METAL, ADDR Rct, 8, 10, 0, 0            
        mov BtnStruct.hBitmap_normal, eax
        mov hBmpMetalNormal, eax
        mov BtnStruct.hBitmap_hover, edx
        mov hBmpMetalHover, edx
        
		invoke RedrawButton, hBtn, ADDR BtnStruct						

;========================User===========================================				
				
		mov hBtn, $invoke ( GetDlgItem, hWnd, IDC_USERBMP )
		invoke GetWindowRect, hBtn, ADDR Rct
        invoke LoadBitmap, hInstance, 500         
        mov BtnStruct.hBitmap_normal, eax
        invoke LoadBitmap, hInstance, 501
        mov BtnStruct.hBitmap_hover, eax
        invoke LoadBitmap, hInstance, 502
        mov BtnStruct.hBitmap_push, eax

        mov BtnStruct.m_border, FALSE
        
		invoke RedrawButton, hBtn, ADDR BtnStruct
		
;========================Exit=========================================		
		mov BtnStruct.m_flat, FALSE
		mov BtnStruct.m_border, TRUE
		
		m2m BtnStruct.hBitmap_push, hBmpNoiseHover
		m2m BtnStruct.hBitmap_normal, hBmpNoiseNormal
        m2m BtnStruct.hBitmap_hover, hBmpNoiseHover
		
		invoke LoadCursor, hInstance, ID_CUR1
		mov BtnStruct.hCursor_hover, eax
		
		mov hBtn, $invoke ( GetDlgItem, hWnd, IDC_EXIT )
		invoke RedrawButton, hBtn, ADDR BtnStruct		

    .elseif iMsg == WM_SYSCOLORCHANGE
        
        call DeleteBitmap
        
        jmp @b

	.elseif	iMsg == WM_CLOSE

        call DeleteBitmap
   	    invoke DeleteObject, hFntFocus
    	invoke DeleteObject, hFnt
		invoke	EndDialog, hWnd, NULL
	
	.elseif iMsg == WM_COMMAND
		mov	eax,wParam
		mov	edx,eax
		shr	edx,16
		
		.if	dx == BN_CLICKED
			.if	eax == IDC_EXIT
				invoke	SendMessage, hWnd, WM_CLOSE, NULL, NULL
			.elseif	eax == IDC_LINK
				invoke ShellExecute, 0, 0, ADDR email_chib, 0, 0, SW_SHOWNORMAL
			.elseif	eax == IDC_ABOUT
			    invoke CreateXXAboutDlg, hWnd
			.endif
		.endif
	.else
		mov	eax,FALSE
		ret
	.endif
	
	mov	eax,TRUE
	ret
DlgProc endp

; Free gdi resource.

DeleteBitmap proc

    invoke DeleteObject,hBmpNoiseNormal
    invoke DeleteObject,hBmpNoiseHover
    invoke DeleteObject,hBmpSoftBumpNormal
    invoke DeleteObject,hBmpSoftBumpHover
    invoke DeleteObject,hBmpVBumpNormal
    invoke DeleteObject,hBmpVBumpHover
    invoke DeleteObject,hBmpHBumpNormal
    invoke DeleteObject,hBmpHBumpHover
    invoke DeleteObject,hBmpHShadeNormal
    invoke DeleteObject,hBmpHShadeHover
    invoke DeleteObject,hBmpVShadeNormal
    invoke DeleteObject,hBmpVShadeHover
    invoke DeleteObject,hBmpDShadeNormal
    invoke DeleteObject,hBmpDShadeHover
    invoke DeleteObject,hBmpHardBumpNormal
    invoke DeleteObject,hBmpHardBumpHover
    invoke DeleteObject,hBmpMetalNormal
    invoke DeleteObject,hBmpMetalHover

	ret
DeleteBitmap endp

end start
