tag:blogger.com,1999:blog-82396315107515970862024-03-08T22:01:58.276+06:00Unmanaged VisioVisio developer's side notesNikolay Belyhhttp://www.blogger.com/profile/08269355782648556627noreply@blogger.comBlogger9125tag:blogger.com,1999:blog-8239631510751597086.post-20818071853116214292012-07-01T21:33:00.000+07:002013-04-10T21:36:07.291+07:00Blog moved to own siteBlog moved to the own site - <a href="http://unmanagedvisio.com/">http://unmanagedvisio.com</a>Nikolay Belyhhttp://www.blogger.com/profile/08269355782648556627noreply@blogger.com0tag:blogger.com,1999:blog-8239631510751597086.post-32821491351922465312012-04-24T19:30:00.001+07:002013-04-12T19:01:48.297+07:00Map of RussiaVisio map of Russia (with regions). The map is in native vector format. <br />Ported from the Wikipedia SVG.<br />
Download: <a href="http://unmanagedvisio.com/map-of-russia-in-visio/">http://unmanagedvisio.com/map-of-russia-in-visio/</a>Nikolay Belyhhttp://www.blogger.com/profile/08269355782648556627noreply@blogger.com0tag:blogger.com,1999:blog-8239631510751597086.post-60027673622957450542011-08-24T08:50:00.001+07:002012-04-17T12:09:06.594+07:00Web site started<p><a href="http://lh4.ggpht.com/-ybniT0RtpQs/TlRY_mzVhsI/AAAAAAAADK0/z0mxUBY7is8/s1600-h/IMG%25255B1%25255D.png"><img style="background-image: none; border-right-width: 0px; margin: 0px 7px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="IMG" border="0" alt="IMG" align="left" src="http://lh4.ggpht.com/-njGdlt_90Co/TlRZAEuDjhI/AAAAAAAADK4/H_OaWvs4wMA/IMG_thumb%25255B1%25255D.png?imgmax=800" width="84" height="109" /></a>Recently I decided to start a website to present my Visio utilities in a “proper” way. Currently there is only the “Find command” plugin (updated version, plus x64 version), although there will a number of other Visio utilities in the nearest future. </p> <p>Keep close eye on: <a href="http://unmanagedvisio.com">http://unmanagedvisio.com</a></p> Nikolay Belyhhttp://www.blogger.com/profile/08269355782648556627noreply@blogger.com0tag:blogger.com,1999:blog-8239631510751597086.post-71720043859930457182011-06-27T05:09:00.001+07:002013-04-06T04:43:20.284+07:00“Find Visio Command” AddinHave you ever tried to find a command in ribbon?<br />
Here is a new add-in which allows to quickly find commands in Visio 2010. Just type in the keyword which is part of command name, and hit enter. All commands which contain this keyword will be shown by the plugin as buttons. You can either use the command found directly from the results pane, or add it to the quick launch toolbar.<br />
<a href="http://unmanagedvisio.com/find-visio-command-addin/">Download it here</a>!<br />
The big picture:<br />
<a href="http://lh6.ggpht.com/-o326J-D5fYw/TgeuAzu3CzI/AAAAAAAADKA/j-Z02f6dIQg/s1600-h/27-06-2011%2525204-57-14%25255B3%25255D.png"><img alt="27-06-2011 4-57-14" border="0" height="292" src="http://lh3.ggpht.com/-aLZNFKpiYgA/TgeuBoS1SyI/AAAAAAAADKE/kirokFYtFfQ/27-06-2011%2525204-57-14_thumb%25255B3%25255D.png?imgmax=800" style="background-image: none; border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="27-06-2011 4-57-14" width="639" /></a><br />
Introductory video:<br />
<div class="wlWriterSmartContent" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:0418edc9-5f61-497e-88f6-79e79299aaa1" style="display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">
<div id="c8ff29e4-5d3f-4e79-b9e8-67c80a913d4b" style="display: inline; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">
<div>
<a href="http://www.youtube.com/watch?v=KJowDTZXihI" target="_new"><img alt="" galleryimg="no" onload="var downlevelDiv = document.getElementById('c8ff29e4-5d3f-4e79-b9e8-67c80a913d4b'); downlevelDiv.innerHTML = "<div><object width=\"448\" height=\"277\"><param name=\"movie\" value=\"http://www.youtube.com/v/KJowDTZXihI?hl=en&hd=1\"><\/param><embed src=\"http://www.youtube.com/v/KJowDTZXihI?hl=en&hd=1\" type=\"application/x-shockwave-flash\" width=\"448\" height=\"277\"><\/embed><\/object><\/div>";" src="http://lh3.ggpht.com/-4DQvbABv3FA/TgjP2pnoFoI/AAAAAAAADKg/6JzMSbG3X1o/video5f2614f0d33c%25255B5%25255D.jpg?imgmax=800" style="border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none;" /></a></div>
</div>
<div style="clear: both; font-size: 0.8em; width: 448px;">
Find Visio Command</div>
</div>
Limitations: <br />- Does not work with x64 version of Microsoft Visio 2010 yet. <br />- Search works in in English only yet.Nikolay Belyhhttp://www.blogger.com/profile/08269355782648556627noreply@blogger.com0tag:blogger.com,1999:blog-8239631510751597086.post-50995767444327699642011-04-05T02:40:00.000+07:002012-04-17T12:09:38.788+07:00Using the same set of button images with transparency in Visio 2003, 2007 and 2010<p><a href="http://lh5.ggpht.com/_rkiUns3tLpE/Tdx1uKSo0KI/AAAAAAAADJk/RfNByw5uMSs/s1600-h/scan%20001%5B2%5D.jpg"><img style="background-image: none; border-right-width: 0px; margin: 0px 8px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="scan 001" border="0" alt="scan 001" align="left" src="http://lh3.ggpht.com/_rkiUns3tLpE/Tdx1uhEgVMI/AAAAAAAADJo/vMRSkC3vPCc/scan%20001_thumb.jpg?imgmax=800" width="86" height="106" /></a>It comes without saying that ribbon interface is cool, times easier to use (especially for developers =), and supports many new controls and neat features.</p> <p>However, if you write a Visio add-in that targets multiple Visio versions at the same time, and have some custom buttons with images (with transparency), you might run into trouble with that new Visio 2010 Ribbon user interface needs different “flavor” of images compared to Visio 2003 and 2007. So you’ll have to to either create two separate sets of images (one set for pre-ribbon version of Visio, the second set for the ribbon one), or to “dance around a little” and make both versions consume the same set of images. The article focuses on the second approach I ended up with.</p> <p><a href="http://lh3.ggpht.com/_rkiUns3tLpE/Tdq4iL1QmHI/AAAAAAAADJM/oT06msYGlyw/s1600-h/image12.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_rkiUns3tLpE/Tdq4i7SKQfI/AAAAAAAADJQ/eG_t7j06geo/image_thumb8.png?imgmax=800" width="352" height="311" /></a></p> <p><a href="http://lh3.ggpht.com/_rkiUns3tLpE/Tdq4jddTPcI/AAAAAAAADJU/DBg7i29a7z0/s1600-h/image34.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" align="left" src="http://lh6.ggpht.com/_rkiUns3tLpE/Tdq4kGR7hDI/AAAAAAAADJY/gkDtyxPnYRM/image_thumb24.png?imgmax=800" width="633" height="260" /></a></p> <p><a href="http://sites.google.com/site/nbelyh/TransparencyTest4CPP.zip" target="_blank">Download sample project (C++)</a></p> <p><a href="http://sites.google.com/site/nbelyh/TransparencyTest4CS.zip" target="_blank">Download sample project (C#)</a></p> <a name='more'></a> <p>In the old versions of Office, you could set the button picture using the “.Picture” and the “.Mask” properties of the “CommandBarButton” object. For Visio 2010, you should return the picture from your add-in, and that picture you return is expected to be PNG with transparency.</p> <p>The solution described here uses single PNG source image, and creates “.Mask” and “.Picture” images for previous versions of Visio out of it. To do so it uses the “AxHost” technique <a href="http://msdn.microsoft.com/en-us/library/ms268747.aspx" target="_blank">described in MSDN</a>:</p> <pre class="brush: csharp;"> // ---------------
Bitmap picture, mask;
PictureConvert.BitmapToPictureAndMask(Resources.MyPicture, out picture, out mask);
button.Picture = PictureConvert.ImageToPictureDisp(picture);
button.Mask = PictureConvert.ImageToPictureDisp(mask);
// ---------------
internal class PictureConvert : System.Windows.Forms.AxHost
{
private PictureConvert() : base("") { }
static public stdole.IPictureDisp ImageToPictureDisp(Bitmap image)
{
return (stdole.IPictureDisp)GetIPictureDispFromPicture(image);
}
static public void BitmapToPictureAndMask(Bitmap bm, out Bitmap picture, out Bitmap mask)
{
int w = bm.Width;
int h = bm.Height;
byte[] picture_data = new byte[3 * w * h];
byte[] mask_data = new byte[3 * w * h];
BitmapData bm_bits = bm.LockBits(new Rectangle(0, 0, w, h), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
byte[] bits = new byte[4 * w * h];
Marshal.Copy(bm_bits.Scan0, bits, 0, 4 * w * h);
bm.UnlockBits(bm_bits);
for (int y = 0; y < h; ++y)
{
for (int x = 0; x < w; ++x)
{
int src_idx = (x + y * w) * 4;
int dst_idx = (x + y * w) * 3;
picture_data[dst_idx + 0] = bits[src_idx + 0];
picture_data[dst_idx + 1] = bits[src_idx + 1];
picture_data[dst_idx + 2] = bits[src_idx + 2];
byte t = (bits[src_idx + 3] < 128) ? (byte)255 : (byte)0;
mask_data[dst_idx + 0] = t;
mask_data[dst_idx + 1] = t;
mask_data[dst_idx + 2] = t;
}
}
Rectangle rect = new Rectangle(0, 0, w, h);
picture = new Bitmap(w, h, PixelFormat.Format24bppRgb);
BitmapData picture_bits = picture.LockBits(rect, ImageLockMode.WriteOnly, picture.PixelFormat);
Marshal.Copy(picture_data, 0, picture_bits.Scan0, w * h * 3);
picture.UnlockBits(picture_bits);
mask = new Bitmap(w, h, PixelFormat.Format24bppRgb);
BitmapData mask_bits = mask.LockBits(rect, ImageLockMode.WriteOnly, picture.PixelFormat);
Marshal.Copy(mask_data, 0, mask_bits.Scan0, w * h * 3);
mask.UnlockBits(mask_bits);
}
}</pre>
<p>The idea for the unmanaged (C++) version is quite similar though much more wordy; the source code for the C++ project includes the implementation of the C++ version “PictureConvert” function. The code in the sample uses the <a href="http://msdn.microsoft.com/en-us/library/ms533798.aspx" target="_blank">gdiplus</a> API to construct the <a href="http://msdn.microsoft.com/en-us/library/ms680762.aspx" target="_blank">IPictureDisp</a> (needed by Visio) out of the PNG images stored in the addin’s resources.</p> Nikolay Belyhhttp://www.blogger.com/profile/08269355782648556627noreply@blogger.com0tag:blogger.com,1999:blog-8239631510751597086.post-24705816924461374232010-05-15T20:54:00.002+07:002012-04-17T12:13:32.563+07:00Persisting Visio shapes<p><a href="http://lh4.ggpht.com/_rkiUns3tLpE/TdqoUZ-A1UI/AAAAAAAADI8/QJuR4-fGfMg/s1600-h/kitten.png"><img style="background-image: none; border-right-width: 0px; margin: 0px 8px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="kitten" border="0" alt="kitten" align="left" src="http://lh3.ggpht.com/_rkiUns3tLpE/S-_kGDjPLmI/AAAAAAAADJA/JoBeH8-wPxg/kitten_thumb.png?imgmax=800" width="81" height="113" /></a> </p> <p>After <a href="http://groups.google.com/group/microsoft.public.visio.developer/msg/1d3e8c478a7d48f3">this post</a> in microsoft.public.visio.developers newsgroup I was asked a few times, how to save Visio shapes in external source exactly, so here is the code to store master/shape in a stream and then drop it back to the document:</p> <p><a href="http://sites.google.com/site/nbelyh/ShapePersistenceCPP.zip">Download sample project (C++)</a></p> <p><a href="http://sites.google.com/site/nbelyh/ShapePersistenceCS.zip">Download sample project (C#)</a></p> <p>To save Visio shapes in some external system (persist them) you can:</p> <p>- Query master or shape you want to persist for IDataObject interface. <br />- Using this interface, obtain data blob in "Visio 11 Shapes" clipboard format (or maybe actually anything that contains “Shapes” word to be compatible with further Visio versions, please refer to the code).</p> <p>Now this blob can be stored any way you want (database/memory/file/whatever). The sample code just saves it to a string variable in base64 encoding. To drop shapes back to the drawing, you can use "Drop" functions of Visio document/page. It turned out that these functions are happy enough with plain IDataObject interface passed in. So, to drop the stored master or shape back to the drawing: </p> <p>- Create you own object that implements IDataObject interface. <br />- Load this object with your data <br />- Pass this object in one of those "Drop" functions (e.g. Page.Drop)</p> <a name='more'></a> <span style="text-align: justify; widows: 2; text-transform: none; text-indent: 0px; letter-spacing: normal; border-collapse: separate; font: 13px 'Segoe UI', tahoma, verdana, arial, helvetica; white-space: normal; orphans: 2; color: rgb(80,80,80); word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" class="Apple-style-span"><span style="white-space: nowrap; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px" class="Apple-style-span"></span>For managed code, all this stuff can be done using “DataObject” framework class that is capable of handling all nasty details for you behind the screen. Here is the basic idea:</span> <pre class="brush: csharp;">string _clipFormat;
string _shapeData;
void SaveShape(IVShape shape)
{
DataObject dataObj = new DataObject(shape);
foreach (string clipFormat in dataObj.GetFormats(false))
{
if (clipFormat.Contains("Shapes"))
{
MemoryStream stream = (MemoryStream)dataObj.GetData(clipFormat);
_clipFormat = clipFormat;
_shapeData = Convert.ToBase64String(stream.ToArray());
}
}
}
void DropSavedShape(IVPage page)
{
MemoryStream stream = new MemoryStream(Convert.FromBase64String(_shapeData));
DataObject obj = new DataObject(_clipFormat, stream);
page.Drop(obj, 0, 0);
}</pre>
<p>Hope this is helpful.</p> Nikolay Belyhhttp://www.blogger.com/profile/08269355782648556627noreply@blogger.com1tag:blogger.com,1999:blog-8239631510751597086.post-20682604044546575492009-08-28T23:45:00.002+07:002012-04-17T12:10:46.925+07:00Making the Visio ribbon tab document-dependent<p> This post explains how to make a ribbon tab in Visio 2010 ribbon document-specific. Means, activate a custom ribbon tab only for a specific document.</p> <p><a href="http://nbelyh.googlepages.com/VisioRibbonTestCS2.zip">Download C# sample project (VS2008)</a> </p> <p><a href="http://nbelyh.googlepages.com/VisioRibbonTestCPP2.zip">Download C++/ATL sample project (VS2008)</a></p> <p>This article discusses the implementation of a document-specific tab in a COM add-in; also, it focuses on nasty details you might be interested in if you e.g. program unmanaged C++. Note that you could do this thing by other means, e.g. by embedding your custom interface in a document template using new Visio 2010 property Document.CustomUI. </p> <p>Nevertheless, one of the ways to it is:</p> <ol> <li>Create a Visio add-in that supports ribbon (as described in <a href="http://unmanagedvisio.blogspot.com/2009/08/getting-started-with-visio-ribbon.html">previous post</a>) </li> <li>Add onLoad event to the ribbon XML. This will allow you to obtain the ribbon manager. <pre class="brush: xml; gutter: false;"><customUI onLoad="OnLoad" ...></pre>
</li>
<li>In the event handler for the onLoad event, save passed-in ribbon manager. This is needed to force update of the ribbon.
<pre class="brush: csharp; gutter: false;"> // this function provides us with IRibbonUI object, called when XML is loaded
public void OnLoad(object obj)
{
vsoRibbonUI = (Office.IRibbonUI) obj;
}
</pre>
<a name='more'></a>
</li>
<li>For the custom tab, add visibility callback function. This callback is called when Visio </li>
<li>decides if the tab shall be shown or not. In the XML this looks like:
<pre class="brush: xml; gutter: false;"><tab id="Tab1" label="MyAddin" getVisible="IsMyTabVisible"></pre>
</li>
<li>Create a callback handler that returns if the tab shall be shown or not. In my case (for simplicity), I just check if the active document has a user-defined cell "User.IsMyDoc"
<pre class="brush: csharp; gutter: false;">// callback for the tab visibility, return if our tab shall be visible
public bool IsMyTabVisible(object control)
{
Visio.Document activeDoc = vsoApplication.ActiveDocument;
bool show =
(activeDoc != null)
&& activeDoc.DocumentSheet.get_CellExists("User.IsMyDoc", 0) != 0;
return show;
}</pre>
</li>
<li>Add handlers to all events that might cause tab to show/hide. For a our document-dependent tab, these are "DocumentAdded", "DocumentOpened", "DocumentClosed", and “Window activated” (in case you want to show/hide your tab when user switches to another window). From each of these handlers, just trigger the refresh for the ribbon:
<pre class="brush: csharp; gutter: false;">void vsoApplication_DocumentCreated(Microsoft.Office.Interop.Visio.Document doc)
{
vsoRibbonUI.Invalidate();
}</pre>
</li>
</ol>
<p>That's basically it; now, when a document that contains a cell named "User.IsMyDoc" is activated the tab is shown; otherwise this tab is hidden.</p> Nikolay Belyhhttp://www.blogger.com/profile/08269355782648556627noreply@blogger.com0tag:blogger.com,1999:blog-8239631510751597086.post-21578100704529496022009-08-22T19:10:00.001+07:002012-04-17T12:12:06.720+07:00Getting started with Visio Ribbon<p>This post explains how one can customize Visio 2010 Ribbon from Visio add-in (and is based on Visio CTP). Namely, it shows how to add a custom tab to the Visio ribbon.</p> <p><a href="http://nbelyh.googlepages.com/VisioRibbonTestCS1.zip">Download C# sample project (VS 2008 solution, 12 Kb)</a> </p> <p><a href="http://nbelyh.googlepages.com/VisioRibbonTestCPP1.zip">Download C++/ATL sample project (VS 2008 solution, 19 Kb)</a></p> <p>Though Visio has been resistant to innovations in user interface for quite a long time (just remember those 16-color icons in the stencils), it seems that finally "the time has come", and the ribbon interface has won the game. I started this project to estimate the amount of work one needs to adopt his add-in to the new Ribbon interface. I should mention that old CommandBars API that was normally used for user interface customization does still work for new Visio 2010; the point is that it just looks a bit unnatural, and kind of unnatural. </p> <p>The way it looked in Visio 2007, native toolbar and menu: <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_rkiUns3tLpE/So-s4HOydNI/AAAAAAAADFA/jyMldGu9Uwo/image%5B34%5D.png?imgmax=800" width="275" height="78" /> </p> <p>If you won’t do a thing, then in Visio 2010 you’ll get something like: <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_rkiUns3tLpE/So-s4acmzAI/AAAAAAAADFE/Ky6igxrMsGw/image%5B33%5D.png?imgmax=800" width="632" height="125" /> If you ask me, this doesn’t look like an exciting user experience… No transparency, no fancy 32-bit images, all custom toolbars (from all add-ins) are put to the “Custom Toolbars” group, all custom menus (from all add-ins) are put into “Menu Commands”, etc, etc… Wouldn’t it be much better if we make it look like that? <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_rkiUns3tLpE/So-s4_YI-HI/AAAAAAAADFI/sjVcj889rmQ/image%5B32%5D.png?imgmax=800" width="645" height="124" /> Here is list of materials about Office ribbon customization (though these are 2 years old and were written for Word 2007 and alike, now they became valid for Visio as well): </p> <a name='more'></a> <p><a href="http://msdn.microsoft.com/en-us/library/aa338202.aspx">Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)</a> </p> <p><a href="http://msdn.microsoft.com/en-us/library/aa338199.aspx">Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)</a> </p> <p><a href="http://msdn.microsoft.com/en-us/library/aa722523.aspx">Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)</a> </p> <p><a href="http://blogs.msdn.com/jensenh/archive/2006/12/08/using-ribbonx-with-c-and-atl.aspx">Using RibbonX with C++ and ATL</a> </p> <p>So, I started from here, and adopted the code from the last article for Visio (both C# and C++/ATL variants). The basic idea is that to allow custom Ribbon, you just need to implement the IRibbonExtensibility interface in your add-in. Like that:</p> <pre class="brush: csharp; gutter: false;">public class Connect
: Object
, IDTExtensibility2
, Office.IRibbonExtensibility // <-- add this for ribbon
{
// Here you shall return the XML description of the custom ribbon part
public string GetCustomUI(string RibbonID)
{
return Resource.RibbonXML;
}
// this is called (by name) when ribbon button is cliecked
public void ButtonClicked(Office.IRibbonControl pButton)
{
System.Windows.Forms.MessageBox.Show(string.Format(
@"Hello from the ribbon, the button ""{0}"" clicked!"
, pButton.Id));
}</pre>
<p>The tricky part here is the XML you return. Hopefully Microsoft will release some tools for Visio ribbon with the next release of the Microsoft Tools for Office (or Visio SDK?), but for now there is nothing about Visio Ribbon. So you have to “master” XML by yourself. But since Ribbon is supported for other office applications, I just opted to create a project of type "<b>Excel 2007 Add-In</b>" (Microsoft Tools for Office template, but for <b>Excel</b>), used “Add New Item” to add a new item of type “Ribbon (Visual Designer)”. In such a way I was able to edit my ribbon using visual designer and then use the designer-generated XML file with Visio add-in. Again, hopefully this will “change to normal” when Microsoft issues updated version of Tools for Office, but unfortunately I believe that for unmanaged code there is no hope of Visual ribbon designer, so this “technique” might be still useful as a “last resort” who dares to write unmanaged code nowadays... So, this is how the ribbon the looks in ribbon designer: <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_rkiUns3tLpE/So-s5bTJd6I/AAAAAAAADFM/ixs6M_JpXTs/image%5B31%5D.png?imgmax=800" width="451" height="297" /> From the designer, one can generate the XML using “Export Ribbon to XML” command: <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_rkiUns3tLpE/So-s5yyaQWI/AAAAAAAADFQ/Gx0CqoLHJ9A/image%5B40%5D.png?imgmax=800" width="331" height="194" /> This produces the XML that can be returned from the “GetCustomUI” method. In my project, I just opted to include generated XML file as a resource. </p>
<pre class="brush: xml; gutter: false;"><customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<ribbon>
<tabs>
<tab id="Tab1" label="MyAddin">
<group id="Group1" label="My Addin Commands">
<button id="HappyFaceButton" imageMso="HappyFace"
onAction="ButtonClicked" label="Click Me!" size="large" />
</group>
</tab>
</tabs>
</ribbon>
</customUI></pre>
<p>As for the unmanaged code, the things might become just a bit more tricky. One clog is implementing 2 interfaces, both inheriting from the IDispatch (one is a callback interface, used for responding to events, and the second is that IRibbonExtensibility). Fortunately enough these points are discussed in details in the article “Using RibbonX with ATL”.</p>
<p>In the future, I hope to post some article about updating user interface dynamically with Ribbon (enabling/disabling buttons or menu items dynamically at runtime) add using custom images with Visio ribbon (this might be a bit tricky).</p> Nikolay Belyhhttp://www.blogger.com/profile/08269355782648556627noreply@blogger.com1tag:blogger.com,1999:blog-8239631510751597086.post-76753945327269765082009-08-16T20:54:00.004+07:002012-04-17T12:15:53.790+07:00Hello world<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="1" border="0" alt="1" align="left" src="http://lh4.ggpht.com/_rkiUns3tLpE/Spgo_e42kNI/AAAAAAAADFU/xMYwyUsJih4/1%5B7%5D.png?imgmax=800" width="111" height="119" /> Basically I started this blog to share some information and examples that might be useful for those who create application for the Microsoft Office in general and Microsoft Visio in particular (add-ins and alike). </p> <p>I deal with the Microsoft Visio for quite some time already (and basically in the unmanaged code), and I feel like I can share some things that Visio community might find useful. So this blog can be considered as a "Visio developer's side notes".</p> <p>Additionally, to make it not that boring, I decided to draw a picture for every post :) <br />Hoping all this is a good idea, Nikolay Belyh</p> Nikolay Belyhhttp://www.blogger.com/profile/08269355782648556627noreply@blogger.com0