I want to use the default PDF-XChange icons on my own buttons on my application ribbonBar. I have come across the following post https://www.pdf-xchange.com/forum3 ... ns#p101826 however I don't understand how I can get the icon image returned. For example I would like to use your default annotation line icon on a button, which obviously means I need to return the icon as a bitmp or similar so I can add it to my button property.
Thanks
Simon
Use default icons on my own ribbonBar...
Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan
Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.
When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.
When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Use default icons on my own ribbonBar...
Hello Simon,
Here's the way to do it:
Cheers,
Alex
Here's the way to do it:
Code: Select all
private void iconToBitmapToolStripMenuItem_Click(object sender, EventArgs e)
{
IUIX_Cmd cmd = uiInst.CmdManager.Cmds.Find("cmd.save");
IUIX_ImageData iData = null;
tagRECT rc;
cmd.Icon.GetItem(0, out iData, out rc);
Bitmap image = new Bitmap(rc.right - rc.left, rc.bottom - rc.top);
Rectangle rect = new Rectangle(0, 0, image.Width, image.Height);
System.Drawing.Imaging.BitmapData bmpData = image.LockBits(rect, ImageLockMode.ReadWrite, image.PixelFormat);
IntPtr outPtr = bmpData.Scan0;
byte[] rgbValues = new byte[bmpData.Stride];
uint nScan0 = (uint)(iData.Scan0 + iData.Stride * rc.top + rc.left * 4);
IntPtr ptr = new IntPtr(nScan0);
for (uint y = 0; y < (rc.bottom - rc.top); y++)
{
System.Runtime.InteropServices.Marshal.Copy(ptr, rgbValues, 0, (rc.right - rc.left) * 4);
ptr = IntPtr.Add(ptr, iData.Stride);
System.Runtime.InteropServices.Marshal.Copy(rgbValues, 0, outPtr, (rc.right - rc.left) * 4);
outPtr = IntPtr.Add(outPtr, bmpData.Stride);
}
image.UnlockBits(bmpData);
image.Save("D:\\TestFile.bmp");
}
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