Visio Addon code to refresh/redraw a diagram during execution

Started by caolen, May 12, 2020, 08:00:47 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


I have created a Visio Addon in C++ that pulls data, changes shape sizes, colors and positions and then iterates.  At the end of each iteration I want the diagram to refresh and redraw itself to show all the changes.  But, the diagram does not refresh until the last iteration is complete and the Addon finishes.

How do I force a diagram refresh/redraw from within my Visio Addon code, at the end of each iteration?



you probably don't want to redraw after everyshape
- takes a long time if lots of shapes

probably want to redraw for every 10 shapes or so.

I don't know much how visio interacts with C++...curious why C++ vs a VBA macro?

So thoughts
- you may want to pause during shape updates...may signal to visio to redraw
- I would think there is a call to update screen (I know VBA has that for excel so that you can control screen updates).
- I doubt live dynamics setting on the shape shapesheet would do this (if so, might be slow)

By the way, if you get this licked, you probably have a foundation for visio animation ;-)




Amazing. Someone is still writing Visio Addons in C++  ;D

Unless you explicitly disabled redraw during the diagram generation, Visio should redraw all by itself.
If it's not happening then there must be a bug/issue somewhere, hard to tell without seeing the code.

If you did disable redraw, you need to re-enable it after you are done...
There are two Visio application object properties related to this:

BTW, in Soviet Russia in C++, the magical "DoEvents" thing looks like this:

void DoEvents()
  MSG msg;


Vojo, Yacine, Nikolay, thanks for your replies.  -and for your gentle patience with me using "ancient Sanskrit" (C++) for writing my Visio Addon!   :)

Can you please tell me more about "doevents?"  I checked the visio.application.getShowChanges(&vbool).  It was turned "on" and is working fine.

I can get my diagram to redraw /refresh at the end of each iteration by inserting a MessageBox command.  But then, my user has to click the "OK" box each time to resume the next iteration.  What can I use to automatically create and dismiss this "MessageBox" event?  I really just want the user to start the Addon, sit back and watch the show, briefly pausing to view each iteration.

cbstrTemp = _T("Iteration: ");

app.putShowChanges(true);   // This was already "on."  I didn't really need to put it.
VARIANT_BOOL vboolShowChanges;
if (vboolShowChanges) {
   MessageBox(GetActiveWindow(), _T("app.getShowChanges returns TRUE."), cbstrTemp, MB_OK);


You could try inserting that "DoEvents" function from my previous post in place of the MessageBox and Sleep.


Nikolay,  I tried inserting the DoEvents(); call instead of the MsgBox & Sleep.  But, it didn't work.  Only the last iteration was refreshed/redrawn.

if (vboolShowChanges) {
   // MessageBox(GetActiveWindow(), _T("app.getShowChanges returns TRUE."), cbstrTemp, MB_OK);
   // Sleep(500);

What else can I try?


Okay the magic didn't work then...  :)
I'm not sure - could you maybe share something that can be used to reproduce the issue?