Print Page | Close Window

Context Menu on MDI form control

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=7887
Printed Date: 18 June 2025 at 7:39am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Context Menu on MDI form control
Posted By: sanddevil
Subject: Context Menu on MDI form control
Date Posted: 28 August 2007 at 5:49am
Hi!! I've been trying to create a context menu using CommandBars ActiveX for the last 2 days but with no success. I've had a look through the samples and I can't see anything to help me. I am new to the product and fairly new to C++.
 
I would like to create a context menu on a control on an MDI client form. A right click would produce a menu list with the usual "Copy/Cut/Paste" plus a few others.
 
Can anyone paste a few lines of code to give me a start please? All help gratefully received. I'm coding in C++.Net  but could probably translate any snippets from C# or VB.
 
Many thanks in advance.



Replies:
Posted By: apuhjee
Date Posted: 28 August 2007 at 11:42am

Here is some code that is used to close tab workspace tabs.  Other context menus will look similar.

Cheers ~ jp
 
 
private void tabWorkspace_RClick(XtremeCommandBars.TabControlItem Item)
{
     if (Item != null)
     {
          tabCurrent = Item;
          CommandBar popup = CommandBars.Add("Context Menu", XtremeCommandBars.XTPBarPosition.xtpBarPopup);
          CommandBarControl control = popup.Controls.Add(XTPControlType.xtpControlButton, ID.ID_TAB_CLOSE, "Close", null, false);
          popup.ShowPopup(XtremeCommandBars.XTPTrackPopupFlags.TPM_RIGHTBUTTON, null, null);
     }
}


-------------
I like mathematics because it is not human and has nothing particular
to do with this planet or with the whole accidental universe — because,
like Spinoza's God, it won't love us in return.


Posted By: sanddevil
Date Posted: 28 August 2007 at 1:28pm
Hi! Many thanks jp - much appreciated. My C++ code actually looks the same as yours but a problem persists. When I call CommandBars.Add, the returned CommandBar popup is a null pointer  - which suggests to me the Add call is not working.
 
A quick look at the debugger confirms this - the count is set to zero controls so Add definitely failed.   I don't have a clue why. Any ideas?
 
Cheers!



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net