W
WoodBeeProgrammer
aargh! what's wrong with the following snippet? i'm trying to use
PrintWindow with a RichTextBox.
[DllImport ("User32.dll")]
public extern static bool PrintWindow (System.IntPtr hWnd, System.IntPtr dc,
uint reservedFlag);
System.IntPtr hwnd = rtf.Handle;
Bitmap bm = new Bitmap (rtf.Size.Width, rtf.Size.Height);
if (bm != null)
{
using (Graphics g = Graphics.FromImage (bm))
{
if (g == null) return null;
System.IntPtr bmDC = g.GetHdc ();
bool ok = PrintWindow (hwnd, bmDC, 0); // RETURNS FALSE-- WHY?????
g.ReleaseHdc (bmDC);
}
}
return bm;
PrintWindow with a RichTextBox.
[DllImport ("User32.dll")]
public extern static bool PrintWindow (System.IntPtr hWnd, System.IntPtr dc,
uint reservedFlag);
System.IntPtr hwnd = rtf.Handle;
Bitmap bm = new Bitmap (rtf.Size.Width, rtf.Size.Height);
if (bm != null)
{
using (Graphics g = Graphics.FromImage (bm))
{
if (g == null) return null;
System.IntPtr bmDC = g.GetHdc ();
bool ok = PrintWindow (hwnd, bmDC, 0); // RETURNS FALSE-- WHY?????
g.ReleaseHdc (bmDC);
}
}
return bm;