Getgadgettype(handle), to retrive the gadget type, string, text, combo... etc...
This would be nice to create functions to act on certain types of gadgets...
(Implemented as 'GadgetType()')
[Implemented] GetGadgetType
Re: GetGadgetType
You could use something like this in the meantime (obviously you'll have to
work out the class names, in advance, for every type of gadget in use):
work out the class names, in advance, for every type of gadget in use):
Code: Select all
Procedure.s GetGadgetType(gadget)
class$=Space(255) : GetClassName_(GadgetID(gadget),class$,255)
ProcedureReturn class$
EndProcedure
If OpenWindow(1,300,250,400,200,#PB_Window_SystemMenu,"Window")
CreateGadgetList(WindowID())
ButtonGadget(1,20,50,60,25,"Button") : Debug GetGadgetType(1)
StringGadget(2,20,80,300,20,"String") : Debug GetGadgetType(2)
Repeat : Until WaitWindowEvent()=#PB_EventCloseWindow
EndIf
-
Num3
- PureBasic Expert

- Posts: 2812
- Joined: Fri Apr 25, 2003 4:51 pm
- Location: Portugal, Lisbon
- Contact:
I have to parse 600 gadgets and change their look...
If i do it by hand it will take me a very long time...
With this procedure here i just change'em at start with a simple line of code
If i do it by hand it will take me a very long time...
With this procedure here i just change'em at start with a simple line of code
Code: Select all
Procedure.s GetGadgetType(gadget)
class$=Space(255) : GetClassName_(GadgetID(gadget),class$,255)
ProcedureReturn class$
EndProcedure
Procedure flatgadget(top.l)
For x=0 To top
If GetGadgetType(x)="Button"
style.l=GetWindowLong_(GadgetID(x),#GWL_STYLE)
SetWindowLong_(GadgetID(x),#GWL_STYLE,style|#BS_FLAT)
EndIf
If GetGadgetType(x)="Edit"
style.l=GetWindowLong_(GadgetID(x),#GWL_STYLE)
SetWindowLong_(GadgetID(x),#GWL_STYLE,style|#WS_GROUP|#WS_BORDER)
EndIf
If GetGadgetType(x)="SysListView32" Or GetGadgetType(x)="SysTreeView32"
style.l=GetWindowLong_(GadgetID(x),#GWL_STYLE)
SetWindowLong_(GadgetID(x),#GWL_STYLE,style|#WS_GROUP|#WS_BORDER)
EndIf
Next
RedrawWindow_(WindowID(),0,0,#RDW_UPDATENOW|#RDW_ERASE|#RDW_INVALIDATE)
EndProcedureNow I understand -- I actually helped you!
I thought you were saying that
you had 600 different CLASSES of gadgets to check. Glad to be of assistance!
BTW, you should change your For...Next loop to this instead:
The way you had it, meant that the loop had to perform 3 checks during
the loop, but if you use ElseIf then the checking stops as soon as a match
is found. That is, if the class is Button then the loop won't check for Edit
and SysListView32, thus saving time. Your way would make the loop
check the last two even if Button was matched first (which is pointless).
you had 600 different CLASSES of gadgets to check. Glad to be of assistance!
BTW, you should change your For...Next loop to this instead:
Code: Select all
For x=0 To top
If GetGadgetType(x)="Button"
style.l=GetWindowLong_(GadgetID(x),#GWL_STYLE)
SetWindowLong_(GadgetID(x),#GWL_STYLE,style|#BS_FLAT)
ElseIf GetGadgetType(x)="Edit"
style.l=GetWindowLong_(GadgetID(x),#GWL_STYLE)
SetWindowLong_(GadgetID(x),#GWL_STYLE,style|#WS_GROUP|#WS_BORDER)
ElseIf GetGadgetType(x)="SysListView32" Or GetGadgetType(x)="SysTreeView32"
style.l=GetWindowLong_(GadgetID(x),#GWL_STYLE)
SetWindowLong_(GadgetID(x),#GWL_STYLE,style|#WS_GROUP|#WS_BORDER)
EndIf
Next
the loop, but if you use ElseIf then the checking stops as soon as a match
is found. That is, if the class is Button then the loop won't check for Edit
and SysListView32, thus saving time. Your way would make the loop
check the last two even if Button was matched first (which is pointless).