Visual Basic .NET Forums  
Click here to advertise with us

Go Back   Visual Basic .NET Forums > VB.NET > Graphics/GDI+

Graphics/GDI+ Graphics discussion for VB.NET applications, Winforms, Web, Compact Framework, etc.

VB.NET Forums Newsletter Signup:
Email address:


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-03-2010, 9:07 PM
ALX ALX is offline
VB.NET Forum Fanatic
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Nov 2005
Location: Columbia, SC
Posts: 135
Reputation: 57
ALX is on a distinguished programming path ahead
Default Bitmaps in memory?

This may be a stupid question, but I'm fearless...

There is a form (let's say Form A) in my app that uses a reduced snapshot of a different form (Form B) in the same app. The way I've been doing this is:

1st- Display the form that I need to copy. (Form B)
2nd- Run through a quick "BitBlt" API call & save the image to a shared bitmap variable.
3rd- Display Form A and assign the bitmap to a picturebox in Form A
4th- Close Form B

This works OK. I was just wondering if there was a way that I could capture the image of Form B without actually displaying it to avoid the distraction of having Form B show briefly just before Form A is shown... say if there were a way to construct Form B in memory and then capture the image from there. It would appear a little more professionally constructed that way. Is this reasonably do-able?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-07-2010, 8:25 PM
VB.NET Forum Enthusiast
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Aug 2008
Age: 64
Posts: 39
Reputation: 55
VicJ probably authored a book by nowVicJ probably authored a book by now
Default

Use the hidden form's DrawToBitmap method. For example, assuming Form1 is hidden:

Code:
Dim bmp As New Bitmap(Form1.Width, Form1.Height)
Dim rect As New Rectangle(0, 0, Form1.Width, Form1.Height)
Form1.DrawToBitmap(bmp, rect)
DrawToBitmap always captures the whole form (as long as the bitmap is big enough) starting from the top left of the title bar. If you don't want that, set its FormBorderStyle to None before using DrawToBitmap.

bye, Vic
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-10-2010, 11:31 PM
ALX ALX is offline
VB.NET Forum Fanatic
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Nov 2005
Location: Columbia, SC
Posts: 135
Reputation: 57
ALX is on a distinguished programming path ahead
Default

This is a great way (and a shorter way than I was using) to capture a bitmap of the screen. But unless I'm screwing up somewhere, it appears that I have to display the form 1st... which is what I was trying to avoid.

-Edited: Well it seems that I can show the form and then immediately hide it and then use your approach... So as far as the users' point of view goes, it never really appears. -(Barely a flash on the screen)- I guess it's a cheat, but it works for me! Thanks for your help!!!

Last edited by ALX; 02-10-2010 at 11:47 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





All times are GMT -4. The time now is 6:18 AM.

Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2


For advertising opportunities click here.