Samapico Posted December 22, 2007 Report Posted December 22, 2007 I'm trying to figure out how to draw stuff kind of like I would with the BitBlt API. However, I want to use native C# functions in System.Drawing. I'm not sure at all how all that works... I have Bitmap objects, I want to copy parts of them somewhere on a picturebox (or whatever would work). So far I've only been able to draw something, but it would get erased as soon as the control is redrawn (i.e. minimize window / restore). In VB6, I would use a picturebox with 'auto-redraw' set to OFF, then BitBlt bitmap data on the picturebox's hDC, and it would stay there. Has anyone done something similar in C# (or VB.net or Java would be close enough, I guess)?
»D1st0rt Posted December 22, 2007 Report Posted December 22, 2007 If I had to guess I would say put your custom drawing code in an event handler that gets called whenever the target control gets redrawn
Samapico Posted December 22, 2007 Author Report Posted December 22, 2007 That is most likely going to suck performance-wise... I'm pretty sure it is possible to draw stuff "permanently"
»D1st0rt Posted December 22, 2007 Report Posted December 22, 2007 In the limited work I've done with graphics, the entire screen was redrawn every time. Granted I wasn't using GDI, but I wouldn't be surprised if it behaved in a similar manner. It's possible that your "permanent" drawing just does this behind the scenes.
Smong Posted December 22, 2007 Report Posted December 22, 2007 If this is for a frontend, and you plan to allow animation, then you're going to be drawing constantly anyway.
Drake7707 Posted December 22, 2007 Report Posted December 22, 2007 In VB6, I would use a picturebox with 'auto-redraw' set to OFF you mean autoredraw = true
»doc flabby Posted December 22, 2007 Report Posted December 22, 2007 quick search on google threw this up http://www.informit.com/articles/article.a...57&seqNum=8and this.http://www.codeguru.com/csharp/csharp/cs_g...icle.php/c6147/
Samapico Posted December 22, 2007 Author Report Posted December 22, 2007 In VB6, I would use a picturebox with 'auto-redraw' set to OFF you mean autoredraw = trueyeah, probably... I just remember we had to change it Actually that makes sense... it means whatever you put in it will be repainted everytime... ok then, I'll have to draw on a bitmap, and paint the bitmap on every Paint event. Thanks for these links doc, my searches on google weren't as successful
Recommended Posts