MSChart image printing VC program processing:
In VC, implementation of printing is much difficult than in VB, in such a question, VB's solution is simple:
VB solution:
Principle: mschart.editcopy (copy control display image)
Printer.print Mschart.OpenClipboard (Interpretation of VB Statement) (Print Clipboard Content)
But in VC, printing is not an easy task, I put the source code for the MSChart control of the MSChart control in netizens, and give it to everyone,
Implementation,
HPALETTE HPALETTE; M_MSCHART.GETPLOT (). GetBackDrop () .Getfill (). Getbrush (). GetFillColor (). Set (255, 255, 255); m_mschart.getplot (). GetBackDrop (). GetShadow () .SetStyle (false); // Shadow
m_mschart.EditCopy (); if (OpenClipboard ()) // m_mschart {hDib = GetClipboardData (CF_DIB); hPalette = (HPALETTE) GetClipboardData (CF_PALETTE); CloseClipboard ();}. else return;. m_mschart.GetPlot () GetBackdrop ( . Getfill (). GetFillColor (). Set (192, 192, 192); m_mschart.get (). GetBackDrop (). Getshadow (). SetStyle (TRUE); // Shadow
CPrintDialog mypd (false); // Construct Print Settings dialog object Mypd.getDefaults (); // Check the device environment of default printing device DEVMODE * DM = mypd.getDevmode (); // Extract DevMode data from the default printer DM-> DMorientation = 2; // DM-> DMPRINTQUALITY = 1200; printdlg pd; {pd.lstructSize = sizeof (printdlg); pd.flags = pd_returndc; pd.hdc = null; pd.hwndowner = null; pd.hinstance = NULL; pd.nmaxpage = 256; pd.nminPage = 1; pd.nfromPage = 1; pd.NTOPAGE = 256; pd.ncopies = 1; pd.hdevmode = DM; pd.hdevnames = null;} if (! (& PD)) {RETURN;} assert (pd.hdc! = null); CDC PDC; PDC.Attach (PD.HDC); int nhorres = getDeviceCaps (pd.hdc, horzres); // Return to the physical display width of the device MM INT NVERRES = getDeviceCaps (PD.HDC, Vertres); // Returns the physical display height of the device MM if (pd.hdc! = null) {docinfo di; di.cbsize = sizeof (docinfo); di.lpszdocname = Like printing; di.lpszoutput = (lptstr) null; di.lpszdattype = (lptstr) NULL; di.fwtype = 0; pdc.startdoc (& di); file: // Notify the printer driver to perform a new print task PDC .StartPage (); file: // Notify the printer driver Print the new page setmapmode (pd.hdc, mm_text); // Set the current image mode: unit 0.001 inch CRECT Rectp RINT (0, 0, Nhorres, NVERRES); File: // Print Graphic BitmapInfo * PBI = (BitmapInfo *) Globalock (HDIB); if (PBI! = null) {BYTE * DATA = (Byte *) (PBI-> Bmicolors); if (pbi-> bmiheader.bibitcount <= 8) {int ncolor = pbi-> bmiheader.biHRUSED? PBI-> bmiheader.biclrused: (1 << pbi-> bmiheader.biBitcount); data = Sizeof Rgbquad) * ncolor;}} (hpalette! = Null) SelectPalette (pd.hdc, hpalette, true); StretchDibits (pd.hdc, rectprint.Width (), RectPrint.Height (), 0, 0, PBI-> bmiheader.biwidth, PBI->