-
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
-
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
-
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
-
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.
-
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.
-
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?
-
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.
-
Thanks Wiz, got it working!