Jump to content
Tuts 4 You

3 State Buttons Without Subcalssing


TheCodeCracker

Recommended Posts

TheCodeCracker
Posted

Guys i started this thread to view the variety of coding styles used by different coders...

I know how to create a 3 state button via subclassing the button window but i started this tread so that every coder can contribute their code snippets on how to skin buttons.

e.g i make a 2 state button by setting the buttons property to be BS_OWNERDRAW and also creating the respective brushes

and then processing it in WM_DRAWITEM message.

Main proc hwnd:DWORD, umsg:DWORD, wparam:DWORD, lparam:DWORD	.if umsg==WM_INITDIALOG
invoke LoadBitmap,hinst,ID_BMPBTNNORMAL
mov btnnormalbmp,eax
invoke CreatePatternBrush,btnnormalbmp
mov btnnormalbrush,eax invoke LoadBitmap,hinst,ID_BMPBTNPRESS
mov btnpressbmp,eax
invoke CreatePatternBrush,btnpressbmp
mov btnpressbrush,eax
invoke GetDlgItem,hwnd,IDC_CLOSEBTN
mov btn,eax
invoke GetWindowLong,btn,GWL_STYLE
or eax, BS_OWNERDRAW
invoke SetWindowLong,btn,GWL_STYLE,eax.elseif umsg==WM_DRAWITEM xor ecx,ecx
mov ecx,lParam assume ecx: ptr DRAWITEMSTRUCT .if [ecx].CtlID == IDC_CLOSEBTN
.if [ecx].itemState & ODS_SELECTED
invoke FillRect,[ecx].hdc,addr [ecx].rcItem,btnpressbrush
.else
invoke FillRect,[ecx].hdc,addr [ecx].rcItem,btnnormalbrush
.endif
.elseif [ecx].CtlID==IDC_NAME || [ecx].CtlID==IDC_SERIAL
invoke GetDlgItemText,hwnd,[ecx].CtlID,addr tempbuffer,sizeof tempbuffer
.if eax>1
invoke DrawText,[ecx].hdc,offset tempbuffer,sizeof tempbuffer,addr [ecx].rcItem,DT_EDITCONTROL
.endif
.endif
assume ecx:nothing .endif
xor eax,eax
Ret
Main ENDP

I hope this thread will be helpful to the guys need to learn Button Skinning as well as some concepts about brushes and skinning another controls the same way as well.

greetz,

TCC/CiB

TheCodeCracker
Posted

Thanks alot to raqdod and Diabolo2002 for you kind and quality based example.

I learnt new tricks from them.

Thanks Again :D

greetz,

TCC/CiB

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...