forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Get the Self-Handle from within a DSU

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 6 Units
View previous topic :: View next topic  
Author Message
bornsoft
Contributor
Contributor


Joined: 19 Feb 2009
Posts: 113
Location: Germany

PostPosted: Tue Oct 25, 2011 7:54 pm    Post subject: Get the Self-Handle from within a DSU Reply with quote

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
View user's profile Send private message Visit poster's website
bornsoft
Contributor
Contributor


Joined: 19 Feb 2009
Posts: 113
Location: Germany

PostPosted: Tue Oct 25, 2011 10:29 pm    Post subject: Reply with quote

@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
View user's profile Send private message Visit poster's website
Aslan
Valued Contributor
Valued Contributor


Joined: 31 May 2001
Posts: 589
Location: Memphis, TN USA

PostPosted: Sat Oct 29, 2011 1:23 pm    Post subject: Reply with quote

How about one line Wink
Code:
%R = @winatpoint(@dlgpos(,L),@dlgpos(,T))


or with VDS6
Code:
%R = @dlgpos(,I)

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
View user's profile Send private message Send e-mail
bornsoft
Contributor
Contributor


Joined: 19 Feb 2009
Posts: 113
Location: Germany

PostPosted: Sun Oct 30, 2011 8:34 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 6 Units All times are GMT
Page 1 of 1

 
Jump to:  
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




Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group