469,331 Members | 5,955 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,331 developers. It's quick & easy.

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 4026

"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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by TheTenor | last post: by
1 post views Thread by Laxmikant Rashinkar | last post: by
21 posts views Thread by Michael Turner | last post: by
2 posts views Thread by Peteroid | last post: by
6 posts views Thread by Chris Dunaway | last post: by
11 posts views Thread by dongarbage | last post: by
8 posts views Thread by vicky87.eie | last post: by
5 posts views Thread by Adam Sandler | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.