Code: Select all
;:=============================================================================
;:- ExamineProps()
;:- Author : Eddy
;:- Date : August 24, 2013
;:- Compiler : PureBasic 5.20 beta 11 LTS
;:- Target OS : Windows
;:- Source --------------------------------------------------------------------
;:- http://www.purebasic.fr/english/viewtopic.php?f=40&t=56203
;:=============================================================================
EnableExplicit
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
Global NewMap Props() ; <---- this map will contain collection of properties
Procedure ExaminePropDetail(*ObjectID, *PropName, PropValue, parameters)
Protected PropName$=Space(256)
If Not GetAtomName_(*PropName, @PropName$, 255)
PropName$=PeekS(*PropName)
EndIf
Props(PropName$)=PropValue
ProcedureReturn #True
EndProcedure
Procedure ExamineProps(*ObjectID, parameters=0)
ResetMap(Props())
EnumPropsEx_(*ObjectID, @ExaminePropDetail(), parameters)
EndProcedure
CompilerEndIf
CompilerIf #PB_Compiler_IsMainFile
; **********************************
; EXAMPLE
; **********************************
DisableExplicit
OpenWindow(0,1,1,100,100,"coucou")
ButtonGadget(17,5,5,70,30,"ok")
SetProp_(GadgetId(17),"the answer to the meaning of life",42) ; <---- api function to set custom windows property
Debug "My PBwindow properties:"
ExamineProps(WindowID(0))
ForEach Props() :Debug " Prop: "+MapKey(Props())+" => "+Props() :Next
Debug "My PBgadget properties:"
ExamineProps(GadgetID(17))
ForEach Props() :Debug " Prop: "+MapKey(Props())+" => "+Props() :Next
Debug GetProp_(GadgetId(17),"PB_ID") ;<---- api function to get custom windows property value => return 17
Debug Props("PB_ID") ; <----- return 17
CompilerEndIf