the False file is attached and so is the most currently created .sdproj file. (file created for a test project in my app - ashley.sdproj)
Printable View
the False file is attached and so is the most currently created .sdproj file. (file created for a test project in my app - ashley.sdproj)
i think it's definitely time for bed, should have seen from the vid.
the error you get occurs on the linea label doesn't have a "Color" property - hence the errorCode:Color|255
when i changed the following (highlighted in first section of code) to ForeColor instead of Color, I then get "object doesnt support this method or property" when i go to load the project file. get the error on the CallByName line (highlighted in second section of code)
Save File
OPEN FILEVB Code:
Option Explicit Private Sub Form_Load() FormBackColor Me End Sub Private Sub cmdSaveFile_Click() m_intFF = FreeFile m_strDirectory = "Projects" m_strSaveProjectFileName = txtFileName.Text m_strSDPROJFileName = m_strSaveProjectFileName & ".sdproj" m_strFileNameLocation = App.Path & "\" & m_strDirectory & "\" & m_strSDPROJFileName If Len(Dir$(App.Path & "\" & m_strDirectory & "\", vbDirectory)) > 0 Then 'do nothing because the Projects directory exists Else MkDir (m_strDirectory) End If If m_strSaveProjectFileName = vbNullString Then MsgBox "You must input a filename!", vbExclamation, "Error Encountered." Exit Sub ElseIf LCase(Right$(txtFileName.Text, 7)) = ".sdproj" Then MsgBox "Input your file name, excluding the file extension.", vbInformation, "Error Encountered." Exit Sub End If If FileExists(m_strFileNameLocation) Then MsgBox "You must choose a different file name" & vbNewLine & "because the file name already exists.", vbInformation, "File Exists." Exit Sub Else Open m_strFileNameLocation For Output As #m_intFF For Each m_Ctrl In frmMain.lblText If m_Ctrl.Index Then With m_Ctrl Print #m_intFF, "###" Print #m_intFF, .Name & "|" & .Index Print #m_intFF, "BorderStyle" & "|" & .BorderStyle Print #m_intFF, "Top" & "|" & .Top Print #m_intFF, "Left" & "|" & .Left Print #m_intFF, "Height" & "|" & .Height Print #m_intFF, "Width" & "|" & .Width Print #m_intFF, "Appearance" & "|" & .Appearance Print #m_intFF, "BackStyle" & "|" & .BackStyle Print #m_intFF, "Caption" & "|" & Replace(.Caption, vbCr, vbNullString) Print #m_intFF, "Alignment" & "|" & .Alignment [hl]Print #m_intFF, "ForeColor" & "|" & .ForeColor[/hl] Print #m_intFF, "FontSize" & "|" & .FontSize Print #m_intFF, "FontBold" & "|" & .FontBold Print #m_intFF, "FontItalic" & "|" & .FontItalic Print #m_intFF, "Strikethrough" & "|" & .Font.Strikethrough Print #m_intFF, "Underline" & "|" & .FontUnderline Print #m_intFF, "FontName" & "|" & .FontName End With End If Next m_Ctrl For Each m_Ctrl In frmMain.pbShape If m_Ctrl.Index Then With m_Ctrl Print #m_intFF, "###" Print #m_intFF, .Name & "|" & .Index Print #m_intFF, "Top" & "|" & .Top Print #m_intFF, "Left" & "|" & .Left Print #m_intFF, "Height" & "|" & .Height Print #m_intFF, "Width" & "|" & .Width Print #m_intFF, "Appearance" & "|" & .Appearance Print #m_intFF, "BorderStyle" & "|" & .BorderStyle End With End If Next m_Ctrl For Each m_Ctrl In frmMain.pb If m_Ctrl.Index Then With m_Ctrl Print #m_intFF, "###" Print #m_intFF, .Name & "|" & .Index Print #m_intFF, "Top" & "|" & .Top Print #m_intFF, "Left" & "|" & .Left Print #m_intFF, "Height" & "|" & .Height Print #m_intFF, "Width" & "|" & .Width Print #m_intFF, "Appearance" & "|" & .Appearance Print #m_intFF, "BorderStyle" & "|" & .BorderStyle Print #m_intFF, "Picture" & "|" & .Tag If Len(.Tag) Then FileCopy App.Path & "\Temp\" & .Tag, _ App.Path & "\Files\" & .Tag End With End If Next m_Ctrl With frmMain.pbWorkArea Print #m_intFF, "###" Print #m_intFF, .Name Print #m_intFF, "Top" & "|" & .Top Print #m_intFF, "Left" & "|" & .Left Print #m_intFF, "Height" & "|" & .Height Print #m_intFF, "Width" & "|" & .Width Print #m_intFF, "Picture" & "|" & .Tag If Len(.Tag) Then FileCopy App.Path & "\Temp\" & .Tag, _ App.Path & "\Files\" & .Tag End With Close #m_intFF End If Unload Me End Sub Private Sub cmdCancel_Click() Unload Me End Sub Private Sub txtFileName_LostFocus() txtFileName.Text = LCase(txtFileName.Text) End Sub
The project file contents save the same way as a couple of posts back. The values for the error line are:VB Code:
Option Explicit Private Sub Form_Load() FormBackColor Me End Sub Private Sub cmdOpenFile_Click() m_intFF = FreeFile m_strFileName = txtFileName.Text 'full path to the .sdproj file Open m_strFileName For Input As #m_intFF Do Until EOF(m_intFF) Line Input #m_intFF, m_strLine Select Case True Case m_blnNewControl m_strParts = Split(m_strLine, "|") If UBound(m_strParts) Then Set m_Ctrl = frmMain.Controls(m_strParts(0))(Val(m_strParts(1))) Load m_Ctrl Set m_Ctrl.Container = frmMain.pbWorkArea Else Set m_Ctrl = frmMain.Controls(m_strParts(0)) End If m_blnNewControl = False Case m_strLine = "###" If Not m_Ctrl Is Nothing Then m_Ctrl.Visible = True Set m_Ctrl = Nothing m_blnNewControl = True Case Len(m_strLine) m_strParts = Split(m_strLine, "|") If m_strParts(0) = "Picure" Then If Len(m_strParts(1)) Then m_Ctrl.Picture = LoadPicture(App.Path & "\Files\" & m_strParts(1)) FileCopy App.Path & "\Files\" & m_strParts(1), _ App.Path & "\Temp\" & m_strParts(1) m_Ctrl.Tag = m_strParts(1) End If Else If m_strParts(1) = "Caption" Then m_strParts(1) = Replace(m_strParts(1), vbLf, vbCrLf) [hl]CallByName m_Ctrl, m_strParts(0), VbLet, m_strParts(1)[/hl] End If End Select Loop Close #m_intFF If Not m_Ctrl Is Nothing Then m_Ctrl.Visible = True With frmMain .lblText(.lblText.UBound).Visible = True .pb(.pb.UBound).Visible = True .pbShape(.pbShape.UBound).Visible = True End With End Sub Private Sub cmdCancel_Click() Unload Me End Sub Private Sub cmdSearchFile_Click() With CD .CancelError = True .DialogTitle = "Project File Search" .ShowOpen m_strSDPROJFileName = .FileName End With txtFileName.Text = m_strSDPROJFileName If txtFileName.Text <> vbNullString Then cmdOpenFile.Enabled = True Else cmdOpenFile.Enabled = False End If End Sub
Code:CallByName m_Ctrl, m_strParts(0), VbLet, m_strParts(1)
m_Ctrl =""
m_strParts(0) = BorderStyle
VbLet = 4
m_strParts(1) = 1
i narrowed the error down to the following, and when i comment it out, i then get a type mismatch on the picture part of the file
VB Code:
'Print #m_intFF, "Strikethrough" & "|" & .Font.Strikethrough
so now have to figure out where i am missing it when i am saving the picture. the pictures that can be used are found using a common dialog control. maybe i should then save that file to the Files directory?
ok, that makes more sense.
VB Code:
' Mismatch error: If m_strParts(0) = "[B]Picture[/B]" Then ' Strikethrough error: Print #m_intFF, "FontStrikethru" & "|" & .FontStrikethru ' Also this should be: If m_strParts[B](0) [/B]= "Caption" Then ' but as i said, just doing: CallByName m_Ctrl, m_strParts(0), VbLet, Replace(m_strParts(1), vbLf, vbCrLf) ' *should* work
ok, getting there slowly. the pbWorkArea picture isnt being saved so isnt showing up in the project file or when the project file is being loaded. There is also a blank line after 1234 Avenue and then the city. but if you add regular text, that seems to save. youll see what i mean in the vid.
when you right click on the pbWorkArea, you have an option to add a background picture, you then search the computer for that picture using a common dialog control. This picture isnt being saved anywhere or moved anywhere either. another movie to show you what i mean....
http://www.brailleschool.com/vbf/prj.html
:confused: if your code is as it is in post #43 then I can't see a reason why it's not there. Stick a break point in the cmdSaveFile_Click sub and just check what's happening - i think that's about all the advice I can offer.
ill work on this and hopefully get it sorted. just seems as tho the tag property isnt getting a value. will post back
but even if it didn't have a value it should still print "Picture|"
in the forms where i get the path to the images, i am trying to copy that particular file to the Files directory, then i can get that filename and put it in the .Tag property (hopefully)
but im getting a bad file name or number error
VB Code:
Private Sub cmdLoadPicture_Click() m_strImageFileName = CD.FileName With frmMain.pb(m_intControlIndex) .Picture = LoadPicture(m_strImageFileName) .BorderStyle = 0 End With CreateFilesDirectory FileCopy CD.FileName, App.Path & "\Files\" Unload Me End Sub
you have to specify the name of the file too:you might want to copy the file to a Temp location (as I did in my example proj) and then copy it to the File folder when they save the layout - it prevents overwriting (they may not save the proj)VB Code:
FileCopy CD.FileName, App.Path & "\Files\" & CD.FileTitle
ill do that :)
tried this to test my theory and got file name not found
VB Code:
Private Sub cmdLoadPicture_Click() m_strImageFileName = CD.FileName With frmMain.pb(m_intControlIndex) .Picture = LoadPicture(m_strImageFileName) .BorderStyle = 0 CreateFilesDirectory FileCopy .Picture, App.Path & "\Files\" End With Unload Me End Sub
error: path not found
gonna debug nowVB Code:
Private Sub cmdLoadPicture_Click() m_strImageFileName = CD.FileName With frmMain.pbWorkArea .Picture = LoadPicture(m_strImageFileName) .BorderStyle = 0 CreateTempFilesDirectory FileCopy m_strImageFileName, App.Path & "\Temp Files\" & CD.FileTitle End With Unload Me End Sub
update: the temp files directory doesnt exist... found that its being created (folder) in the same folder im getting the image from, when it should be added to the app.path. this is what im using to create the temp file folder if it doesnt exist... it should work!!!
VB Code:
Public Sub CreateTempFilesDirectory() m_strDirectory = "Temp Files" If Len(Dir$(App.Path & "\" & m_strDirectory & "\", vbDirectory)) > 0 Then 'do nothing because the Files directory exists Else MkDir (m_strDirectory) End If End Sub
do a debug.print:and does App.Path & "\Temp Files\" definitely exist?VB Code:
Debug.Print m_strImageFileName, App.Path & "\Temp Files\" & CD.FileTitle FileCopy m_strImageFileName, App.Path & "\Temp Files\" & CD.FileTitle
updated post #54 (above)Quote:
Originally Posted by bushmobile
just debugged the folder creation part and the app.path shows the right path, m_strDirectory shows the right directory name, but its not creating the directory in the right place.... hmm
solved the problem by changing the public sub to show
VB Code:
MkDir (App.Path & "\" & m_strDirectory & "\")
getting there slowly. picture now has a value but has a value of Picture|369431684 instead of the filename lol. i am sure ill figure this out :)
least my debug skills are coming into effect and hopefully improving.
:thumb:
1) all directories are created in the right place
2) the image is copied to the Temp Files directory
3) files directory is empty
4) .Tag doesnt show any value for an assigned image in the project file.
This is what the save project file code looks like:
VB Code:
Option Explicit Private Sub Form_Load() FormBackColor Me End Sub Private Sub cmdSaveFile_Click() m_intFF = FreeFile m_strProjectsDirectory = "Projects" m_strSaveProjectFileName = txtFileName.Text m_strSDPROJFileName = m_strSaveProjectFileName & ".sdproj" m_strFileNameLocation = App.Path & "\" & m_strProjectsDirectory & "\" & m_strSDPROJFileName If Len(Dir$(App.Path & "\" & m_strProjectsDirectory & "\", vbDirectory)) > 0 Then 'do nothing because the Projects directory exists Else MkDir (m_strProjectsDirectory) End If If m_strSaveProjectFileName = vbNullString Then MsgBox "You must input a filename!", vbExclamation, "Error Encountered." Exit Sub ElseIf LCase(Right$(txtFileName.Text, 7)) = ".sdproj" Then MsgBox "Input your file name, excluding the file extension.", vbInformation, "Error Encountered." Exit Sub End If If FileExists(m_strFileNameLocation) Then MsgBox "You must choose a different file name" & vbNewLine & "because the file name already exists.", vbInformation, "File Exists." Exit Sub Else Open m_strFileNameLocation For Output As #m_intFF For Each m_Ctrl In frmMain.lblText If m_Ctrl.Index Then With m_Ctrl Print #m_intFF, "###" Print #m_intFF, .Name & "|" & .Index Print #m_intFF, "BorderStyle" & "|" & .BorderStyle Print #m_intFF, "Top" & "|" & .Top Print #m_intFF, "Left" & "|" & .Left Print #m_intFF, "Height" & "|" & .Height Print #m_intFF, "Width" & "|" & .Width Print #m_intFF, "Appearance" & "|" & .Appearance Print #m_intFF, "BackStyle" & "|" & .BackStyle Print #m_intFF, "Caption" & "|" & Replace(.Caption, vbCr, vbNullString) Print #m_intFF, "Alignment" & "|" & .Alignment Print #m_intFF, "ForeColor" & "|" & .ForeColor Print #m_intFF, "FontSize" & "|" & .FontSize Print #m_intFF, "FontBold" & "|" & .FontBold Print #m_intFF, "FontItalic" & "|" & .FontItalic Print #m_intFF, "FontStrikethru" & "|" & .FontStrikethru Print #m_intFF, "FontUnderline" & "|" & .FontUnderline Print #m_intFF, "FontName" & "|" & .FontName End With End If Next m_Ctrl For Each m_Ctrl In frmMain.pbShape If m_Ctrl.Index Then With m_Ctrl Print #m_intFF, "###" Print #m_intFF, .Name & "|" & .Index Print #m_intFF, "Top" & "|" & .Top Print #m_intFF, "Left" & "|" & .Left Print #m_intFF, "Height" & "|" & .Height Print #m_intFF, "Width" & "|" & .Width Print #m_intFF, "Appearance" & "|" & .Appearance Print #m_intFF, "BorderStyle" & "|" & .BorderStyle End With End If Next m_Ctrl For Each m_Ctrl In frmMain.pb If m_Ctrl.Index Then With m_Ctrl Print #m_intFF, "###" Print #m_intFF, .Name & "|" & .Index Print #m_intFF, "Top" & "|" & .Top Print #m_intFF, "Left" & "|" & .Left Print #m_intFF, "Height" & "|" & .Height Print #m_intFF, "Width" & "|" & .Width Print #m_intFF, "Appearance" & "|" & .Appearance Print #m_intFF, "BorderStyle" & "|" & .BorderStyle Print #m_intFF, "Picture" & "|" & .Tag If Len(.Tag) Then FileCopy App.Path & "\Temp Files\" & .Tag, _ App.Path & "\Files\" & .Tag End With End If Next m_Ctrl With frmMain.pbWorkArea Print #m_intFF, "###" Print #m_intFF, .Name Print #m_intFF, "Top" & "|" & .Top Print #m_intFF, "Left" & "|" & .Left Print #m_intFF, "Height" & "|" & .Height Print #m_intFF, "Width" & "|" & .Width Print #m_intFF, "Picture" & "|" & .Tag If Len(.Tag) Then FileCopy App.Path & "\Temp Files\" & .Tag, _ App.Path & "\Files\" & .Tag End With Close #m_intFF End If Unload Me End Sub Private Sub cmdCancel_Click() Unload Me End Sub Private Sub txtFileName_LostFocus() txtFileName.Text = LCase(txtFileName.Text) End Sub
you have to populate the .Tag property when you load the picture. this is what i was doing in my example prj:VB Code:
picArr(Index).Picture = LoadPicture(cmdlg.FileName) [B]picArr(Index).Tag = [/B]Mid$(cmdlg.FileName, InStrRev(cmdlg.FileName, "\") + 1) 'could have used cmdlg.FileTitle but forgot FileCopy cmdlg.FileName, App.Path & "\Temp\" & picArr(Index).Tag
must have missed it :)Quote:
Originally Posted by bushmobile
for the pbWorkArea (not in control array), it would be like so? Then yours for the other pictureboxes that are in a control array?
update: invalid procedure call or argumentVB Code:
Private Sub cmdLoadPicture_Click() m_strImageFileName = CD.FileName With frmMain.pbWorkArea .Picture = LoadPicture(m_strImageFileName) .BorderStyle = 0 [hl].Tag = Mid$(m_strImageFileName, InStrRev(CD.FileTitle, "\"))[/hl] CreateTempFilesDirectory FileCopy m_strImageFileName, App.Path & "\Temp Files\" & .Tag End With Unload Me End Sub
should be.
as i mentioned in the post above you can use:VB Code:
.Tag = CD.FileTitle
woohoo! the picture is showing in the project file and its also loading when i load it into the app. pbworkarea done, now for the control array!
I used the CD.FileTitle as you suggested. the following also worked
but i went withVB Code:
Private Sub cmdLoadPicture_Click() m_strImageFileName = CD.FileName With frmMain.pbWorkArea .Picture = LoadPicture(m_strImageFileName) .BorderStyle = 0 .Tag = Mid$(m_strImageFileName, InStrRev(CD.FileName, "\")) CreateTempFilesDirectory FileCopy m_strImageFileName, App.Path & "\Temp Files\" & .Tag End With Unload Me End Sub
VB Code:
Private Sub cmdLoadPicture_Click() m_strImageFileName = CD.FileName With frmMain.pbWorkArea .Picture = LoadPicture(m_strImageFileName) .BorderStyle = 0 .Tag = CD.FileTitle CreateTempFilesDirectory FileCopy m_strImageFileName, App.Path & "\Temp Files\" & .Tag End With Unload Me End Sub
saving the project file now seems to work without any problems. loading also works which is awesome. this part of the app seems to be complete.
thanks so much for your help, i cant say it enough..
No probs :thumb: