Click here to Skip to main content
16,011,447 members
Home / Discussions / C#
   

C#

 
GeneralDragDrop registration failed Pin
michael.wikstrom12-May-04 22:32
michael.wikstrom12-May-04 22:32 
GeneralRe: DragDrop registration failed Pin
Heath Stewart13-May-04 3:03
protectorHeath Stewart13-May-04 3:03 
GeneralGDI+ Image from Graphics Pin
mhmoud rawas12-May-04 22:10
mhmoud rawas12-May-04 22:10 
GeneralRe: GDI+ Image from Graphics Pin
sprout7412-May-04 22:31
sprout7412-May-04 22:31 
GeneralRe: GDI+ Image from Graphics Pin
mhmoud rawas12-May-04 23:35
mhmoud rawas12-May-04 23:35 
GeneralRe: GDI+ Image from Graphics Pin
Heath Stewart13-May-04 3:01
protectorHeath Stewart13-May-04 3:01 
GeneralRe: GDI+ Image from Graphics Pin
mhmoud rawas13-May-04 4:19
mhmoud rawas13-May-04 4:19 
GeneralRe: GDI+ Image from Graphics Pin
Heath Stewart13-May-04 4:50
protectorHeath Stewart13-May-04 4:50 
Well, yes, I know, but you can use that (basically, it creates a compatible bitmap) to draw into as well.That was the intention. Also, don't save with every call to OnPaint - do you realize how much a performance hit you'll take? Use a state variable or something.

Without using BitBlt to source-copy an HDC, about the only other option (because this is a Windows-specific operation) is to create a compatible Bitmap (using a Graphics object from CreateGraphics), then getting the Graphics object from the Bitmap. This results in about what CreateCompatibleDC does.

You then pass that second Graphics to OnPaint like so:
using (Graphics g1 = CreateGraphics())
{
  using (Bitmap bmp = new Bitmap(Bounds.Width, Bounds.Height, g1))
  {
    using (Graphics g2 = Graphics.FromImage(bmp))
    {
      PaintEventArgs e = new PaintEventArgs(g2, Bounds);
      OnPaint(e);
    }

    bmp.Save(filename);
  }
}
This will only capture what you've drawn, however.

Keep in mind that one provider for Windows Forms in Mono is Wine, so all this stuff would still work. This type of functionality is specific to the window manager, though. Some things can't be written genericly (like modifying controls using Windows messaging since you can't always do this using the .NET FCL).

 

Microsoft MVP, Visual C#
My Articles
GeneralRe: GDI+ Image from Graphics Pin
mhmoud rawas14-May-04 19:45
mhmoud rawas14-May-04 19:45 
GeneralRe: GDI+ Image from Graphics Pin
Heath Stewart16-May-04 11:17
protectorHeath Stewart16-May-04 11:17 
Generalregd richtextbox and datagrid Pin
karteek12-May-04 21:47
karteek12-May-04 21:47 
GeneralRe: regd richtextbox and datagrid Pin
Heath Stewart13-May-04 2:58
protectorHeath Stewart13-May-04 2:58 
Generalfirewall Pin
shahrokh nabavi12-May-04 21:07
shahrokh nabavi12-May-04 21:07 
GeneralRe: firewall Pin
Colin Angus Mackay12-May-04 23:26
Colin Angus Mackay12-May-04 23:26 
GeneralRe: firewall Pin
walker_net23-Jun-04 22:54
walker_net23-Jun-04 22:54 
GeneralRe: firewall Pin
Colin Angus Mackay23-Jun-04 23:03
Colin Angus Mackay23-Jun-04 23:03 
GeneralTable problem (Xml) Pin
bertcox12-May-04 20:40
bertcox12-May-04 20:40 
GeneralRe: Table problem (Xml) Pin
Aryadip12-May-04 21:20
Aryadip12-May-04 21:20 
GeneralScroll Bar Pin
sreejith ss nair12-May-04 19:18
sreejith ss nair12-May-04 19:18 
GeneralRe: Scroll Bar Pin
Heath Stewart13-May-04 2:54
protectorHeath Stewart13-May-04 2:54 
GeneralText Readers, Streams, *ugh* Pin
gUrM33T12-May-04 17:42
gUrM33T12-May-04 17:42 
GeneralRe: Text Readers, Streams, *ugh* Pin
Paul Watson12-May-04 21:23
sitebuilderPaul Watson12-May-04 21:23 
GeneralRe: Found an alternate way ... Pin
gUrM33T13-May-04 0:23
gUrM33T13-May-04 0:23 
GeneralRe: Text Readers, Streams, *ugh* Pin
Heath Stewart13-May-04 2:52
protectorHeath Stewart13-May-04 2:52 
GeneralRe: Text Readers, Streams, *ugh* Pin
Mike Dimmick13-May-04 4:37
Mike Dimmick13-May-04 4:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.