Jump to content
Software FX Community

AddPicture and C++


User (Legacy)
 Share

Recommended Posts

The following sample code adds a picture to the command bar and then adds an

item to the toolbar containing the added picture:

// Load picture from resources. IDB_BITMAP1 is a 16-Color bitmap measuring

16x15 pixels

IPictureDispPtr pPicDisp;

PICTDESC pd;

pd.cbSizeofstruct = sizeof(pd);

pd.picType = PICTYPE_BITMAP;

pd.bmp.hbitmap =

LoadBitmap(theApp.m_hInstance,MAKEINTRESOURCE(IDB_BITMAP1));

OleCreatePictureIndirect(&pd,IID_IPictureDisp,TRUE,(LPVOID *)&pPicDisp);

// Add picture to command bar

int nPicture = m_pChartFX->Commands->AddPicture(pPicDisp);

// Add command to command bar

m_pChartFX->Commands->AddCommand(101);

// Assign recently added picture to new command

m_pChartFX->Commands->Item[101]->Picture = nPicture;

// Replace first toolbar buttun with recently added command

m_pChartFX->ToolBarObj->Item[0]->CommandID = 101;

You can try this code by adding it to the MFC sample we provide, you will

need to add a bitmap IDB_BITMAP1 to your project as well.

--

FP

Software FX Support

"David Freer" <freer.mail@worldnet.att.net> wrote in message

news:w3KCU6qqCHA.2684@webserver1.softwarefx.com...

> Does anyone have an example showing how a bitmap, icon or whatever is

added

> to a command object to be used in a chart menu? How is the IPictureDisp

> used?

>

>

Link to comment
Share on other sites

  • 3 weeks later...

Thank you. It works great.

"Software FX Support" <support@softwarefx.com> wrote in message

news:ResTcYtqCHA.3228@webserver1.softwarefx.com...

> The following sample code adds a picture to the command bar and then adds

an

> item to the toolbar containing the added picture:

>

> // Load picture from resources. IDB_BITMAP1 is a 16-Color bitmap measuring

> 16x15 pixels

> IPictureDispPtr pPicDisp;

> PICTDESC pd;

>

> pd.cbSizeofstruct = sizeof(pd);

> pd.picType = PICTYPE_BITMAP;

> pd.bmp.hbitmap =

> LoadBitmap(theApp.m_hInstance,MAKEINTRESOURCE(IDB_BITMAP1));

> OleCreatePictureIndirect(&pd,IID_IPictureDisp,TRUE,(LPVOID *)&pPicDisp);

>

> // Add picture to command bar

> int nPicture = m_pChartFX->Commands->AddPicture(pPicDisp);

>

> // Add command to command bar

> m_pChartFX->Commands->AddCommand(101);

>

> // Assign recently added picture to new command

> m_pChartFX->Commands->Item[101]->Picture = nPicture;

>

> // Replace first toolbar buttun with recently added command

> m_pChartFX->ToolBarObj->Item[0]->CommandID = 101;

>

>

> You can try this code by adding it to the MFC sample we provide, you will

> need to add a bitmap IDB_BITMAP1 to your project as well.

>

> --

> FP

> Software FX Support

> "David Freer" <freer.mail@worldnet.att.net> wrote in message

> news:w3KCU6qqCHA.2684@webserver1.softwarefx.com...

> > Does anyone have an example showing how a bitmap, icon or whatever is

> added

> > to a command object to be used in a chart menu? How is the IPictureDisp

> > used?

> >

> >

>

>

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...