PDA

Click to See Complete Forum and Search --> : ActiveX Control Positioning


genie_of_agrabah
Aug 13th, 2000, 04:18 PM
I am developing an ActiveX control. And for some of the functions that i wish to perform, i need to know the location of the usercontrol form WITH RESPECT TO THE SCREEN. i mean like not w.r.t to its parent or anthing, but i need to know the position of the control w.r.t the screen itself. I realize that there are no Ambient properties that expose this. is there a way around using API?

Actually , let my try to put it more clearly. I have a textbox in a usercontrol. Is there a method or an API through which i can learn the position or coordinates of the textbox with respect to (0,0) of the desktop ? the .top and .left aren't of much use because they return the position with respect to their parent controls. Is there a way around ?

Thanks a lot in advance,
Genie

gwdash
Aug 13th, 2000, 04:35 PM
try adding the parent forms top and left to the text box top and left.

genie_of_agrabah
Aug 13th, 2000, 04:45 PM
Yeah.. been there.. tried that.. doesn't work...

thanks ne wayz..

Sam Finch
Aug 13th, 2000, 04:45 PM
the GetWindowRect API will get the Controlls position on the screen in pixels. Adding the parents position to the usercontrols position gets a bit tricky with scalemodes and just doesn't work if the usercontol is in a frame, picturebox or MDI child form try this



Private Type RECTL
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

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



Private Function GetPosition (hWnd As Long) As RECT

dim retval As RECT

Call GetWindowRect9hWnd,retval)

GetPosition = retval

End Function

The RECT UDT returned by this will Contain all the info about the window in pixels