Solved

VB6 How to get the absolute position of a control?

Posted on 2008-10-17
2
3,587 Views
Last Modified: 2013-12-20
I need to find the absolute position of a control within a VB6 application. (Absolute as in 0,0 = top,left of the Windows desktop).

I understand that VB.NET has a .PointToScreen method for doing this (I don't have .NET so I'm not sure).

The application is MDI-based and the controls may be in containers with different ScaleModes. Is there an API where you can pass the hWnd of a control and get back the absolute position?
0
Comment
Question by:AndyGroom
2 Comments
 
LVL 26

Accepted Solution

by:
EDDYKT earned 500 total points
ID: 22739265
Option Explicit
Private Type RECT
    Left As Long
    Top As Long
    right As Long
    bottom As Long
End Type



Private Declare Function GetWindowRect& Lib "user32" (ByVal hwnd As Long, lpRect As RECT)

Private Sub Command1_Click()
Dim rc As RECT
GetWindowRect Command1.hwnd, rc
Label1 = rc.Left & "  " & rc.Top & "  " & rc.right & "  " & rc.bottom
End Sub
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question