Page 1 of 1
CheckBoxGadget class is 'Button' ?
Posted: Tue Feb 22, 2005 9:05 am
by gnozal
CheckBoxGadget class is 'Button' ?
Is this 'normal' or am I doing something wrong ?
How to know what sort of gadget is GadgetID(#GadgetNumber) ?
Code: Select all
Procedure.s GetGadgetClass(hGadget.l)
Protected Class.s
Class = Space(255)
GetClassName_(hGadget, @Class, 254)
ProcedureReturn Class
EndProcedure
OpenWindow(0, 100, 300, 400, 200, #PB_Window_SystemMenu, "Class test")
If CreateGadgetList(WindowID())
CheckBoxGadget(3, 240, 170, 200, 20, "Checkbox")
Debug GetGadgetClass(GadgetID(3))
EndIf
Repeat
EventID.l = WaitWindowEvent()
If EventID = #PB_EventCloseWindow
Break
EndIf
ForEver
Posted: Tue Feb 22, 2005 11:05 am
by Fred
It's normal.
Re: CheckBoxGadget class is 'Button' ?
Posted: Tue Feb 22, 2005 11:14 am
by PB
> CheckBoxGadget class is 'Button' ?
Yes.
> Is this 'normal'
Yes. CheckBoxes are just a modified button -- even in C and Visual Basic.
They are just a different graphical style, that's all. Use any window spy app
to view the class of checkboxes in other apps if you don't believe me.

Re: CheckBoxGadget class is 'Button' ?
Posted: Tue Feb 22, 2005 12:25 pm
by gnozal
Fred wrote:It's normal.
Thanks
PB wrote:
They are just a different graphical style, that's all. Use any window spy app to view the class of checkboxes in other apps if you don't believe me.

I believe you
Is there another way to know what gadget type is hiding behind a handle ?
Re: CheckBoxGadget class is 'Button' ?
Posted: Tue Feb 22, 2005 8:00 pm
by PB
> Is there another way to know what gadget type is hiding behind a handle ?
You could use a window spy app such as "ShoWin", or just create a window
with many different gadgets and then run a routine to show all their classes:
Code: Select all
Procedure GetAllChildWins(hWnd)
r=GetWindow_(hWnd,#GW_CHILD)
Repeat
c$=Space(999) : GetClassName_(r,c$,999) : Debug c$
r=GetWindow_(r,#GW_HWNDNEXT)
Until r=0
EndProcedure
If OpenWindow(1,300,250,400,200,#PB_Window_SystemMenu,"test")
CreateGadgetList(WindowID())
; Create whatever gadgets here.
GetAllChildWins(WindowID())
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf
Posted: Wed Feb 23, 2005 9:07 am
by gnozal
Thanks, I know ShoWin.
I meant, is there a more precise way to identify a gadget than its class (e.g. CheckBox <> Button)?
Posted: Wed Feb 23, 2005 11:16 am
by PB
> is there a more precise way to identify a gadget than its class (e.g. CheckBox <> Button)?
I see what you mean now... but I don't think so. You'd have to just scan for
the basic class (like my proc above) and then, for example, test to see if the
button is really a button or checkbox, by checking its flags. I don't know too
much about testing all flag possibilities, so I won't go into it.
Posted: Wed Feb 23, 2005 11:34 am
by gnozal
I didn't think so either.
I just modified my PureCOLOR lib with a specific function for buttons, because I didn't find a simple and reliable way to distinguish real buttons from other 'button' class members.
Posted: Wed Feb 23, 2005 11:47 am
by PB
> I didn't find a simple and reliable way to distinguish real buttons from other
> 'button' class members
This might get you started... 0 means "normal" button and 2 means checkbox:
Code: Select all
If OpenWindow(1,300,250,400,200,#PB_Window_SystemMenu,"test")
CreateGadgetList(WindowID())
ButtonGadget(1,10,10,150,30,"Button")
CheckBoxGadget(2,10,50,150,30,"CheckBox")
Debug GetWindowLong_(GadgetID(1),#GWL_STYLE) & #BS_CHECKBOX
Debug GetWindowLong_(GadgetID(2),#GWL_STYLE) & #BS_CHECKBOX
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf
Posted: Wed Feb 23, 2005 12:01 pm
by gnozal
Thanks, interesting.
Posted: Tue Mar 01, 2005 8:57 pm
by PolyVector
Here's a chunk of test code I had sitting around for the button class...
Style is #GWL_STYLE obviously...
Code: Select all
If (Style&#BS_GROUPBOX=#BS_GROUPBOX)
Type=#SkinGroupBox
ElseIf (Style&#BS_CHECKBOX=#BS_CHECKBOX Or Style&#BS_AUTOCHECKBOX=#BS_AUTOCHECKBOX Or Style&#BS_3STATE=#BS_3STATE Or Style&#BS_AUTO3STATE=#BS_AUTO3STATE)
If Style&#BS_PUSHLIKE=#BS_PUSHLIKE
Type=#SkinButton
Else
Type=#SkinCheckbox
EndIf
ElseIf (Style&#BS_RADIOBUTTON=#BS_RADIOBUTTON Or Style&#BS_AUTORADIOBUTTON=#BS_AUTORADIOBUTTON)
Type=#SkinRadio
ElseIf (Style&#BS_PUSHBUTTON=#BS_PUSHBUTTON Or Style&#BS_DEFPUSHBUTTON=#BS_DEFPUSHBUTTON)
Type=#SkinButton
EndIf