473,324 Members | 2,417 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,324 software developers and data experts.

Saving a panel to a Graphics (Printing)

Dear All,

I need to save the content of a panel to a bitmap. The panel can have
many child controls which also need to be saved. The problem would be
solved if I could have the panel saved to a Graphics object, which is
the same as if I'd need to print it. It'd be easy using
Control.DrawToBitmap, but I also need the invisible part of the panel
(which is hidden because of scrolling) and DrawToBitmap just takes a
screenshot.

I've been reading about this. Many samples uses BitBlt, but that also
skips the invisible part. I've also seen some posts stating that this
is not a simple thing and I'd need to programatically scroll to all
needed position and combine the screenshots taken from all the scroll-
positions. These posts were from 2003 or 2004.

So my question: Is there any new solutions provided by VS2005? Or do I
have to do this multiple scrolling (which produces flickering)?

Thank you for any help!

Chris

Jun 9 '07 #1
9 4248

"she_prog" <pu*********@yahoo.comwrote in message
news:11**********************@m36g2000hse.googlegr oups.com...
Dear All,

I need to save the content of a panel to a bitmap. The panel can have
many child controls which also need to be saved. The problem would be
solved if I could have the panel saved to a Graphics object, which is
the same as if I'd need to print it. It'd be easy using
Control.DrawToBitmap, but I also need the invisible part of the panel
(which is hidden because of scrolling) and DrawToBitmap just takes a
screenshot.

I've been reading about this. Many samples uses BitBlt, but that also
skips the invisible part. I've also seen some posts stating that this
is not a simple thing and I'd need to programatically scroll to all
needed position and combine the screenshots taken from all the scroll-
positions. These posts were from 2003 or 2004.

So my question: Is there any new solutions provided by VS2005? Or do I
No, there aren't. However, Windows has always had a solution for this:
WM_PRINT.

Try creating a bitmap of the appropriate size, getting a Graphics for it,
get the HDC, and SendMessage WM_PRINT to the window and each of its
children. That will usually get you the results you are looking for.
have to do this multiple scrolling (which produces flickering)?

Thank you for any help!

Chris
Jun 9 '07 #2
Thank you very much, Ben!
I tried your solution, but it didn't work for me. Maybe the problem is
that I'm trying to save a class of my own, derived from Panel and
OnPaint method is overriden in this new class. When trying to debug,
OnPaint is not called as a result of SendMessage. Here's my code:

[DllImport("user32.dll")]
public static extern int SendMessage(
IntPtr hWnd, // handle to destination window
int Msg, // message
int wParam, // first message parameter
int lParam // second message parameter
);

const int WM_PRINT = 0x317;

[Flags]
enum DrawingOptions
{
PRF_CHECKVISIBLE = 0x01,
PRF_NONCLIENT = 0x02,
PRF_CLIENT = 0x04,
PRF_ERASEBKGND = 0x08,
PRF_CHILDREN = 0x10,
PRF_OWNED = 0x20
}

....
Bitmap l_bmp = new Bitmap(c_panel.Width, c_panel.Height);
Graphics l_grp = Graphics.FromImage(l_bmp);
IntPtr hdc = l_grp.GetHdc();
SendMessage(c_panel.Handle, WM_PRINT, (int)hdc,
(int)DrawingOptions.PRF_OWNED);

Could you please advice further?
Regards,
Chris

Ben Voigt [C++ MVP] írta:
"she_prog" <pu*********@yahoo.comwrote in message
news:11**********************@m36g2000hse.googlegr oups.com...
Dear All,

I need to save the content of a panel to a bitmap. The panel can have
many child controls which also need to be saved. The problem would be
solved if I could have the panel saved to a Graphics object, which is
the same as if I'd need to print it. It'd be easy using
Control.DrawToBitmap, but I also need the invisible part of the panel
(which is hidden because of scrolling) and DrawToBitmap just takes a
screenshot.

I've been reading about this. Many samples uses BitBlt, but that also
skips the invisible part. I've also seen some posts stating that this
is not a simple thing and I'd need to programatically scroll to all
needed position and combine the screenshots taken from all the scroll-
positions. These posts were from 2003 or 2004.

