User (Legacy) Posted February 28, 2002 Report Share Posted February 28, 2002 Hi, I can add the custom command to the menu as follows: IToolBarPtr pMenu; int CommandID; pMenu=m_pChartFX->MenuBarObj; pMenu->AddItems (3,6); pMenu->Visible = TRUE; CommandID = 1; pMenu->Commands->AddCommand(CommandID); pMenu->Commands->Item[CommandID]->Text = "My Menu Item 1"; pMenu->Item[6]->CommandID = CommandID; CommandID = 2; pMenu->Commands->AddCommand(CommandID); pMenu->Commands->Item[CommandID]->Text = "My Menu Item 2"; pMenu->Item[7]->CommandID = CommandID; CommandID =3; pMenu->Commands->AddCommand(CommandID); pMenu->Commands->Item[CommandID]->Text = "My Menu Item 3"; pMenu->Item[8]->CommandID = CommandID; Then those 3 menu items will appear from position 6 to 8. I wonder how to add only one item(eg. My Menu) in position 6 and those three items are added as subitem of position 6? It should look like: My Menu My Menu Item 1 My Menu Item 2 My Menu Item 3 Thanks in advance, Link to comment Share on other sites More sharing options...
Software FX Posted March 4, 2002 Report Share Posted March 4, 2002 Chek out article Q1381058, it shows you how to add "Menu" commands. Here is the code in VB (the article is in C++): ChartFX1.Commands.AddCommand (1) ChartFX1.Commands.AddCommand (2) ChartFX1.Commands.AddCommand (3) 'We are not using the default style for the first command ChartFX1.Commands.Item(1).Style = CBIS_SMARTLIST 'Set the text that will be in the tooltip for each command ChartFX1.Commands.Item(1).Text = "&MyCommand" ChartFX1.Commands.Item(2).Text = "&CmdOpt1" ChartFX1.Commands.Item(3).Text = "&CmdOpt2" ' Add and position the command on to the toolbar ChartFX1.ToolBarObj.AddItems 1, 15 ChartFX1.ToolBarObj.Item(15).CommandID = 1 'Add and position the command on to the Background Menu ChartFX1.Commands.Item(CFX_ID_CM_BACKGROUND).InsertSubCommands 1, 12 ChartFX1.Commands.Item(CFX_ID_CM_BACKGROUND).SubCommandID(12) = 1 ' Add SubCommands to the first Command ChartFX1.Commands.Item(1).InsertSubCommands 2, 0 ChartFX1.Commands.Item(1).SubCommandID(0) = 2 ChartFX1.Commands.Item(1).SubCommandID(1) = 3 -- FP Software FX, Inc. Link to comment Share on other sites More sharing options...
User (Legacy) Posted March 6, 2002 Author Report Share Posted March 6, 2002 I tried the code in Q1381058, but no menu item was added to the chartfx menu, only in toolbar and background menu. I still have several questions: 1. I got undeclared identifier error when I used CBS_NOIMAGEIFTEXT to set the style for command item. 2. Since I'm not going to use those pre-defined chart fx command, I wonder what is the item index of command I can use for the following code? m_pChartFX->Commands->Item[???]->InsertSubCommands(1,12); m_pChartFX->Commands->Item[???]->SubCommandID[12]=...; 3. How can I add and position the commands to the Menu bar instead of Background Menu? The sample code in Q1381058 only add and position the command on to the Background Menu. As I mentioned in previous post, I want to add a group of menu item after help menu item in chart fx menu. It should look like: File Edit Tool View Gallery Help My Menu My Menu Item 1 My Menu Item 2 My Menu Item 3 "SoftwareFX Support" <support@softwarefx.com> wrote in message news:EB3yrK5wBHA.1412@webserver1.softwarefx.com... > Chek out article Q1381058, it shows you how to add "Menu" commands. Here is > the code in VB (the article is in C++): > > ChartFX1.Commands.AddCommand (1) > ChartFX1.Commands.AddCommand (2) > ChartFX1.Commands.AddCommand (3) > > 'We are not using the default style for the first command > ChartFX1.Commands.Item(1).Style = CBIS_SMARTLIST > > 'Set the text that will be in the tooltip for each command > ChartFX1.Commands.Item(1).Text = "&MyCommand" > ChartFX1.Commands.Item(2).Text = "&CmdOpt1" > ChartFX1.Commands.Item(3).Text = "&CmdOpt2" > > ' Add and position the command on to the toolbar > ChartFX1.ToolBarObj.AddItems 1, 15 > ChartFX1.ToolBarObj.Item(15).CommandID = 1 > > 'Add and position the command on to the Background Menu > ChartFX1.Commands.Item(CFX_ID_CM_BACKGROUND).InsertSubCommands 1, 12 > ChartFX1.Commands.Item(CFX_ID_CM_BACKGROUND).SubCommandID(12) = 1 > > ' Add SubCommands to the first Command > ChartFX1.Commands.Item(1).InsertSubCommands 2, 0 > ChartFX1.Commands.Item(1).SubCommandID(0) = 2 > ChartFX1.Commands.Item(1).SubCommandID(1) = 3 > > > > -- > FP > Software FX, Inc. > > Link to comment Share on other sites More sharing options...
Software FX Posted March 7, 2002 Report Share Posted March 7, 2002 1) Make sure you add SFXBAR.DLL to your project references. VB will ask you if you want to when you use a constant that is defined inside it like CBIS_NOIMAGEIFTEXT. 2) The command ID is specified by you when you add it. For example: ChartFX1.Commands.AddCommand (1) Is adding a command with ID = 1 Like in the sample I sent you, after I add command ID = 1 I add subitems to it: ChartFX1.Commands.Item(1).InsertSubCommands 2, 0 ChartFX1.Commands.Item(1).SubCommandID(0) = 2 ChartFX1.Commands.Item(1).SubCommandID(1) = 3 The 1 in the Item index corresponds to the ID. 3) In the sample, it is added to the toolbar because of these two lines: ChartFX1.ToolBarObj.AddItems 1, 15 ChartFX1.ToolBarObj.Item(15).CommandID = 1 You can add it to the menu the same way using MenuBarObj instead of ToolBarObj. To add it to a context menu, you have to add it as a sub-item of the appropriate context menu (background, series, etc.). -- FP Software FX, Inc. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.