473,395 Members | 2,468 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

RichTextBox PrintWindow -- let's get real

How come everybody on this newsgroup answers easy questions but not hard
questions?

Does PrintWindow work with RichTextBox? If not, WHY NOT? And if not,
what's the workaround?

TIA
[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;
Nov 15 '05 #1
2 2357
class Test {
delegate bool CallBack(int hWnd, int lParam);
[DllImport("user32.dll")]
static extern int EnumWindows(CallBack hWnd, int lParam);
static bool PrintWindow(int hWnd, int lParam) {
Console.WriteLine(hWnd);
return true;
}
static void Main() {
CallBack e = new CallBack(PrintWindow);
EnumWindows(e, 0);
}
}

--
Rami Saad
Microsoft GTSC Developer support for Middle East
"WoodBeeProgrammer" <Wo***************@spamex.com> wrote in message
news:10***************@utility.isomedia.com...
How come everybody on this newsgroup answers easy questions but not hard
questions?

Does PrintWindow work with RichTextBox? If not, WHY NOT? And if not,
what's the workaround?

TIA
[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;

Nov 15 '05 #2
Rami, thanks for answering this post, i don't understand what i should do
with the class Test. I'm trying to use the PrintWindow function defined in
User32.dll to render the contents of a RichTextBox offscreen.

"Rami Saad" <ra*******@egdsc.microsoft.com> wrote in message
news:O7**************@TK2MSFTNGP11.phx.gbl...
class Test {
delegate bool CallBack(int hWnd, int lParam);
[DllImport("user32.dll")]
static extern int EnumWindows(CallBack hWnd, int lParam);
static bool PrintWindow(int hWnd, int lParam) {
Console.WriteLine(hWnd);
return true;
}
static void Main() {
CallBack e = new CallBack(PrintWindow);
EnumWindows(e, 0);
}
}

--
Rami Saad
Microsoft GTSC Developer support for Middle East
"WoodBeeProgrammer" <Wo***************@spamex.com> wrote in message
news:10***************@utility.isomedia.com...
How come everybody on this newsgroup answers easy questions but not hard
questions?

Does PrintWindow work with RichTextBox? If not, WHY NOT? And if not,
what's the workaround?

TIA
[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;


Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: OysterCracker | last post by:
Hi - I've used the <a href="javascript:printWindow()"><Print></a> function for printing a webpage, but I ran into an interesting variation recently, and would appreciate some help duplicating it....
0
by: WoodBeeProgrammer | last post by:
How come everybody on this newsgroup answers easy questions but not hard questions? Does PrintWindow work with RichTextBox? If not, WHY NOT? And if not, what's the workaround? TIA
10
by: D Steward | last post by:
I can't seem to add a newline (/n) to get a richtextbox control to display text on successive lines. The text that I type is overwritten. How do I remedy this My example richTextBox->Multiline...
0
by: Berry W | last post by:
Some articles say that PrintWindow can be used to take a capture of the hidden window and save the content. How should PrintWindow used? Any sample code around how to use it? Thanks to you all!
9
by: James Wong | last post by:
Hi, I use the RichTextBox in my program. It will use different language in this RichTextBox (chinese and english characters), and it set the "DualFont" and use different fonts. By the way, how...
3
by: michael sorens | last post by:
The documentation for the RichTextBox is sketchy at best. I want to do a very simple task but I cannot find information on this. I am using a RichTextBox as an output window. Some text I want to...
4
by: Technical | last post by:
Greetings, I am currently working on a project that requires that the contents of a RichTextBox control be drawn to a bitmap. I have attempted nearly everything including using calls into the...
8
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post by:
I have created a Control that extends RichTextBox to do syntax-hilighting. My strategy is to have a timer that restarts every time a user types a key so that it can wait until the user pauses for...
0
by: Linda Liu[MSFT] | last post by:
Hi CES, Thank you for posting here! I notice that you post a same issue in the microsoft.public.dotnet.framework.windowsforms.controls newsgroup and I have replied to that thread. For your...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.