So my question: Is there any new solutions provided by VS2005? Or do I
No, there aren't. However, Windows has always had a solution for this:
WM_PRINT.

Try creating a bitmap of the appropriate size, getting a Graphics for it,
get the HDC, and SendMessage WM_PRINT to the window and each of its
children. That will usually get you the results you are looking for.
have to do this multiple scrolling (which produces flickering)?

Thank you for any help!

Chris
Jun 9 '07 #3
You should also use the CLIENT and CHILDREN flags (OR-ed together), to get
the content of the window and all contained windows.
"she_prog" <pu*********@yahoo.comwrote in message
news:11**********************@c77g2000hse.googlegr oups.com...
Thank you very much, Ben!
I tried your solution, but it didn't work for me. Maybe the problem is
that I'm trying to save a class of my own, derived from Panel and
OnPaint method is overriden in this new class. When trying to debug,
OnPaint is not called as a result of SendMessage. Here's my code:

[DllImport("user32.dll")]
public static extern int SendMessage(
IntPtr hWnd, // handle to destination window
int Msg, // message
int wParam, // first message parameter
int lParam // second message parameter
);

const int WM_PRINT = 0x317;

[Flags]
enum DrawingOptions
{
PRF_CHECKVISIBLE = 0x01,
PRF_NONCLIENT = 0x02,
PRF_CLIENT = 0x04,
PRF_ERASEBKGND = 0x08,
PRF_CHILDREN = 0x10,
PRF_OWNED = 0x20
}

....
Bitmap l_bmp = new Bitmap(c_panel.Width, c_panel.Height);
Graphics l_grp = Graphics.FromImage(l_bmp);
IntPtr hdc = l_grp.GetHdc();
SendMessage(c_panel.Handle, WM_PRINT, (int)hdc,
(int)DrawingOptions.PRF_OWNED);

Could you please advice further?
Regards,
Chris

Ben Voigt [C++ MVP] írta:
"she_prog" <pu*********@yahoo.comwrote in message
news:11**********************@m36g2000hse.googlegr oups.com...
Dear All,

I need to save the content of a panel to a bitmap. The panel can have
many child controls which also need to be saved. The problem would be
solved if I could have the panel saved to a Graphics object, which is
the same as if I'd need to print it. It'd be easy using
Control.DrawToBitmap, but I also need the invisible part of the panel
(which is hidden because of scrolling) and DrawToBitmap just takes a
screenshot.

I've been reading about this. Many samples uses BitBlt, but that also
skips the invisible part. I've also seen some posts stating that this
is not a simple thing and I'd need to programatically scroll to all
needed position and combine the screenshots taken from all the scroll-
positions. These posts were from 2003 or 2004.

So my question: Is there any new solutions provided by VS2005? Or do I
No, there aren't. However, Windows has always had a solution for this:
WM_PRINT.

Try creating a bitmap of the appropriate size, getting a Graphics for it,
get the HDC, and SendMessage WM_PRINT to the window and each of its
children. That will usually get you the results you are looking for.
have to do this multiple scrolling (which produces flickering)?

Thank you for any help!

