In windows all objects (windows,gadgets,statusbar,toolbar) , are windows (or the os handle them like this),
so their os-id's are unique.
I don't know if linux and macos have the same behaviour like windows, but if so, this little piece of code make sense
The syntax is like the WinAPI functions. And FreeMap() is since PB4.51, so a little check is integrated...
Code: Select all
CompilerIf #PB_Compiler_Version => 451
Procedure InitProps(UPPERCASE = #False) ; < for you, said ;)
Global NewMap _CrossPlatformProperties_()
_CrossPlatformProperties_("UPPERCASE") = UPPERCASE
EndProcedure
Procedure SetProp(hWnd, Property$, Value)
Protected Key.s, Result = #False
If hWnd
Key = Str(hWnd) + "_" + Property$
If _CrossPlatformProperties_("UPPERCASE")
Key = UCase(Key)
EndIf
_CrossPlatformProperties_(Key) = Value
Result = #True
EndIf
ProcedureReturn Result
EndProcedure
Procedure GetProp(hWnd, Property$)
Protected Key.s, Result = #False
If hWnd
Key = Str(hWnd) + "_" + Property$
If _CrossPlatformProperties_("UPPERCASE")
Key = UCase(Key)
EndIf
If FindMapElement(_CrossPlatformProperties_(), Key)
Result = _CrossPlatformProperties_(Key)
EndIf
EndIf
ProcedureReturn Result
EndProcedure
Procedure RemoveProp(hWnd, Property$)
Protected Key.s, Result = #False
If hWnd
Key = Str(hWnd) + "_" + Property$
If _CrossPlatformProperties_("UPPERCASE")
Key = UCase(Key)
EndIf
If FindMapElement(_CrossPlatformProperties_(), Key)
DeleteMapElement(_CrossPlatformProperties_(), Key)
Result = #True
EndIf
EndIf
ProcedureReturn Result
EndProcedure
Procedure ClearAllProps()
ClearMap(_CrossPlatformProperties_())
FreeMap(_CrossPlatformProperties_())
EndProcedure
CompilerEndIf