|
-
Apr 21st, 2003, 08:50 PM
#1
Thread Starter
Fanatic Member
PaintPicture doesnt seem to work in my Form_Load Macro
Bizzarre:
This code is in a filelist box that displays available images.
Code:
Private Sub flbPhotos_Click()
Dim PicPath As String
PicPath = frmSELECTPICPATH.DirPhotos + "\" + frmSELECTPICPATH.flbPhotos
frmSELECTPICPATH.picboxEmployee.Picture = LoadPicture(PicPath)
picboxEmployee.PaintPicture frmSELECTPICPATH.picboxEmployee.Picture, 0, 0, frmSELECTPICPATH.picboxEmployee.Width, frmSELECTPICPATH.picboxEmployee.Height
End Sub
This code is in the Form_Load routine
Code:
Private Sub Form_Load()
Dim i As Integer
Dim SavedPicPath As String
Dim PhotoSelected As String
Dim EmployeeName As String
On Error GoTo MyTrap:
EmployeeName = frmMANAGE_EMPLOYEE.txtFirstName + frmMANAGE_EMPLOYEE.txtLastName
frmSELECTPICPATH.Left = GetSetting(appname:="SSS", Section:="PathSettings" + CurrentUserStr, Key:="frmSELECTPICPATH_MyLeft", Default:=0)
frmSELECTPICPATH.Top = GetSetting(appname:="SSS", Section:="PathSettings" + CurrentUserStr, Key:="frmSELECTPICPATH_MyTop", Default:=0)
frmSELECTPICPATH.DirPhotos = GetSetting(appname:="SSS", Section:="PathSettings" + EmployeeName, Key:="frmSELECTPICPATH_DirPhotos", Default:=frmSELECTPICPATH.DrivePhotos)
frmSELECTPICPATH.DrivePhotos = GetSetting(appname:="SSS", Section:="PathSettings" + EmployeeName, Key:="frmSELECTPICPATH_DrivePhotos", Default:="C:\")
PhotoSelected = GetSetting(appname:="SSS", Section:="PathSettings" + EmployeeName, Key:="frmSELECTPICPATH_flbPhotos", Default:="")
If Not PhotoSelected = "" Then
For i = 0 To flbPhotos.ListCount
flbPhotos.Selected(i) = True
If PhotoSelected = flbPhotos Then
flbPhotos.Selected(i) = True
Exit For
End If
Next
End If
SavedPicPath = GetSetting(appname:="SSS", Section:="PathSettings" + EmployeeName, Key:="frmSELECTPICPATH_picboxEmployee", Default:="")
If Not SavedPicPath = "" Then
frmSELECTPICPATH.picboxEmployee.Picture = LoadPicture(SavedPicPath)
frmSELECTPICPATH.picboxEmployee.PaintPicture frmSELECTPICPATH.picboxEmployee.Picture, 0, 0, frmSELECTPICPATH.picboxEmployee.Width, frmSELECTPICPATH.picboxEmployee.Height
Else
frmSELECTPICPATH.picboxEmployee.Picture = LoadPicture(NoPic)
End If
MyTrap:
End Sub
Now why does my form load with the picture not formatted to fit my picturebox. But when I click the file in my filelist box the picture displays formatted to the picturebox.
-
Apr 21st, 2003, 09:02 PM
#2
This could be totally off-base, and I have not used PaintPicture before, but let me briefly throw this out there. I have found that in general, you should watch what code you put in Form_Load, and basically limit it to initializing variables and such. The reason for this is that (I believe) all of the controls on the form are not fully "ready" until after Form_Load completes. I would move a lot of the code to Form_Activate instead.
"It's cold gin time again ..."
Check out my website here.
-
Apr 21st, 2003, 09:35 PM
#3
Thread Starter
Fanatic Member
BruceG
That helped somewhat moving the code that deals with my picturebox into the Activate property of my form. However When I exit that form I am returning to the main form which displays all the information as well as the picture. The picture on this main form isnt displayed properly either. I get a color filling the picture box without any of the picture showing up.
I can see the picture flash in the box but then crap.
-
Apr 21st, 2003, 10:48 PM
#4
Sorry I can't help you more with the picture, perhaps someone else can assist.
One other note on the Form_Activate: if you don't want the code to execute every time Activate event fires, you should use a flag to prevent the code from executing after the first time:
In general declarations:
Dim mblnFormIsActivated As Boolean
In Form_Load:
mblnFormIsActivated = False
In Form_Activate:
If mblnFormIsActivated Then Exit Sub
(code to execute just once)
mblnFormIsActivated = True
"It's cold gin time again ..."
Check out my website here.
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
|