Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Store a value associated with a window?
#2
Function SetPropString
Code:
Copy      Help
;/
function hwnd $name $value

;Assigns a string property to the window. Or changes.
;Similar to SetProp, but SetProp assigns an integer property.


str s1.from(name "[1]*") s2
if(FindProp(hwnd s1 s2)) RemoveProp hwnd s2
s1.from(name "[1]" value)
SetProp hwnd s1 1

Function GetPropString
Code:
Copy      Help
;/
function! hwnd $name str&value

;Gets a string property assigned to the window using SetPropString.
;Similar to GetProp, but GetProp gets an integer property.
;Returns 1 if found, 0 if not.

;EXAMPLE
;int h=win("Notepad")
;SetPropString h "y" "asdfg"
;str s
;if(GetPropString(h "y" s))
,;out s


str s1.from(name "[1]*")
if(FindProp(hwnd s1 value))
,value.get(value findc(value 1)+1)
,ret 1

Function FindProp
Code:
Copy      Help
;/
function! hwnd $propw str&propFull

;Find a window property.
;In propw you specify window property name with wildcard characters, eg "ab=*".
;In propFull you receive full property name, eg "ab=cd"
;Returns 1 if found, 0 if not.
;Note: This function is not to be used with properties set by SetPropString. Use GetPropString instead.

;EXAMPLE
;int h=win("Notepad")
;SetProp h "x=qwerty" 71
;str s
;if(FindProp(h "x=*" s))
,;out s
,;out GetProp(h s)


type FINDPROPDATA $propw str*propFull
propFull.len=0
EnumPropsEx hwnd &FP_EnumProc &propw
ret propFull.len!0

Function FP_EnumProc
Code:
Copy      Help
;/
function# hwnd $lpszString hData FINDPROPDATA&x

if(lpszString<=0xffff) ret 1 ;;atom
;out lpszString
if(!matchw(lpszString x.propw 1)) ret 1
*x.propFull=lpszString

--------------------------------------------------------------

this is not needed for the above functions but may be useful somewhere else

Macro enum window props
Code:
Copy      Help
;shows what properties the window has

out
int h=win("Notepad")
EnumPropsEx h &Prop_EnumProc 0

Function Prop_EnumProc
Code:
Copy      Help
;/
function# hwnd $lpszString hData x

;used only by "enum window props" macro

if(lpszString<=0xffff) ret 1 ;;atom
out lpszString
ret 1


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)