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.DrawToB itmap, 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 9 4272
"she_prog" <pu*********@ya hoo.comwrote in message
news:11******** **************@ m36g2000hse.goo glegroups.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.DrawToB itmap, 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
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("user 32.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_CHECKVISIBL E = 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.FromIm age(l_bmp);
IntPtr hdc = l_grp.GetHdc();
SendMessage(c_p anel.Handle, WM_PRINT, (int)hdc,
(int)DrawingOpt ions.PRF_OWNED) ;
Could you please advice further?
Regards,
Chris
Ben Voigt [C++ MVP] írta:
"she_prog" <pu*********@ya hoo.comwrote in message
news:11******** **************@ m36g2000hse.goo glegroups.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.DrawToB itmap, 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
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*********@ya hoo.comwrote in message
news:11******** **************@ c77g2000hse.goo glegroups.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("user 32.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_CHECKVISIBL E = 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.FromIm age(l_bmp);
IntPtr hdc = l_grp.GetHdc();
SendMessage(c_p anel.Handle, WM_PRINT, (int)hdc,
(int)DrawingOpt ions.PRF_OWNED) ;
Could you please advice further?
Regards,
Chris
Ben Voigt [C++ MVP] írta:
"she_prog" <pu*********@ya hoo.comwrote in message
news:11******** **************@ m36g2000hse.goo glegroups.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.DrawToB itmap, 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
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(file name); 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*********@ya hoo.comwrote in message
news:11******** **************@ c77g2000hse.goo glegroups.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("user 32.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_CHECKVISIBL E = 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.FromIm age(l_bmp);
IntPtr hdc = l_grp.GetHdc();
SendMessage(c_p anel.Handle, WM_PRINT, (int)hdc,
(int)DrawingOpt ions.PRF_OWNED) ;
Could you please advice further?
Regards,
Chris
Ben Voigt [C++ MVP] írta:
"she_prog" <pu*********@ya hoo.comwrote in message
news:11******** **************@ m36g2000hse.goo glegroups.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.DrawToB itmap, 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
>
Did you Dispose the Graphics object before trying to use the Bitmap?
"she_prog" <pu*********@ya hoo.comwrote in message
news:11******** **************@ k79g2000hse.goo glegroups.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(file name); 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*********@ya hoo.comwrote in message
news:11******** **************@ c77g2000hse.goo glegroups.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("user 32.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_CHECKVISIBL E = 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.FromIm age(l_bmp);
IntPtr hdc = l_grp.GetHdc();
SendMessage(c_p anel.Handle, WM_PRINT, (int)hdc,
(int)DrawingOpt ions.PRF_OWNED) ;
Could you please advice further?
Regards,
Chris
Ben Voigt [C++ MVP] írta:
"she_prog" <pu*********@ya hoo.comwrote in message
news:11******** **************@ m36g2000hse.goo glegroups.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.DrawToB itmap, 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
>
"she_prog" <pu*********@ya hoo.comwrote in message
news:11******** **************@ k79g2000hse.goo glegroups.com.. .
>the resulted Bitmap is all blank :( Right after SendMessage I'm calling l_bmp.Save(file name); 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.Display Rectangle.Width , c_panel.Display Rectangle.Heigh t to get
the entire control.
--
Mick Doherty http://www.dotnetrix.co.uk/nothing.html
Thank you, Mick! The first code was just for testing purposes, yes, I
did use DisplayRectangl e.
Mick Doherty írta:
"she_prog" <pu*********@ya hoo.comwrote in message
news:11******** **************@ k79g2000hse.goo glegroups.com.. .
the resulted Bitmap is all blank :(
Right after SendMessage I'm calling l_bmp.Save(file name); 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.Display Rectangle.Width , c_panel.Display Rectangle.Heigh t to get
the entire control.
--
Mick Doherty http://www.dotnetrix.co.uk/nothing.html
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("user 32.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_CHECKVISIBL E = 0x01,
PRF_NONCLIENT = 0x02,
PRF_CLIENT = 0x04,
PRF_ERASEBKGND = 0x08,
PRF_CHILDREN = 0x10,
PRF_OWNED = 0x20
}
private void command_Click(o bject sender, EventArgs e)
{
// get filename
c_panel.AutoScr ollPosition = new Point(0, 0);
Bitmap l_bmpPanel = new
Bitmap(c_panel. DisplayRectangl e.Width,
c_panel.Display Rectangle.Heigh t);
Graphics l_grpSrc = Graphics.FromIm age(l_bmpPanel) ;
c_panel.ForcePa int(new PaintEventArgs( l_grpSrc,
c_panel.Display Rectangle));
SendMessage(c_p anel.Handle, WM_PRINT,
(int)l_grpSrc.G etHdc(), (int)(DrawingOp tions.PRF_OWNED |
DrawingOptions. PRF_CHILDREN | DrawingOptions. PRF_CLIENT |
DrawingOptions. PRF_NONCLIENT)) ;
l_grpSrc.Releas eHdc();
l_bmpPanel.Save (filename);
}
I had to set AutoScrollPosit ion to (0,0), but I don't think it's
against the user-friendliness of the application.
ForcePaint is simple:
public void ForcePaint(Pain tEventArgs 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*********@ya hoo.comwrote in message
news:11******** **************@ k79g2000hse.goo glegroups.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(file name); 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*********@ya hoo.comwrote in message
news:11******** **************@ c77g2000hse.goo glegroups.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("user 32.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_CHECKVISIBL E = 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.FromIm age(l_bmp);
IntPtr hdc = l_grp.GetHdc();
SendMessage(c_p anel.Handle, WM_PRINT, (int)hdc,
(int)DrawingOpt ions.PRF_OWNED) ;
Could you please advice further?
Regards,
Chris
Ben Voigt [C++ MVP] írta:
"she_prog" <pu*********@ya hoo.comwrote in message
news:11******** **************@ m36g2000hse.goo glegroups.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.DrawToB itmap, 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
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*********@ya hoo.comwrote in message
news:11******** **************@ m36g2000hse.goo glegroups.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("user 32.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_CHECKVISIBL E = 0x01,
PRF_NONCLIENT = 0x02,
PRF_CLIENT = 0x04,
PRF_ERASEBKGND = 0x08,
PRF_CHILDREN = 0x10,
PRF_OWNED = 0x20
}
private void command_Click(o bject sender, EventArgs e)
{
// get filename
c_panel.AutoScr ollPosition = new Point(0, 0);
Bitmap l_bmpPanel = new
Bitmap(c_panel. DisplayRectangl e.Width,
c_panel.Display Rectangle.Heigh t);
Graphics l_grpSrc = Graphics.FromIm age(l_bmpPanel) ;
c_panel.ForcePa int(new PaintEventArgs( l_grpSrc,
c_panel.Display Rectangle));
SendMessage(c_p anel.Handle, WM_PRINT,
(int)l_grpSrc.G etHdc(), (int)(DrawingOp tions.PRF_OWNED |
DrawingOptions. PRF_CHILDREN | DrawingOptions. PRF_CLIENT |
DrawingOptions. PRF_NONCLIENT)) ;
l_grpSrc.Releas eHdc();
l_bmpPanel.Save (filename);
}
I had to set AutoScrollPosit ion to (0,0), but I don't think it's
against the user-friendliness of the application.
ForcePaint is simple:
public void ForcePaint(Pain tEventArgs 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*********@ya hoo.comwrote in message
news:11******** **************@ k79g2000hse.goo glegroups.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(file name); 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*********@ya hoo.comwrote in message
news:11******** **************@ c77g2000hse.goo glegroups.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("user 32.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_CHECKVISIBL E = 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.FromIm age(l_bmp);
IntPtr hdc = l_grp.GetHdc();
SendMessage(c_p anel.Handle, WM_PRINT, (int)hdc,
(int)DrawingOpt ions.PRF_OWNED) ;
Could you please advice further?
Regards,
Chris
Ben Voigt [C++ MVP] írta:
"she_prog" <pu*********@ya hoo.comwrote in message
news:11******** **************@ m36g2000hse.goo glegroups.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.DrawToB itmap, 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
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 created just for the graphic when
the page is saved.
The page is an asp page that is used to access a database record. I have the
page title convey the record name so that the user can save the page and it
will be saved with the record name. I just...
|
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.
LK
|
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 control which inherits the panel
and added three panel control which host the 3 background images ( one to
the left the other to the right and one to fill the gap) now with this
control textboxes will be placed on these controls once they are added...
|
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.
The weird part is, the panel, in the instant it becomes visible, seems to
have an image of what this panel had in it the LAST TIME THE APPLICATION WAS
RUN! Since this panel is created anew every time the application is run
('natch), this seems...
|
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
{
.............................
public MyPanel () : base ()
| |
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 (much like
the current model), but my PrintDocument would have a Pages collection
such that each time you need to have an additional page, you would just
add another page to the collection and then use the page object for the
actual drawing etc. ...
|
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
|
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 image.save. But i
didn't work...
|
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':
private void CaptureScreen(Panel p)
{
Graphics myGraphics = p.CreateGraphics();
Size s = p.Size;
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |