|
-
Aug 20th, 2000, 11:08 AM
#1
Thread Starter
Junior Member
i am new, and i want to add a common dialog into my program so i can open files, where do i click to add one?
i have vb 6
thanks
-
Aug 20th, 2000, 11:13 AM
#2
Monday Morning Lunatic
Go to Components, and add "Microsoft Common Dialog Control". Choose the latest version you see.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 20th, 2000, 11:19 AM
#3
Thread Starter
Junior Member
i did that, now what do i do next?
-
Aug 20th, 2000, 11:26 AM
#4
Monday Morning Lunatic
Take the new component you now have, and put one on the form. Call it "cdlg" because it'll shorten the code .
Then, add a CommandButton ("btnGo").
Here's the code:
Code:
Private Sub btnGo_Click()
On Error GoTo ErrorHandler
cdlg.Filter = "My Program Files (*.myp)|*.myp|All Files (*.*)|*.*|"
cdlg.DialogTitle = "Open file..."
cdlg.CancelError = True
cdlg.ShowOpen
MsgBox cdlg.filename
Exit Sub
ErrorHandler:
If Err.Number = cdlCancel Then
' The user hit cancel
Else
Debug.Print "Other Error " & Err.Number
End If
End Sub
The documentation explains most of it, but that's a start. The Filter property is a bit nasty, but it's basically:
Code:
Desc1|Type1|Desc2|Type2|Desc3|Type3|
The last pipe is very important.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 20th, 2000, 01:28 PM
#5
transcendental analytic
The last pipe is very important.
Why is that? I never had a problem with not having a pipe char in the end.
Code:
CommonDialog1.Filter = "Form (*.frm)|.frm|Module (*.bas)|*.bas|All supported files|*.bas;*frm|allfiles|*.*"
Also you can have a filter accepting several filetypes, just separate them with ;
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Aug 21st, 2000, 01:09 PM
#6
Monday Morning Lunatic
*kicks ankles*
Sorry...my c++ heritage is showing . It's important when you use the API version...sorry...sorr*@%*@$*$*$%@@@$*%
*slap*
I feel better now.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 21st, 2000, 02:00 PM
#7
transcendental analytic
No big deal
yeah, but you put nullchars intead of pipechars
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Aug 21st, 2000, 02:03 PM
#8
Monday Morning Lunatic
Oh? When using the function from C++ it always worked using pipes for me...
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 21st, 2000, 02:30 PM
#9
transcendental analytic
hmm? maybe i should try that, i've always used nullchars
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Aug 21st, 2000, 02:32 PM
#10
Monday Morning Lunatic
Now I AM confused .
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 21st, 2000, 02:57 PM
#11
transcendental analytic
Yeah, me too, works only with nullchars 
Do you use these declarations?
Code:
Private Declare Function GetSaveFileName Lib "comdlg32.dll" Alias "GetSaveFileNameA" (pOpenfilename As OPENFILENAME) As Long
Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Aug 21st, 2000, 03:53 PM
#12
Monday Morning Lunatic
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 21st, 2000, 05:13 PM
#13
They're open and save dialogs.
-
Aug 21st, 2000, 06:04 PM
#14
Monday Morning Lunatic
They're open and save dialogs.
Yes...I know that. What I don't know is what's going on with the nullchars and pipechars.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 22nd, 2000, 03:47 PM
#15
transcendental analytic
*Confused*
Hmm, any ideas?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Aug 22nd, 2000, 03:56 PM
#16
Monday Morning Lunatic
*idea*
Maybe in the later version they set it so that you could use pipechars in the API version, so that people from other languages could easily incorporate it into a string. Also, in C, since the string terminator is a nullchar, how would they get the other parts? That must be why it needs two at the end...it loops through and checks for a double null.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
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
|