Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4609110
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:56:25+00:00 2026-05-22T00:56:25+00:00

I am using Visual Basic 6 (please don’t laugh), and I would like to

  • 0

I am using Visual Basic 6 (please don’t laugh), and I would like to dynamically position a control, at runtime, in a position based upon the position of one of the “top level” menu items (such as “File”, “Edit”, “View”).

Unfortunately, VB’s Menu control (which is the type of control that these “File”, “Edit”, etc. things are) does not have any properties like “Top”, “Left”, “Height”, or “Width”.

I could just experiment, eyeballing it, and eventually arrive at numbers that I’ll hardcode, but for various reasons I would prefer that the code actually figure out where the control should go.

I am thinking that perhaps there is some Windows API call that I can use to figure out the position of the Menu control?

Thanks in advance.

Edit: In case it matters, this is on an MDI form.

Edit #2:

OK, answering my own question:

You can get the position of each item on the main menu bar via the GetMenuBarInfo function, such as:

    Dim mbi as MENUBARINFO
    mbi.cbSize = LenB(mbi)
    GetMenuBarInfo Me.hWnd, OBJID_MENU, lMenuNumber, mbi

Where “lMenuNumber” is 1 for the first (e.g. “File”), 2 for the second (e.g. “Edit”), etc.

That mbi struct has an rcBar member, which is the coordinates of the rectangle where that menu item is.

Unfortunately, it’s in absolute coordinates relative to the screen, not relative to the MDI form. So, get the mbi the one you’re interested in and of the first, and subtract.

Plus, the position as given in the mbi is in pixels, so convert as necessary to twips or whatever.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T00:56:26+00:00Added an answer on May 22, 2026 at 12:56 am

    OK, answering my own question:

    You can get the position of each item on the main menu bar via the GetMenuBarInfo function, such as:

        Dim mbi as MENUBARINFO
        mbi.cbSize = LenB(mbi)
        GetMenuBarInfo Me.hWnd, OBJID_MENU, lMenuNumber, mbi
    

    Where “lMenuNumber” is 1 for the first (e.g. “File”), 2 for the second (e.g. “Edit”), etc.

    That mbi struct has an rcBar member, which is the coordinates of the rectangle where that menu item is.

    Unfortunately, it’s in absolute coordinates relative to the screen, not relative to the MDI form. So, get the mbi the one you’re interested in and of the first, and subtract.

    Plus, the position as given in the mbi is in pixels, so convert as necessary to twips or whatever.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Visual Basic 9 (VS2008) and TagLib. The following code extracts the album
I'm using Visual Basic 9 (VS2008) I want to create new Tabs as and
I need to write an error log to a XML file using Visual Basic
In Visual Basic, is there a performance difference when using the IIf function instead
I'm developing a Desktop Search Engine in Visual Basic 9 (VS2008) using Lucene.NET (v2.0).
I'm using Visual Basic 2010 Express. I have a form that can be minimized.
I am using Visual Studio 2008. I have created a visual basic form that
Im using Visual Basic 2008 Express Is there a way to disable mouse click
I'm using Visual Basic .NET to work with a USB HID device. Most of
I am trying to compress an AVI file using Visual Basic 6.0 but having

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.