Results 1 to 16 of 16

Thread: common dialog

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2000
    Location
    USA, Virginia
    Posts
    25

    Post

    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


  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Aug 2000
    Location
    USA, Virginia
    Posts
    25
    i did that, now what do i do next?

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  5. #5
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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.

  6. #6
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    *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

  7. #7
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221

    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.

  8. #8
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  9. #9
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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.

  10. #10
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  11. #11
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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.

  12. #12
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Yeah...Dunno what it is.
    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

  13. #13
    Guest
    They're open and save dialogs.

  14. #14
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  15. #15
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    *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.

  16. #16
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    *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
  •  



Click Here to Expand Forum to Full Width