Avatar of Cyril Joudieh
Cyril Joudieh
Flag for Lebanon asked on

VFP Automation on MS-Graph


I am automating the preview of MS-Graph in VFP forms and their exports into Excel and PowerPoint.

There are way too many options on the software now to customize the charts (color, font, style, shadow, gradient, ...) and each time I change a property in the graph it has to refresh. So previewing a handful of columns is taking like 5-10 seconds to refresh. If I use other plotters it is done instantaneously.

I read on MSDN and other places that there is a Repaint Property:

However, it seems only to be available in .Net.

I also tried to hide the chart  (oChart.Visible = False) and to lock the VFP form from refreshing (LockScreen = .T.) and it improved the performance a bit.

Does anyone know how to handle this? I need to stop MS-Graph from refreshing when I assign all the properties I need.

FoxProMicrosoft OfficeVisual Basic.NET

Avatar of undefined
Last Comment
Cyril Joudieh

8/22/2022 - Mon
Olaf Doschke

As ActiveX are always seperate forms with their own hwnd, VFPs native Lockscreen property doesn't help much, even if you do that on the _screen level. Try Win API LockWindowUpdate with the hwnd of the control.

Bye, Olaf.
Cyril Joudieh

That did not work. Same effect as LockScreen = .T.
Olaf Doschke

Makes me wonder, LockWindowUpdate even works on all running processes. It just has the downside only one hwnd at a time can be locked, but that window then is locked. How did you implement LockWindowUpdate?

Bye, Olaf.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Cyril Joudieh

The LockWindowUpdate did prevent the MSGraph from refreshing visibly but it took the same amount of time as without it. The same with LockScreen, Visible = .F. and other methods I tried.

The software does the following:
1) Change Data
2) Change Chart Type
3) Change and Format Title, Subtitle, Axes, ...
4) Change Colors
5) Apply additional options: Averages, Min, Max, Quartiles, ...
6) Apply DataLabels and Colors them
7) Apply Effects: Gradient, Shadow, 3D Effects

With each property change (ex. Font.Size = 10) the graph refreshes which means it redraws itself. There is Refresh and Update in MS-Graph. I could not find the option to prevent it from auto-refresh. The only method is to use Visual Studio .Net and MyChart.Repaint = False.

I wrote my own plotters using VFP objects. It takes a few milliseconds for my charts to draw and in some charts it takes 10 seconds of MS-Graph to draw. The client wishes to have editable charts in PowerPoint. So to export a study in 200 slides takes a considerable amount of time.
Olaf Doschke

Okay, I see. Then this is nothing you can solve via Lockscreen or LockWindoUpdate. But how about making all layout changes, while not having the full dataset in ms graph? Eg "zap" data or leave it to a minimum of data, which is drawn fast and only in the last step, if the graph layout is as wanted, add the data. That's the best I can think of, if you want to avoid the .Net involvement.

I don't have ms graph here, or I'm too stupid to find it, so I can't help you finding out how or why .Net offers an option you don't have in the OLE object.

Bye, Olaf.
Cyril Joudieh

I think the .net has a special way to communicate with the hidden parameters of MS-Graph.

Lockscreen and LockWindowUpdate just prevent the flickering. They hardly improve the performance.

The problem is that I am updating individual points in the series and I need to have the data there beforehand. There are special items in the chart that need the user's attention so they are colored or formatted differently. Plus I use special options to show average, quartiles, mins, maxs that MS-Graph does not show.

I made the chart now twice as fast by removing the formatting of the data labels in preview mode but I have to enable it when exporting to PowerPoint.
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Cyril Joudieh

View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Cyril Joudieh

The solutions posted on the internet do not work in FoxPro. They work in Excel or .Net. This is the only solution I could find after trying for months.