News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Little test

Started by donkey, April 09, 2011, 09:52:15 AM

Previous topic - Next topic

donkey

I've found that within my project the dialog looks pretty cool. However, since the background is gradient filled, static controls don't look right as they have the dialog gray background. In order to fix this I subclassed the static controls. Now setting the subclass for each control is a pain in the arse so I did them in an enumeration.

Added the following to WM_INITDIALOG:

invoke EnumChildWindows,[hwnd],offset EnumChildProc,offset StaticSubclass

New procedures:

EnumChildProc FRAME hwnd, lParam
LOCAL szClassName[256]:%TCHAR

invoke GetClassName,[hwnd],offset szClassName,256

invoke lstrcmpi,offset szClassName,"Static"
jnz >>
invoke GetWindowLong,[hwnd],GWL_WNDPROC
invoke SetWindowLong,[hwnd],GWL_USERDATA,eax
invoke SetWindowLong,[hwnd],GWL_WNDPROC,[lParam]
:
mov eax,TRUE
ret
endf

StaticSubclass FRAME hwnd,uMsg,wParam,lParam
LOCAL rct:RECT
LOCAL szText[256]:%TCHAR ; may want Unicode some day so use TCHAR instead of B
LOCAL ps:PAINTSTRUCT

.WM_PAINT
cmp D[uMsg],WM_PAINT
jne >>.DEFPROC
invoke BeginPaint,[hwnd],offset ps
invoke SetBkMode,[ps.hdc],TRANSPARENT
invoke SetTextColor,[ps.hdc],0
invoke GetClientRect,[hwnd],offset rct

invoke GetWindowLong,[hwnd],GWL_USERDATA
invoke CallWindowProc,eax,[hwnd],WM_GETTEXT,256,offset szText

invoke GetStockObject,DEFAULT_GUI_FONT
invoke SelectObject,[ps.hdc],eax
push eax
invoke DrawTextEx,[ps.hdc],offset szText,-1,offset rct,DT_CENTER + DT_VCENTER,NULL
pop edx
invoke SelectObject,[ps.hdc],edx
invoke EndPaint,[hwnd],offset ps
xor eax,eax
ret

.DEFPROC
invoke GetWindowLong,[hwnd],GWL_USERDATA
invoke CallWindowProc,eax,[hwnd],[uMsg],[wParam],[lParam]
ret
endf
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

donkey

This is how the dialog looks in my RadAsm addin (which is nearing completion). The labels are static controls using the subclass above, note the rounded buttons, I thought that added a bit of pizazz to it as well.



For the rounded buttons the following code was added to EnumChildProc, no subclassing was necessary for the buttons.

:
invoke lstrcmpi,offset szClassName,"Button"
jnz >>
// Make the buttons pretty too
// Note that only the buttons with the WS_CLIPSIBLINGS style
// will show the modification so that style is used to
// regulate which buttons are affected
invoke GetClientRect,[hwnd],offset rct
// Remove the button borders or it looks silly
sub D[rct.right],2
sub D[rct.bottom],2
; adjust the origin of the region to left 2 and top 3 when creating it
invoke CreateRoundRectRgn,2,3,[rct.right],[rct.bottom],10,10
invoke SetWindowRgn,[hwnd],eax,TRUE
:
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

dedndave

now, you're showing off   :P