|
-
Nov 2nd, 2003, 04:23 PM
#1
Thread Starter
Addicted Member
Common Dialog problems.
ive added a common dialog control onto my project, but there are a few things im stuck with:
1) i have a browse button but i dont know how to change the picture in a image control with the file that was selected.
here is the code i have so far:
-
Nov 2nd, 2003, 04:28 PM
#2
Thread Starter
Addicted Member
whoops, pressed enter to quickly.
here is the code for q 1)
VB Code:
Private Sub cmdbgbrowse_Click()
diabox.DialogTitle = "Browse"
diabox.Filter = "All Formats|*.BMP;*.RLE;*.DIB;*.GIF;*.JPG;*.JPEG;*.JPE;*.PNG;*.TIF;*.TIFF|BMP (*.BMP;*.RLE;*.DIB)|*.BMP;*.RLE;*.DIB|GIF (*.GIF)|*.GIF|JPEG (*.JPG;*.JPEG;*.JPE)|*.JPG;*.JPEG;*.JPE|PNG (*.PNG)|*.PNG|TIFF (*.TIF;*.TIFF)|*.TIF;*.TIFF|"
diabox.ShowOpen
picturepreview = diabox.FileName
imgpic.Picture = picturepreview
End Sub
but that doesnt work right.
2) i call the dialog in the Save As menu thing, but i dont know how to make it so if a file already exists then you have the msgbox to either overwrite or to exit.
here is my code so far:
[Highlight=VB]
Private Sub saveas_Click()
diabox.DialogTitle = "Save Scene As"
diabox.Filter = "Scene Files (*.tsn)|*.tsn|"
diabox.ShowSave
'save the file
Open App.Path & "\Demo\Scenes\" & diabox.FileTitle For Output As #1
Print #1, diabox.FileTitle & vbNewLine & txtscenetext.Text & vbNewLine & txtnorth.Text & vbNewLine & txtsouth.Text & vbNewLine & txteast.Text & vbNewLine & txtwest.Text
Close #1
done:
End Sub
3) how do i make it so if the user clicks cancel it just quits the dialog? because what i have at the moment, is that it saves weather i click save or cancel.
4) how do i erase what is in the FileName box of the dialog? because when i close a dialog is has something in it, so next time i open the dialog it already has that in it. and this code doesnt work:
thanks
-
Nov 3rd, 2003, 06:03 AM
#3
Fanatic Member
Use loadpicture command.
This is just a sample piece.
Add the loadpicture to your code]
VB Code:
Private Sub Command1_Click()
Dialog1.Filter = "*.jpeg|*.bmp|*.gif|"
Dialog1.ShowOpen
Image1.Picture = LoadPicture(Dialog1.FileName)
'ps set Cancelerror to true in the dialog properties'
-
Nov 3rd, 2003, 06:41 AM
#4
2) See help for the "Flags" property, one of the options is to show the "confirm overwrite" message.
3) Set the CancelError property - then you will get an error if they cancel. eg:
VB Code:
Private Sub saveas_Click()
diabox.DialogTitle = "Save Scene As"
diabox.Filter = "Scene Files (*.tsn)|*.tsn|"
diabox.CancelError = True
On Error Resume Next
diabox.ShowSave
If Err = 0 Then
On Error Goto 0 '(resume normal error handling)
'save the file
Open App.Path & "\Demo\Scenes\" & diabox.FileTitle For Output As #1
Print #1, diabox.FileTitle & vbNewLine & txtscenetext.Text & vbNewLine & txtnorth.Text & vbNewLine & txtsouth.Text & vbNewLine & txteast.Text & vbNewLine & txtwest.Text
Close #1
End If
done:
End Sub
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
|