Chris
Jun 9 '07 #4
Great, now I can see stepping through OnPaint when debugging. Still,
the resulted Bitmap is all blank :(
Right after SendMessage I'm calling l_bmp.Save(filename); so there's
no code overdrawing the result of SendMessage. The same OnPaint draws
the panel and its children just fine onto the screen.
Right now I'm just testing without scrollbars, so that shouldn't cause
the problem. I might try to do a small sample application to try to
narrow down the cause.

Thank you very much for the help! If you could think of anything that
could cause the problem, please let me know!
Regards,
Chris

Ben Voigt [C++ MVP] írta:
You should also use the CLIENT and CHILDREN flags (OR-ed together), to get
the content of the window and all contained windows.
"she_prog" <pu*********@yahoo.comwrote in message
news:11**********************@c77g2000hse.googlegr oups.com...
Thank you very much, Ben!
I tried your solution, but it didn't work for me. Maybe the problem is
that I'm trying to save a class of my own, derived from Panel and
OnPaint method is overriden in this new class. When trying to debug,
OnPaint is not called as a result of SendMessage. Here's my code:

[DllImport("user32.dll")]
public static extern int SendMessage(
IntPtr hWnd, // handle to destination window
int Msg, // message
int wParam, // first message parameter
int lParam // second message parameter
);

const int WM_PRINT = 0x317;

[Flags]
enum DrawingOptions
{
PRF_CHECKVISIBLE = 0x01,
PRF_NONCLIENT = 0x02,
PRF_CLIENT = 0x04,
PRF_ERASEBKGND = 0x08,
PRF_CHILDREN = 0x10,
PRF_OWNED = 0x20
}

...
Bitmap l_bmp = new Bitmap(c_panel.Width, c_panel.Height);
Graphics l_grp = Graphics.FromImage(l_bmp);
IntPtr hdc = l_grp.GetHdc();
SendMessage(c_panel.Handle, WM_PRINT, (int)hdc,
(int)DrawingOptions.PRF_OWNED);

Could you please advice further?
Regards,
Chris

Ben Voigt [C++ MVP] írta:
"she_prog" <pu*********@yahoo.comwrote in message
news:11**********************@m36g2000hse.googlegr oups.com...
Dear All,
>
I need to save the content of a panel to a bitmap. The panel can have
many child controls which also need to be saved. The problem would be
solved if I could have the panel saved to a Graphics object, which is
the same as if I'd need to print it. It'd be easy using
Control.DrawToBitmap, but I also need the invisible part of the panel
(which is hidden because of scrolling) and DrawToBitmap just takes a
screenshot.
>
I've been reading about this. Many samples uses BitBlt, but that also
skips the invisible part. I've also seen some posts stating that this
is not a simple thing and I'd need to programatically scroll to all
needed position and combine the screenshots taken from all the scroll-
positions. These posts were from 2003 or 2004.
>
So my question: Is there any new solutions provided by VS2005? Or do I
No, there aren't. However, Windows has always had a solution for this:
WM_PRINT.

Try creating a bitmap of the appropriate size, getting a Graphics for it,
get the HDC, and SendMessage WM_PRINT to the window and each of its
children. That will usually get you the results you are looking for.
have to do this multiple scrolling (which produces flickering)?
>
Thank you for any help!
>
Chris
>
Jun 9 '07 #5
Did you Dispose the Graphics object before trying to use the Bitmap?

"she_prog" <pu*********@yahoo.comwrote in message
news:11**********************@k79g2000hse.googlegr oups.com...
Great, now I can see stepping through OnPaint when debugging. Still,
the resulted Bitmap is all blank :(
Right after SendMessage I'm calling l_bmp.Save(filename); so there's
no code overdrawing the result of SendMessage. The same OnPaint draws
the panel and its children just fine onto the screen.
Right now I'm just testing without scrollbars, so that shouldn't cause
the problem. I might try to do a small sample application to try to
narrow down the cause.

Thank you very much for the help! If you could think of anything that
could cause the problem, please let me know!
Regards,
Chris

Ben Voigt [C++ MVP] írta:
You should also use the CLIENT and CHILDREN flags (OR-ed together), to get
the content of the window and all contained windows.
"she_prog" <pu*********@yahoo.comwrote in message
news:11**********************@c77g2000hse.googlegr oups.com...
Thank you very much, Ben!
I tried your solution, but it didn't work for me. Maybe the problem is
that I'm trying to save a class of my own, derived from Panel and
OnPaint method is overriden in this new class. When trying to debug,
OnPaint is not called as a result of SendMessage. Here's my code:

[DllImport("user32.dll")]
public static extern int SendMessage(
IntPtr hWnd, // handle to destination window
int Msg, // message
int wParam, // first message parameter
int lParam // second message parameter
);

const int WM_PRINT = 0x317;

[Flags]
enum DrawingOptions
{
PRF_CHECKVISIBLE = 0x01,
PRF_NONCLIENT = 0x02,
PRF_CLIENT = 0x04,
PRF_ERASEBKGND = 0x08,
PRF_CHILDREN = 0x10,
PRF_OWNED = 0x20
}

...
Bitmap l_bmp = new Bitmap(c_panel.Width, c_panel.Height);
Graphics l_grp = Graphics.FromImage(l_bmp);
IntPtr hdc = l_grp.GetHdc();
SendMessage(c_panel.Handle, WM_PRINT, (int)hdc,
(int)DrawingOptions.PRF_OWNED);

Could you please advice further?
Regards,
Chris

Ben Voigt [C++ MVP] írta:
"she_prog" <pu*********@yahoo.comwrote in message
news:11**********************@m36g2000hse.googlegr oups.com...
Dear All,
>
I need to save the content of a panel to a bitmap. The panel can have
many child controls which also need to be saved. The problem would be
solved if I could have the panel saved to a Graphics object, which is
the same as if I'd need to print it. It'd be easy using
Control.DrawToBitmap, but I also need the invisible part of the panel
(which is hidden because of scrolling) and DrawToBitmap just takes a
screenshot.
>
I've been reading about this. Many samples uses BitBlt, but that also
skips the invisible part. I've also seen some posts stating that this
is not a simple thing and I'd need to programatically scroll to all
needed position and combine the screenshots taken from all the scroll-
positions. These posts were from 2003 or 2004.
>
So my question: Is there any new solutions provided by VS2005? Or do I
No, there aren't. However, Windows has always had a solution for this:
WM_PRINT.

Try creating a bitmap of the appropriate size, getting a Graphics for
it,
get the HDC, and SendMessage WM_PRINT to the window and each of its
children. That will usually get you the results you are looking for.
have to do this multiple scrolling (which produces flickering)?
>
Thank you for any help!
>
Chris
>
Jun 9 '07 #6
"she_prog" <pu*********@yahoo.comwrote in message
news:11**********************@k79g2000hse.googlegr oups.com...
>the resulted Bitmap is all blank :(
Right after SendMessage I'm calling l_bmp.Save(filename); so there's
no code overdrawing the result of SendMessage.
Release the hdc before saving the bitmap.

c_panel.Width and c_panel.Height will only get you the visible part of the
control.
Use c_panel.DisplayRectangle.Width, c_panel.DisplayRectangle.Height to get
the entire control.

--
Mick Doherty
http://www.dotnetrix.co.uk/nothing.html
Jun 10 '07 #7
Thank you, Mick! The first code was just for testing purposes, yes, I
did use DisplayRectangle.
Mick Doherty írta:
"she_prog" <pu*********@yahoo.comwrote in message
news:11**********************@k79g2000hse.googlegr oups.com...
the resulted Bitmap is all blank :(
Right after SendMessage I'm calling l_bmp.Save(filename); so there's
no code overdrawing the result of SendMessage.

Release the hdc before saving the bitmap.

c_panel.Width and c_panel.Height will only get you the visible part of the
control.
Use c_panel.DisplayRectangle.Width, c_panel.DisplayRectangle.Height to get
the entire control.

--
Mick Doherty
http://www.dotnetrix.co.uk/nothing.html
Jun 10 '07 #8
You're great, Ben, thank you very much! I did play with flags and all,
but here I'm displaying the code that's working for me for every case
- it might help someone sometime in the future :)

[DllImport("user32.dll")]
public static extern int SendMessage(
IntPtr hWnd, // handle to destination window
int Msg, // message
int wParam, // first message parameter
int lParam // second message parameter
);

const int WM_PRINT = 0x317;

[Flags]
enum DrawingOptions
{
PRF_CHECKVISIBLE = 0x01,
PRF_NONCLIENT = 0x02,
PRF_CLIENT = 0x04,
PRF_ERASEBKGND = 0x08,
PRF_CHILDREN = 0x10,
PRF_OWNED = 0x20
}

private void command_Click(object sender, EventArgs e)
{
// get filename
c_panel.AutoScrollPosition = new Point(0, 0);
Bitmap l_bmpPanel = new
Bitmap(c_panel.DisplayRectangle.Width,
c_panel.DisplayRectangle.Height);
Graphics l_grpSrc = Graphics.FromImage(l_bmpPanel);

c_panel.ForcePaint(new PaintEventArgs(l_grpSrc,
c_panel.DisplayRectangle));
SendMessage(c_panel.Handle, WM_PRINT,
(int)l_grpSrc.GetHdc(), (int)(DrawingOptions.PRF_OWNED |
DrawingOptions.PRF_CHILDREN | DrawingOptions.PRF_CLIENT |
DrawingOptions.PRF_NONCLIENT));
l_grpSrc.ReleaseHdc();

l_bmpPanel.Save(filename);
}

I had to set AutoScrollPosition to (0,0), but I don't think it's
against the user-friendliness of the application.
ForcePaint is simple:

public void ForcePaint(PaintEventArgs pe)
{
OnPaint(pe);
}

It's only needed because I have some custom painting in this OnPaint
and that was only drawn in the visible area of the panel, I don't
really know why. All children have custom painting as well, and those
drawings are done both on visible and invisible area. Although I don't
think it's elegant programming, I couldn't think of any other
solution.

So thank you again for the help, Ben!
Regards, Chris

Ben Voigt [C++ MVP] írta:
Did you Dispose the Graphics object before trying to use the Bitmap?

"she_prog" <pu*********@yahoo.comwrote in message
news:11**********************@k79g2000hse.googlegr oups.com...
Great, now I can see stepping through OnPaint when debugging. Still,
the resulted Bitmap is all blank :(
Right after SendMessage I'm calling l_bmp.Save(filename); so there's
no code overdrawing the result of SendMessage. The same OnPaint draws
the panel and its children just fine onto the screen.
Right now I'm just testing without scrollbars, so that shouldn't cause
the problem. I might try to do a small sample application to try to
narrow down the cause.

Thank you very much for the help! If you could think of anything that
could cause the problem, please let me know!
Regards,
Chris

Ben Voigt [C++ MVP] írta:
You should also use the CLIENT and CHILDREN flags (OR-ed together), to get
the content of the window and all contained windows.
"she_prog" <pu*********@yahoo.comwrote in message
news:11**********************@c77g2000hse.googlegr oups.com...
Thank you very much, Ben!
I tried your solution, but it didn't work for me. Maybe the problem is
that I'm trying to save a class of my own, derived from Panel and
OnPaint method is overriden in this new class. When trying to debug,
OnPaint is not called as a result of SendMessage. Here's my code:

[DllImport("user32.dll")]
public static extern int SendMessage(
IntPtr hWnd, // handle to destination window
int Msg, // message
int wParam, // first message parameter
int lParam // second message parameter
);

const int WM_PRINT = 0x317;

[Flags]
enum DrawingOptions
{
PRF_CHECKVISIBLE = 0x01,
PRF_NONCLIENT = 0x02,
PRF_CLIENT = 0x04,
PRF_ERASEBKGND = 0x08,
PRF_CHILDREN = 0x10,
PRF_OWNED = 0x20
}

...
Bitmap l_bmp = new Bitmap(c_panel.Width, c_panel.Height);
Graphics l_grp = Graphics.FromImage(l_bmp);
IntPtr hdc = l_grp.GetHdc();
SendMessage(c_panel.Handle, WM_PRINT, (int)hdc,
(int)DrawingOptions.PRF_OWNED);

Could you please advice further?
Regards,
Chris

Ben Voigt [C++ MVP] írta:
"she_prog" <pu*********@yahoo.comwrote in message
news:11**********************@m36g2000hse.googlegr oups.com...
Dear All,

I need to save the content of a panel to a bitmap. The panel can have
many child controls which also need to be saved. The problem would be
solved if I could have the panel saved to a Graphics object, which is
the same as if I'd need to print it. It'd be easy using
Control.DrawToBitmap, but I also need the invisible part of the panel
(which is hidden because of scrolling) and DrawToBitmap just takes a
screenshot.

I've been reading about this. Many samples uses BitBlt, but that also
skips the invisible part. I've also seen some posts stating that this
is not a simple thing and I'd need to programatically scroll to all
needed position and combine the screenshots taken from all the scroll-
positions. These posts were from 2003 or 2004.

So my question: Is there any new solutions provided by VS2005? Or do I
No, there aren't. However, Windows has always had a solution for this:
WM_PRINT.
>
Try creating a bitmap of the appropriate size, getting a Graphics for
it,
get the HDC, and SendMessage WM_PRINT to the window and each of its
children. That will usually get you the results you are looking for.
>
have to do this multiple scrolling (which produces flickering)?

Thank you for any help!

Chris
Jun 10 '07 #9
I'm glad it helped. If custom draw worked properly in children but not the
panel itself, then the panel's WM_PAINT must clip to the visible area
instead of using the clipping region you gave it. Does your OnPaint do
anything like that? That part about having to call OnPaint yourself seems
to be the most hacky part of this, and still not too bad. WM_PRINT is
definitely intended for this purpose.
"she_prog" <pu*********@yahoo.comwrote in message
news:11**********************@m36g2000hse.googlegr oups.com...
You're great, Ben, thank you very much! I did play with flags and all,
but here I'm displaying the code that's working for me for every case
- it might help someone sometime in the future :)

[DllImport("user32.dll")]
public static extern int SendMessage(
IntPtr hWnd, // handle to destination window
int Msg, // message
int wParam, // first message parameter
int lParam // second message parameter
);

const int WM_PRINT = 0x317;

[Flags]
enum DrawingOptions
{
PRF_CHECKVISIBLE = 0x01,
PRF_NONCLIENT = 0x02,
PRF_CLIENT = 0x04,
PRF_ERASEBKGND = 0x08,
PRF_CHILDREN = 0x10,
PRF_OWNED = 0x20
}

private void command_Click(object sender, EventArgs e)
{
// get filename
c_panel.AutoScrollPosition = new Point(0, 0);
Bitmap l_bmpPanel = new
Bitmap(c_panel.DisplayRectangle.Width,
c_panel.DisplayRectangle.Height);
Graphics l_grpSrc = Graphics.FromImage(l_bmpPanel);

c_panel.ForcePaint(new PaintEventArgs(l_grpSrc,
c_panel.DisplayRectangle));
SendMessage(c_panel.Handle, WM_PRINT,
(int)l_grpSrc.GetHdc(), (int)(DrawingOptions.PRF_OWNED |
DrawingOptions.PRF_CHILDREN | DrawingOptions.PRF_CLIENT |
DrawingOptions.PRF_NONCLIENT));
l_grpSrc.ReleaseHdc();

l_bmpPanel.Save(filename);
}

I had to set AutoScrollPosition to (0,0), but I don't think it's
against the user-friendliness of the application.
ForcePaint is simple:

public void ForcePaint(PaintEventArgs pe)
{
OnPaint(pe);
}

It's only needed because I have some custom painting in this OnPaint
and that was only drawn in the visible area of the panel, I don't
really know why. All children have custom painting as well, and those
drawings are done both on visible and invisible area. Although I don't
think it's elegant programming, I couldn't think of any other
solution.

So thank you again for the help, Ben!
Regards, Chris

Ben Voigt [C++ MVP] írta:
Did you Dispose the Graphics object before trying to use the Bitmap?

"she_prog" <pu*********@yahoo.comwrote in message
news:11**********************@k79g2000hse.googlegr oups.com...
Great, now I can see stepping through OnPaint when debugging. Still,
the resulted Bitmap is all blank :(
Right after SendMessage I'm calling l_bmp.Save(filename); so there's
no code overdrawing the result of SendMessage. The same OnPaint draws
the panel and its children just fine onto the screen.
Right now I'm just testing without scrollbars, so that shouldn't cause
the problem. I might try to do a small sample application to try to
narrow down the cause.

Thank you very much for the help! If you could think of anything that
could cause the problem, please let me know!
Regards,
Chris

Ben Voigt [C++ MVP] írta:
You should also use the CLIENT and CHILDREN flags (OR-ed together), to
get
the content of the window and all contained windows.
"she_prog" <pu*********@yahoo.comwrote in message
news:11**********************@c77g2000hse.googlegr oups.com...
Thank you very much, Ben!
I tried your solution, but it didn't work for me. Maybe the problem is
that I'm trying to save a class of my own, derived from Panel and
OnPaint method is overriden in this new class. When trying to debug,
OnPaint is not called as a result of SendMessage. Here's my code:

[DllImport("user32.dll")]
public static extern int SendMessage(
IntPtr hWnd, // handle to destination window
int Msg, // message
int wParam, // first message parameter
int lParam // second message parameter
);

const int WM_PRINT = 0x317;

[Flags]
enum DrawingOptions
{
PRF_CHECKVISIBLE = 0x01,
PRF_NONCLIENT = 0x02,
PRF_CLIENT = 0x04,
PRF_ERASEBKGND = 0x08,
PRF_CHILDREN = 0x10,
PRF_OWNED = 0x20
}

...
Bitmap l_bmp = new Bitmap(c_panel.Width, c_panel.Height);
Graphics l_grp = Graphics.FromImage(l_bmp);
IntPtr hdc = l_grp.GetHdc();
SendMessage(c_panel.Handle, WM_PRINT, (int)hdc,
(int)DrawingOptions.PRF_OWNED);

Could you please advice further?
Regards,
Chris

Ben Voigt [C++ MVP] írta:
"she_prog" <pu*********@yahoo.comwrote in message
news:11**********************@m36g2000hse.googlegr oups.com...
Dear All,

I need to save the content of a panel to a bitmap. The panel can
have
many child controls which also need to be saved. The problem would
be
solved if I could have the panel saved to a Graphics object, which
is
the same as if I'd need to print it. It'd be easy using
Control.DrawToBitmap, but I also need the invisible part of the
panel
(which is hidden because of scrolling) and DrawToBitmap just takes a
screenshot.

I've been reading about this. Many samples uses BitBlt, but that
also
skips the invisible part. I've also seen some posts stating that
this
is not a simple thing and I'd need to programatically scroll to all
needed position and combine the screenshots taken from all the
scroll-
positions. These posts were from 2003 or 2004.

So my question: Is there any new solutions provided by VS2005? Or do
I
No, there aren't. However, Windows has always had a solution for
this:
WM_PRINT.
>
Try creating a bitmap of the appropriate size, getting a Graphics for
it,
get the HDC, and SendMessage WM_PRINT to the window and each of its
children. That will usually get you the results you are looking for.
>
have to do this multiple scrolling (which produces flickering)?

Thank you for any help!

Chris
Jun 12 '07 #10

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

Similar topics

3
by: TheTenor | last post by:
I have a page with a graphic. I want to be able to define the graphics such that it is not saved when the viewer saves the page to his local drive. I'm trying to avoid having a seperate folder...
1
by: Laxmikant Rashinkar | last post by:
Hi, I am drawing some graphical data (such as waveforms and graphs) on a panel. I would like to save this graphical data as a jpeg image. How does one do this in C#? thank you for your help....
21
by: Michael Turner | last post by:
Hi Guys I have several images that will be used over and over again on different forms in the same place, I have decided to create a control to save space/time in development, I have create a...
2
by: Peteroid | last post by:
When the application I'm working on is run it creates a panel with a Paint event customized to draw primitives (circles, rectangles, etc.), places the panel on a form, and then launches the form....
6
by: Paul_Madden | last post by:
I have a System.Windows.Forms.Form onto which I add a Panel (MyPanel) directly derived from System.Windows.Forms.Panel. Here are the important code fragments ... public class MyPanel : Panel...
6
by: Chris Dunaway | last post by:
The method for printing documents in .Net can be confusing, especially for newer users. I would like to create a way to simplify this process. My idea would be implemented using a PrintDocument...
11
by: dongarbage | last post by:
Hi there, I'm very much a C# novice. How do you do freehand drawing on a panel with a mouse in c#? Thanks, Don
8
by: vicky87.eie | last post by:
I used a picture box to draw lines and rectangle using its graphics object in paint event. Now i need to save those lines i have drawn and print them. I need to know how to save them. I tried...
5
by: Adam Sandler | last post by:
Hello, I took a look at http://msdn.microsoft.com/en-us/library/aa287531(VS.71).aspx which gives a code sample on how to print a form. To print a panel, I just substituted 'p' for 'this': ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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...
1
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: 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...
1
by: Shćllîpôpď 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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.