Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
990
Get contextmenu bounds to handle position of minitoolbar
posted

Hello,

i have a question about the contextmenu and it's bounds. If i use a toolbarsmanager and a control with contextmenu and minitoolbar, the tbm decides where to show the menu and where to show the minitoolbar in case of the position of the screen. That works fine.

But we have a problem. We have more than one tbm. One tbm on the form and another one on a usercontrol. On this usercontrol there is a grid control. This grid control should show a contextmenu and a minitoolbar also. But the contextmenu is handled by the form-tbm and the minitoolbar by the tbm of the usercontrol.

The structure with two tbm is necessary because the usercontrol has a toolbar (which contains same tools shown in the minitoolbar [like a QuickAccesToolbar]). This toolbar could not be linked to the forms toolbarmanager, because each tbm can only have one dockarea for each side.

Another reason is, that the usercontrol can be on the form multiple times. And all toolclicks of the minitoolbar should only be handled in each respective instance of the usercontrol.

The toolclicks of the grid contextmenu show be handled by the form. So the tools have to be in the forms tbm.

My problem is: The contextmenu is showing by forms tbm by rightclicking on the grid and i coded the minitoolbar.show call also. So far so good. But how can i adjust the minitoolbarposition on the base of the contextmenu? Is it possible to get the menu bounds?

Best regards,

Bjoern

  • 990
    Verified Answer
    posted

    It's me again. After nobody responded i searched a lot and found a solution.

    For future searches:

    Loop through all childtools of the popupmenu. If tool is visible then add bounds to an variable (rectangle.Union).

    After the loop the boundsvariable contains the size of the contextmenu.

     

    Bjoern