473,322 Members | 1,421 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,322 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 2354
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
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.