SetGadgetAttribute() extended
Posted: Mon Jul 20, 2009 7:07 pm
This is obviously a very very simple trick, but can be useful...
It's a template you can use and easily extends
for adding more Attributes to the function SetGadgetAttribute().
It's a template you can use and easily extends
for adding more Attributes to the function SetGadgetAttribute().
Code: Select all
;=======================================
;== Macro SetGadgetAttribute()
;== Replaces and Extends the PureBasic original function.
;=======================================
Procedure __SetGadgetAttribute(gadget, attribute, value)
Select attribute
Case #PB_String_ReadOnly
If GadgetType(gadget) = #PB_GadgetType_String
SendMessage_(GadgetID(gadget), #EM_SETREADONLY, value, #Null)
If value = #True
SetGadgetColor(gadget, #PB_Gadget_BackColor, #White)
EndIf
EndIf
Default
SetGadgetAttribute(gadget, attribute, value)
EndSelect
EndProcedure
Macro SetGadgetAttribute(gadget, attribute, value)
__SetGadgetAttribute(gadget, attribute, value)
EndMacro
;=======================================
;== Test
;=======================================
If OpenWindow(0, 300, 300, 100, 30, "test")
StringGadget(0, 5, 5, 90, 20, "")
SetGadgetText(0, "READONLY")
SetGadgetAttribute(0, #PB_String_ReadOnly, #True)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
SetGadgetText(0, "READWRITE")
SetGadgetAttribute(0, #PB_String_ReadOnly, #False)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
End