Results 1 to 3 of 3

Thread: Menu

  1. #1
    Join Date
    May 2003
    Posts
    144

    Unanswered: Menu

    Hi.

    Is it possible to have a menu automatically drop down when the mouse passes by it?

    Thanks

    SHK

  2. #2
    Join Date
    Nov 2003
    Posts
    1,487
    Sure..... but before we start:

    *** SAVE AND BACKUP YOUR PROJECT FIRST ***

    I would hate to think that you lost your most recent work because you messed up with the API function I am about to show you.

    Here is what you do. Create your shortcut menu (or use one of the built in ones). Select the name of the menu from within the ShortcutMenuBar property located under the Other tab of the control properties window for the control (let's say a textbox) you want to display the menu over.

    Now, copy and paste the following code API declaration and constants into the declarations section of your form code module (somewhere directly under the Option Explicit):

    Code:
    Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, _
    ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
    
    Const MOUSEEVENTF_LEFTDOWN = &H2
    Const MOUSEEVENTF_LEFTUP = &H4
    Const MOUSEEVENTF_MIDDLEDOWN = &H20
    Const MOUSEEVENTF_MIDDLEUP = &H40
    Const MOUSEEVENTF_MOVE = &H1
    Const MOUSEEVENTF_ABSOLUTE = &H8000
    Const MOUSEEVENTF_RIGHTDOWN = &H8
    Const MOUSEEVENTF_RIGHTUP = &H10
    Next, in the MouseMove event of your control (again, let's say a textbox) copy and paste the following API function:
    Code:
    mouse_event MOUSEEVENTF_RIGHTDOWN Or MOUSEEVENTF_RIGHTUP, 0&, 0&, 0&, 0&
    There you go. Now when the application is compiled & run, when you pass your mouse over the control, your shortcut menu pops up.

    You will notice that I have added all the constants for this API. This is so that you can play with it. You really only need the MOUSEEVENTF_RIGHTDOWN and MOUSEEVENTF_RIGHTUP constants to do what you want.

    Have fun playing with this one

  3. #3
    Join Date
    May 2003
    Posts
    144
    Thanks for your reply, CyberLynx.

    Your solution works when there is a control (say a text box) and the menu drops down when the mouse passes the control. I now need to go one step above where there is not going to be a control. The mouse passes the menu itself and the menu needs to drop down.

    For example, there are "File", "Edit", "View", "Insert" menus up at the toolbar in MS Access. Currently, we will need to press the "File" menu in order to see the options under the "FIle" menu. Is it possible to have the "File" menu drops down by simply passing the mouse over it, without pressing the menu.

    Thanks

    SHK

Posting Permissions

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