• UserForm Startup Position

    Author
    Topic
    #461510

    I have a custom button on an Excel toolbar that displays my Userform. In the Initialize event, I want to set the form’s Left & Top property so that the form starts up close to the mouse pointer.

    Currently, I am using the GetCursorPos API, using the X & Y as Left & Top. This is OK when my application is in the upper-left corner of the screen, but as I move accross/down the screen, the GetCursorPos values that I am using for Left & Top are too big by about 30%.

    So, for now, I just subtract 30% & it is close, but I would like to know how to properly convert and why? Points, pixels, TIA –Sam

    Viewing 1 reply thread
    Author
    Replies
    • #1171322

      The API uses pixels, I think, so you’d need the Application.Pointstoscreenpixelsx and PointstoscreenpixelsY to convert them.

    • #1171323

      IIRC the ratio from points to pixels is (usually) either 0.75 or 1/0.75

      • #1171343

        IIRC the ratio from points to pixels is (usually) either 0.75 or 1/0.75

        Thanks, Jan Karel! Since XL2K and earlier does not have PointsToScreenPixel…, (which was what I was looking for) .75 is the answer.

    Viewing 1 reply thread
    Reply To: UserForm Startup Position

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: