Convert From C# to C++/CLI
Managed C++/CLI
1
Posts
1
Posters
12
Views
1
Watching
-
Hi, I try to convert from C# to C++/Cli. I have a small application in C#. When I try to print the RDLC report directly to printer, I found a c# online-codes.
public static void Print(this LocalReport report, PageSettings pageSettings) { string deviceInfo = $@" EMF {pageSettings.PaperSize.Width \* 100}in {pageSettings.PaperSize.Height \* 100}in {pageSettings.Margins.Top \* 100}in {pageSettings.Margins.Left \* 100}in {pageSettings.Margins.Right \* 100}in {pageSettings.Margins.Bottom \* 100}in "; Warning\[\] warnings; var streams = new List(); var pageIndex = 0; report.Render("Image", deviceInfo, (name, fileNameExtension, encoding, mimeType, willSeek) => { MemoryStream stream = new MemoryStream(); streams.Add(stream); return stream; }, out warnings); foreach (Stream stream in streams) stream.Position = 0; if (streams == null || streams.Count == 0) throw new Exception("No stream to print."); using (PrintDocument printDocument = new PrintDocument()) { printDocument.DefaultPageSettings = pageSettings; if (!printDocument.PrinterSettings.IsValid) throw new Exception("Can't find the default printer."); else { printDocument.PrintPage += (sender, e) => { Metafile pageImage = new Metafile(streams\[pageIndex\]); Rectangle adjustedRect = new Rectangle(e.PageBounds.Left - (int)e.PageSettings.HardMarginX, e.PageBounds.Top - (int)e.PageSettings.HardMarginY, e.PageBounds.Width, e.PageBounds.Height); e.Graphics.FillRectangle(Brushes.White, adjustedRect); e.Graphics.DrawImage(pageImage, adjustedRect); pageIndex++; e.HasMorePages = (pageIndex < streams.Count); e.Graphics