Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > API > Can anyone help me get a window position with API?


Reply
 
Thread Tools Display Modes
  #1  
Old 03-12-2001, 04:24 PM
SDouble
Guest
 
Posts: n/a
Question Can anyone help me get a window position with API?


I've been trying all sorts of things, but it seems I'm unable to figure it out on my own. I am trying to get a window position of a different application. Like an x,y position or a .top, .left Anything so I can find the window position of another window. Also if possible, is there anyway to get the window size of it? Thank you for your help.

Check out my site
<a href="http://www.sswebsites.com">http://www.sswebsites.com</a>
Reply With Quote
  #2  
Old 03-12-2001, 06:03 PM
Derek Stone
Guest
 
Posts: n/a
Default Re: Can anyone help me get a window position with API?

Use the GetWindowRect API function.

Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

Example:

Dim rctMain As RECT
GetWindowRect Me.hWnd, rctMain

This will store the window position and size in rctMain.

If you need to know how to get the window handle (hWnd) of an application window let me know.

Good Luck
-cl

<a href="http://vb.wsoftware.net" target="_new">http://vb.wsoftware.net</a>
Reply With Quote
  #3  
Old 03-12-2001, 08:28 PM
SDouble
Guest
 
Posts: n/a
Default Re: Can anyone help me get a window position with API?

Cool, thanks a lot. But how do I get the value for the left, right, top, and bottom? I've never worked with something like this before. Thanks for your help.

Check out my site
http://www.sswebsites.com
Reply With Quote
  #4  
Old 03-13-2001, 02:38 PM
Derek Stone
Guest
 
Posts: n/a
Default Re: Can anyone help me get a window position with API?

You would type something similar to the code below:

rctMain.Top
rctMain.Bottom
rctMain.Left
rctMain.Right

To get the width of the window you would type:

rctMain.Right - rctMain.Left

The code is virtually the same for finding the height of the window.

Good Luck
-cl

<a href="http://vb.wsoftware.net" target="_new">http://vb.wsoftware.net</a>
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->