Jump to content
Software FX Community

add custom menu item


User (Legacy)
 Share

Recommended Posts

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

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

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...