Results 1 to 4 of 4

Thread: ActiveX Control Positioning

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Location
    MD
    Posts
    2

    Unhappy

    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
    If its too good to be true, it probably isn't

  2. #2
    Fanatic Member gwdash's Avatar
    Join Date
    Aug 2000
    Location
    Minnesota
    Posts
    666
    try adding the parent forms top and left to the text box top and left.
    GWDASH
    [b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Location
    MD
    Posts
    2

    yup..

    Yeah.. been there.. tried that.. doesn't work...

    thanks ne wayz..
    If its too good to be true, it probably isn't

  4. #4
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    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


    Code:
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width