User (Legacy) Posted February 5, 2002 Report Share Posted February 5, 2002 I'm trying to add some menu item of my own. I didn't figure out what's wrong with the following code: void AddMenu() { IToolBarPtr pMenu; pMenu=m_pChartFX->MenuBarObj; pMenu->AddItems (1,6); pMenu->Visible = TRUE; pMenu->Commands ->Item[6]->Text = "My Menu"; pMenu->Item[6]->CommandID = CFX_ID_EXPORTFILE; } For the command id, could I add any command id that was not defined by ChartFX pre-defined command? If I could, how to associate that command id with some function I developed? Thanks, Link to comment Share on other sites More sharing options...
Software FX Posted February 5, 2002 Report Share Posted February 5, 2002 There are two objects you need to deal with: The command list and the Menu object. A menu is a collection of commands in the command list. You can add a Custom command or a predefined command to the menu (or toolbar).. pMenu->AddItems (1,6); Adds 1 menu item in position 6. You then need to specify what that menu item is by doing: pMenu->Item[6]->CommandID = CommandID; CommandID can be any of the predefined commands (e.g. CFX_ID_EXPORTFILE) or a custom command. To create a custom command: CommandID = 1; pMenu->Commands->AddCommand(CommandID); pMenu->Commands->Item[CommandID]->Text = "My Menu"; Then you will receive a UserCommand event when this menu item is selected. The CommandID being 1. -- FP Software FX, Inc. Link to comment Share on other sites More sharing options...
User (Legacy) Posted February 5, 2002 Author Report Share Posted February 5, 2002 Thanks for your help. I'm working on handle the UserCommand event myself. Could anyone tell me the dispatch id for the UserCommand ? (Or Where I can find the dispatch ID for all the event?) I need them in the definition of event sink map as follows: ON_EVENT(CCFXChildWindow, IDC_CHARTFX, ?/*UserCommand */,UserCommand, VTS_I4 VTS_I4 VTS_PI2) If I need to pop up a new dialog box when my menu item was selected, could I use the following event handle function? void CCFXChildWindow::UserCommand(WPARAM wParam,LPARAM lParam,int nRes) { CMyDialog pDlg; pDlg.DoModal(); } "SoftwareFX Support" <support@softwarefx.com> wrote in message news:jPZmlmlrBHA.2668@webserver1.softwarefx.com... > There are two objects you need to deal with: The command list and the Menu > object. > > A menu is a collection of commands in the command list. > > You can add a Custom command or a predefined command to the menu (or > toolbar).. > > pMenu->AddItems (1,6); > > Adds 1 menu item in position 6. > > You then need to specify what that menu item is by doing: > > pMenu->Item[6]->CommandID = CommandID; > > CommandID can be any of the predefined commands (e.g. CFX_ID_EXPORTFILE) or > a custom command. To create a custom command: > > CommandID = 1; > pMenu->Commands->AddCommand(CommandID); > pMenu->Commands->Item[CommandID]->Text = "My Menu"; > > Then you will receive a UserCommand event when this menu item is selected. > The CommandID being 1. > > > > > -- > 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.