|
-
August 4th, 2004, 01:52 PM
#1
load bitmap
I can load a bitmap into my VB IDE form and have it displayed in my VB app.
However, now I want to set a flag to decide which bitmap of two to display. How can I load the bitmap manually from the code? Do I need to set the coordinates manually?
Thanks
Kevin Smith
-
August 4th, 2004, 02:22 PM
#2
You can use the LoadPicture() function, here an example, add one button and one image control to a blank project and try this code, of course you'll need to change the image file name:
Code:
Private Sub Command1_Click()
Image1.Picture = LoadPicture("E:\Images\warden.gif")
End Sub
JeffB
-
August 4th, 2004, 06:58 PM
#3
Load Bitmap
Code:
Option Explicit
' Add Component : Picture Clip Control !
' Add 2 Command Buttons
' Default 1 ( Indexed as 0 and as 1 )
' In the Picture Clip Properties window ( to the right )
' Set Rows to 2
' Columns - default setting
' This will allow you to load pictures into 1 picture clip control
' and then show them as a slideshow if you wanted to ( as an example )
' The Picture Clip file type Limitations though are limited to an .BMP
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Just showing you another option at your fingers
'
' Some code may return errors as I didn't copy and paste anything
' just rambled at the top of my head , but it will work .
' Hope you find it useful , if not now , maybe later it will come in handy :)
'
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub Form1_Load()
On Error goto LostPhoto
PictureClip1.Picture = LoadPicture(APP.Path & "\MyNudePicture.BMP")
exit sub
LostPhoto:
Msg"Someone,Somehow has removed a file, Action Aborted !",vbcritical
End Sub
Private Sub Command1_Click(index as integer)' replace with yours...
with Image1
If 0 then
.Picture = PictureClip1.GraphicCell(0)
Else
.Picture = PictureClip1.GraphicCell(1)
end if
end with
end sub
How can anyone sell information when all the information that they sell is free at the library ?
How come Doctors keep getting smarter yet they cannot cure the common cold ?
If Scientist are right and man evolved from monkey then where did the monkeys' come from ?
Man I love this little dude that waves =>  <= He just doesn't stop 
-
August 5th, 2004, 08:15 AM
#4
Thanks for your responses... there is one prob. The bitmap cannot be separate from the exe, it must be already loaded in the IDE. Know what I mean?
So I need 2 bitmaps already loaded in the IDE, and the initial image of the 2 I display will be determined by a flag.
-
August 5th, 2004, 09:21 AM
#5
You can use a resource file, or you can use image controls with the Picture property set from within the IDE, so the exe contains the images.
Please remember to rate the posts and threads that you find useful.
How can something be both new and improved at the same time?
-
August 5th, 2004, 10:25 AM
#6
Thanks, I tried loading my bitmap from the resource file I made like this:
frmProgress.pic.Picture = LoadResPicture(101, vbResBitmap)
When I run the app, I now get this error message:
"Can't show non-modal form when modal form is displayed."
Why is this happening? What am I doing wrong?
-
August 5th, 2004, 05:19 PM
#7
Referrencing the form or anything on it will load it, executing any code in the Load sub as well. It seems that the form you have showing when that code is executed is modal at the time. Instead of loading the form and image before they are needed, it might be better to just put pic.Picture = LoadResPicture(101, vbResBitmap) in the Load sub of the form where the picture is. That way, the picture is only loaded when the form is.
Please remember to rate the posts and threads that you find useful.
How can something be both new and improved at the same time?
-
August 9th, 2004, 09:18 AM
#8
Thanks Wiz, got it working!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|