Posts by MaxR

Important Notice

Please note that on 14th December 2023 users will experience an expected outage whilst we make upgrades to our network. We anticipate this process may take a couple of hours and so we apologise in advance for any inconvenience.

    Here's an idea. All the methods of open a userform near the cursor seem to rely on Windows API calls, but what about if you just use the MouseDown function. At least if you're opening a second userform from another, then the MouseDown event of the object on the userform, you're going to click, dlb-click etc. to open the 2nd form provides the X and Y coords within that object. So to position the 2nd userform, in the project global variables (say Module 1), define:

    Public CursorX, CursorY as Single

    WIthin the MouseDown event of the object include:

    CursorX = X

    CursorY = Y

    Within the Userform2_Initialise include

    Userform2.left = Userform1.left + Userform2.obj.left + CursorX

    Userform2.Top = + + CursorY + 25

    Then userform2 will appear to the right of the cursor position. The 25 offset in Userform2.Top is to account for the title bar.

    Where possible I avoid Windows APIs as they are not portable to, say, Mac OSX and if you have them in your code, you need to have conditional statements checking for the OS to be Windows or not - messy if it can be avoided.