View previous topic :: View next topic |
Author |
Message |
bornsoft Contributor
Joined: 19 Feb 2009 Posts: 113 Location: Germany
|
Posted: Tue Oct 25, 2011 7:54 pm Post subject: Get the Self-Handle from within a DSU |
|
|
Hi folks,
things can be so simple ...
For those who need it:
here is a really simple way to obtain the own windows-handle when you don't know the class-name or title and thus can't use @winexists().
I've had this problem sometimes, when I needed the self-handle within an external function and didn't want to provide it by an argument because of the number of arguments.
Also this could be useful if you create a (dummy)dialog within an external function or command for correct dialog selection on exit.
I've tried the way over tasklist and GetWindowThreadProcessId like WidgetCoder's example, but for this purpose it seemed to me like using a big crane to raise a beer box.
So here is the three-lines-way in simplest VDS ...
Code: |
#DEFINE Function,bsSelfHandle
DIALOG CREATE,bsSelfHandle - Demo,-1,0,240,126,NOMIN,CLASS bsSelfHandle
DIALOG ADD,TEXT,TEXT1,24,18,,,"Handle of this window obtained by the"@cr()"@winexists() function:"
DIALOG ADD,TEXT,Handle,64,92,,,123
DIALOG ADD,BUTTON,Get,92,80,80,20,Get Handle
DIALOG SHOW
dialog set,Handle,@winexists(#bsSelfHandle)
:EvLoop
wait event
goto @Event()
:GetButton
info Handle obtained by bsSelfHandle: @bsSelfHandle() @tab()
goto EvLoop
:Close
exit
:bsSelfHandle
%T = @dlgpos(,T)
%L = @dlgpos(,L)
%R = @winatpoint(@sum(%L,10),@sum(%T,10))
exit %R
|
Greetings to the last standing VDS-Coders
bornSoft |
|
Back to top |
|
|
bornsoft Contributor
Joined: 19 Feb 2009 Posts: 113 Location: Germany
|
Posted: Tue Oct 25, 2011 10:29 pm Post subject: |
|
|
@Admin
Hey,
why is this topic moved, and why to VDS 6 Units section??
There is no special VDS 6 code in it and the code example is not a unit/DSU and it is only to demonstrate this three lines of code:
Code: |
%T = @dlgpos(,T)
%L = @dlgpos(,L)
%R = @winatpoint(@sum(%L,10),@sum(%T,10))
|
bornSoft
. |
|
Back to top |
|
|
Aslan Valued Contributor
Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Sat Oct 29, 2011 1:23 pm Post subject: |
|
|
How about one line
Code: | %R = @winatpoint(@dlgpos(,L),@dlgpos(,T)) |
or with VDS6
Code: | :bsSelfHandle
If @greater(@substr(@SYSINFO(DSVER),1),5)
%R = @dlgpos(,I)
Else
%R = @winatpoint(@dlgpos(,L),@dlgpos(,T))
End
exit %R |
|
|
Back to top |
|
|
bornsoft Contributor
Joined: 19 Feb 2009 Posts: 113 Location: Germany
|
Posted: Sun Oct 30, 2011 8:34 am Post subject: |
|
|
Thank you Aslan,
Wow,I didn't know about the "I" flag.
Should have soetimes RTFM, could have saved me hours.
Greetz |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|