Enumerate properties [Windows]

Share your advanced PureBasic knowledge/code with the community.
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

Enumerate properties [Windows]

Post 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 
Last edited by eddy on Fri Aug 30, 2013 7:51 pm, edited 2 times in total.
Imagewin10 x64 5.72 | IDE | PB plugin | Tools | Sprite | JSON | visual tool
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: Enumerate properties [Windows]

Post 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
sorry for my bad english
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

Re: Enumerate properties [Windows]

Post 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
Imagewin10 x64 5.72 | IDE | PB plugin | Tools | Sprite | JSON | visual tool
Post Reply