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 


Using the Window Handle...

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Knowledge Base
View previous topic :: View next topic  
Author Message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Sat Dec 07, 2002 5:47 am    Post subject: Using the Window Handle... Reply with quote

The window "handle" is a unique ID number that's
assigned to every window by the Windows OS,
and is used instead of window titles, classes, etc.
for identification.

The undocumented @win() and the standard @winexists()
both dependably return the window "handle". They seem
to function identically.

[EDIT] Apparently @win() is only an abbreviation for
@winexists() - more discussion on this below...


By using the window "handle", you don't have to worry
with class names (making sure each one is unique) or
window title names which, like class names, are always
the same for multiple instances. It can be used with any
VDS command/function that requires a window name or
class.

Retrieve the "handle" immediately after DIALOG CREATE
for accuracy. Here's an example using WINDOW POSITION
and @winpos().

Compile and open as many as ya want... Wink
______________________________________________________________________________________________
Code:

OPTION SCALE, 96
OPTION DECIMALSEP, "."
TITLE By Mac
DIALOG CREATE,"Test Program",50,100,170,52
  %%hwnd = @winexists("Test Program")
  DIALOG ADD,BUTTON,Large,5,5,45,22
  DIALOG ADD,BUTTON,Small,5,55,45,22
  DIALOG ADD,BUTTON,Handle,5,105,60,22,"Handle #"
  DIALOG ADD,TEXT,T1,32,5,,,"Window TLWH= "@winpos(%%hwnd, TLWH)
DIALOG SHOW

:EVLOOP
  WAIT EVENT
  goto @event()

:LargeBUTTON
  WINDOW POSITION,%%hwnd,,,300,200
  DIALOG SET, T1, "Window TLWH= "@winpos(%%hwnd, TLWH)
  goto EVLOOP

:SmallBUTTON
  WINDOW POSITION,%%hwnd,,,176,77
  DIALOG SET, T1, "Window TLWH= "@winpos(%%hwnd, TLWH)
  goto EVLOOP

:HandleBUTTON
  INFO %%hwnd
  goto EVLOOP

:CLOSE
  EXIT

NOTE: The window handle can also be retrieved with
@winactive() and @winatpoint(), but both require the
window to be "on top". Wink

Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361


Last edited by Mac on Sun Dec 08, 2002 12:55 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Sat Dec 07, 2002 12:18 pm    Post subject: Reply with quote

Mac wrote:
The undocumented @win() and the standard @winexists()
both dependably return the window "handle". They seem
to function identically.


Any command or function can be abbreviated in VDS. Try the code below:
Code:
t Test
D CREATE,New Dialog,-1,0,240,160
D ADD,BUTTON,BUTTON1,47,58,,,BUTTON1
D SHOW
i @wi(New Dialog)
war This is a test
en
exi

_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Sat Dec 07, 2002 1:43 pm    Post subject: Reply with quote

Hi FF,

I didn't know that! But now I've seen it, I realised that it can be even shorter!

Code:
t Test
d cr,New Dialog,-1,0,240,160
d ad,b,BUTTON1,47,58,,,BUTTON1
d sh
i @wi(New Dialog)
war This is a test
en
ex


There is only one big problem with this kind of programming, you can't see what you're doing...
Back to top
View user's profile Send private message
Tommy
Admin Team


Joined: 16 Nov 2002
Posts: 746
Location: The Netherlands

PostPosted: Sat Dec 07, 2002 6:02 pm    Post subject: Reply with quote

I wouldn't recommend using abbreviations like that. If S.A.D.E. would ever for example
add a DIAL command in addition to the DIALOG command, the "D" would suddenly
mean DIAL rather than DIALOG.


Last edited by Tommy on Sat Dec 07, 2002 11:01 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Sat Dec 07, 2002 8:25 pm    Post subject: Reply with quote

Skit, Let's not get too lazy now!! Wink If you ever plan to share the
code that you've done a lot of abbreviations with, the other person may
not have a clue what "@wi()" is or even "@win()" is. In fact, even I forget
which function @win() is for. Also, future versions of VDS may not
recognize the abbreviated stuff and then you'll be spending too much
going through your scripts fixing all the abbreviated stuff to full function
names and full command names.

-Garrett
Back to top
View user's profile Send private message
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Sat Dec 07, 2002 8:29 pm    Post subject: Reply with quote

That's what I said! Smile Other people don't get what you're doing, and it can confuse even yourself! It is only handy if you have a long code (20 kb or something) and you want the compiled version as small as possible...
Back to top
View user's profile Send private message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Sat Dec 07, 2002 8:32 pm    Post subject: Reply with quote

FreezingFire wrote:

Any command or function can be abbreviated in VDS.

Not necessarily FF. Only unique abbreviations can
be used, or else VDS uses the first one that matches. Wink

I assume the functions are checked in alphabetical order,
in which case @win() should catch @winactive() if it
were an abbreviation, just like @as() catches @asc()
instead of @ask().

BTW, @winactive(), @winatpoint(), @winclass(), @windir(),
and @window() are all alphabetically before @winexists().

I still think @win() is either a function of it's own or a clone
of @winexists(). Wink

Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Sat Dec 07, 2002 8:40 pm    Post subject: Reply with quote

If it is a function, it should have some more commands!
Back to top
View user's profile Send private message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Sat Dec 07, 2002 9:02 pm    Post subject: Reply with quote

Why? If nothing else, it's a handy alternative to typing
@ w i n e x i s t s.... Razz Laughing

I wasn't trying to spotlight an unknown function - @win()
is used extensively in the VDS API help file. This thread was
about using window "handles"... Wink

Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Sat Dec 07, 2002 9:11 pm    Post subject: Reply with quote

Oops, your right... Got a little of the road... Smile
Back to top
View user's profile Send private message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Sun Dec 08, 2002 1:06 am    Post subject: Reply with quote

Well, to clear things up a little (hopefully)... Confused

Apparently @win() is an abbreviation for @winexists().

Everything from @w() thru @winexists() does the
exact same thing (if it's not an abbreviation, @win() and
@winexists() would have to be the first two functions
checked, and while this is possible, I don't think it's likely...).

If so.... this means that VDS doesn't always check for
abbreviated commands and functions in alphabetical order.
Also (as Tommy mentioned) abbreviations that work now
may not work in future versions of VDS.

And since I agree with Garrett on typing the full commands,
I edited the code to use @winexists() to retrieve the "handle". Wink

Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Knowledge Base 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 can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group