private void AddImageFromControl(Control ctrl) { try { ctrl.Refresh(); System.Threading.Thread.Sleep(100); Bitmap bmp = CScreenCopieur.GetWindowImage(ctrl); CHelpExtender.FaireClignoterControl(m_help.Controle); string strFichier = "C:\\TMP.BMP"; bmp.Save(strFichier); CResultAErreur result = CHelpData.SourceAide.ReferenceFichier(strFichier, m_help); if (!result) { CFormAlerte.Afficher(result.Erreur.ToString(), EFormAlerteType.Erreur); return; } CRessourceFichier ressource = (CRessourceFichier)result.Data; m_listeRessourcesFichier.Add(ressource); string strImage = "<img src='File://" + ressource.NomFichierLocal + "'/>"; m_htmlEditor.InsertHtml(strImage); } catch { CFormAlerte.Afficher(I.T("Error while adding an image|30016"), EFormAlerteType.Erreur); } }
public static void PrintWindow(Control control) { control.Refresh(); System.Threading.Thread.Sleep(100); Bitmap bmp = CScreenCopieur.GetWindowImage(control); PrintDialog dlg = new PrintDialog(); dlg.PrinterSettings = new PrinterSettings(); if (dlg.ShowDialog() == DialogResult.OK) { PrintDocument document = new PrintDocument(); document.PrinterSettings = dlg.PrinterSettings; CScreenPrinter printer = new CScreenPrinter(); printer.m_bitmapToPrint = bmp; document.PrintPage += new PrintPageEventHandler(printer.document_PrintPage); document.Print(); } }