CheckBoxGadget class is 'Button' ?

Just starting out? Need help? Post your questions and find answers here.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

CheckBoxGadget class is 'Button' ?

Post 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
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

It's normal.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: CheckBoxGadget class is 'Button' ?

Post 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. :)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: CheckBoxGadget class is 'Button' ?

Post 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 :D

Is there another way to know what gadget type is hiding behind a handle ?
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: CheckBoxGadget class is 'Button' ?

Post 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
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post 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)?
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post 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.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post 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.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post 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
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Thanks, interesting.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
PolyVector
Enthusiast
Enthusiast
Posts: 499
Joined: Wed Sep 17, 2003 9:17 pm
Location: Southern California
Contact:

Post 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
Post Reply