Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Printing a graph from a FormView (SOS)

I'm having problems with printing a CWgraph which is positioned on FormView. (C++)
I tried using the attatched code but it only prints when the graph is positioned on a dialog.

What's the diffrence?
0 Kudos
Message 1 of 5
(3,250 Views)
Why aren't you using our native Visual C++ tools? It would be a lot easier for you to integrate with SDI and MDI applications.

Anyway, with that said, I had no problem printing a CWGraph object on a FormView with the same code you send. What I suspect may be the problem is that you are trying to do the printing in a class other than the Form class. You may be trying to do the printing from the CMainFrame class. That would not work, since the CMainFrame does not have a m_CWGraph member. You have to do the printing in the Form class and you have to declare a member variable (m_CWGraph) for the CWGraph object. Other than that, I don't have any guesses why it wouldn't work for you.

Best Regards,

Chris Matthews
National Instruments
Message 2 of 5
(3,250 Views)
Hi again,

First, I'd like to thank you for the response,but...
I still can't see the problem.
I attached my function code ( CGraphView ) is the FormView class.

Thanks
0 Kudos
Message 3 of 5
(3,250 Views)
I forgot to mention that the output of this function is
a printed page with only the graph caption on it, that's it! the graphics itself is not printed

thanks again
0 Kudos
Message 4 of 5
(3,250 Views)
Ahhh, just a simple C mistake. You have an error in one of your lines with the operator orders. You have the line:

double cInchesTall = cInchesWide * rcGraph.Height() * 60 / rcGraph.Width() * 60;

in your program. This line calculates how tall (in inches) the printout should be based on a fixed width of 6 inches. In our examples the * 60 is not there and that is what is causing your problem. I'm not sure why you have * 60 on your rc width and height, but that is causing the problem. You DON't have parentheses. Therefore your graph height is coming out 3600 times larger than it should. 🐵 That's going to be one HUGE graph. You printer is running out of memory and therefore, you don't get the printout. Change that l
ine to:

double cInchesTall = cInchesWide * (rcGraph.Height() * 60) / (rcGraph.Width() * 60);

or

double cInchesTall = cInchesWide * rcGraph.Height() / rcGraph.Width();

Either one should fix your problem. At least it did for me with your code.

Best Regards,

Chris Matthews
National Instruments
0 Kudos
Message 5 of 5
(3,250 Views)