M
Mr. X.
I have two panels.
One is visible on screen (pnlMain), and one not (BackPanel)
When I create VirtualPanel :
==================
BackPanel = new Panel();
BackPanel.Left = pnlMain.Left;
BackPanel.Top = pnlMain.Top;
BackPanel.Width = pnlMain.Width;
BackPanel.Height = pnlMain.Height;
BackPanel.Margin = pnlMain.Margin;
BackPanel.BackColor = Color.White;
Also I did :
Graphics g = BackPanel.CreateGraphics();
g.DrawEllipse(Pens.Blue,10, 10, 20, 20);
Bitmap bmp = default(Bitmap);
bmp = new Bitmap(pnlMain.Width, pnlMain.Height);
FBackPanel.BackColor = Color.Red;
pnlMain.DrawToBitmap(bmp, new Rectangle(0,
0,pnlMain.Width, pnlMain.Height));
bmp.Save("test.bmp"); // **** even
pnlMain.BackgroundImage =
(Image)(Image.FromHbitmap(bmp.GetHbitmap()));
Not the file "test.bmp" neither pnlMain has the Ellipse (that I did
g.DrawEllipse ...)
Why ?
One is visible on screen (pnlMain), and one not (BackPanel)
When I create VirtualPanel :
==================
BackPanel = new Panel();
BackPanel.Left = pnlMain.Left;
BackPanel.Top = pnlMain.Top;
BackPanel.Width = pnlMain.Width;
BackPanel.Height = pnlMain.Height;
BackPanel.Margin = pnlMain.Margin;
BackPanel.BackColor = Color.White;
Also I did :
Graphics g = BackPanel.CreateGraphics();
g.DrawEllipse(Pens.Blue,10, 10, 20, 20);
Bitmap bmp = default(Bitmap);
bmp = new Bitmap(pnlMain.Width, pnlMain.Height);
FBackPanel.BackColor = Color.Red;
pnlMain.DrawToBitmap(bmp, new Rectangle(0,
0,pnlMain.Width, pnlMain.Height));
bmp.Save("test.bmp"); // **** even
pnlMain.BackgroundImage =
(Image)(Image.FromHbitmap(bmp.GetHbitmap()));
Not the file "test.bmp" neither pnlMain has the Ellipse (that I did
g.DrawEllipse ...)
Why ?