Posts: 58
Threads: 19
Joined: Mar 2005
I currently do this by appending the window name with the string i want to keep associated to this window, but if the window name changes, I lose my value.
The value I am storing is a variable, so using GetProp or FindTaggedWindow I was unable to find the value because it varies. (previous window dimensions)
I played around a bit with global variables but didn't like it.
Is there an alternative method to store a value associated with a window(string) inside the window itself so that it is obtainable on the next run?
****
Edit: I am pretty sure i can use RegWinPos and get this to work.
****
Edit2: Code removed, contained error
Posts: 12,066
Threads: 140
Joined: Dec 2002
Function
SetPropString
;/
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
;/
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
;/
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
;/
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
;shows what properties the window has
out
int h=win("Notepad")
EnumPropsEx h &Prop_EnumProc 0
Function
Prop_EnumProc
;/
function# hwnd $lpszString hData x
;used only by "enum window props" macro
if(lpszString<=0xffff) ret 1 ;;atom
out lpszString
ret 1
Posts: 58
Threads: 19
Joined: Mar 2005
Thanks for the functions, 1 problem.
for FINDPROPDATA, I am getting unknown identifier. It is not appearing in purple/pink. Am I missing a file?
I figured out a solution I am pretty happy with using TagWindow + RegWinPos but your solution appears to be exactly what I was previously looking for.
***
Edit: Code removed, contained error
***
Posts: 12,066
Threads: 140
Joined: Dec 2002
in Prop_EnumProc? Remove FINDPROPDATA& , i forgot it.
Posts: 58
Threads: 19
Joined: Mar 2005