Page 1 of 1

Enumerate properties [Windows]

Posted: Sat Aug 24, 2013 4:21 pm
by eddy

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 

Re: Enumerate properties [Windows]

Posted: Sat Aug 24, 2013 5:50 pm
by Josh
change

Code: Select all

PropName$=PeekS(*PropName, -1,  #PB_Ascii)
to

Code: Select all

PropName$=PeekS(*PropName)
In this case it works correct with and without unicode

Re: Enumerate properties [Windows]

Posted: Sat Aug 24, 2013 5:54 pm
by eddy
Josh wrote:change

Code: Select all

PropName$=PeekS(*PropName, -1,  #PB_Ascii)
to

Code: Select all

PropName$=PeekS(*PropName)
In this case it works correct with and without unicode
Done