Results 1 to 15 of 15

Thread: [RESOLVED] Change the text of the Common Dialog button

  1. #1

    Thread Starter
    Fanatic Member Episcopal's Avatar
    Join Date
    Mar 2019
    Location
    Brazil
    Posts
    547

    Resolved [RESOLVED] Change the text of the Common Dialog button

    Is it possible to change the button text of the common save/open dialog box to another text?
    Name:  Dialog.jpg
Views: 397
Size:  29.5 KB

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Change the text of the Common Dialog button

    If you use the GetOpenFileName() API you can include an OPENFILENAME.lpfnHook pointer to an OFNHookProc().

    In your OFNHookProc() you can send CDM_SETCONTROLTEXT messages to the hdlg that is passed to your hook procedure.

    I don't have a working VB example to show. I just looked it up.

  3. #3
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Change the text of the Common Dialog button

    Quote Originally Posted by Episcopal View Post
    Is it possible to change the button text of the common save/open dialog box to another text?
    That's the modern equivalent, available since Vista: IFileDialog

    There are several variations of that in the code bank. Here is mine: https://www.vbforums.com/showthread....One)&p=5254303
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  4. #4
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Change the text of the Common Dialog button

    Ah, I was thinking he was using VB, so GetOpenFileName() made sense. Didn't notice he wanted the IFileDialog instead.

  5. #5
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Change the text of the Common Dialog button

    Only way I really recognized it was due to the combobox near the "Make" button. GetOpenFileName can still be used, but unfortunately, once the OFNHookProc is in play, the dialog goes back to pre-Vista old style. Without hooking, looks just like the modern version, but without all the customization options.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  6. #6
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Change the text of the Common Dialog button

    Are you sure you aren't thinking of the OFNHookProcOldStyle() instead? Using OFN_EXPLORER is supposed to get the new hook instead.

  7. #7
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Change the text of the Common Dialog button

    There's three styles now: oldest style (pre-XP?), old-style (pre-Vista), current style (Vista+). Here are some comments from another site. I'm not on a VB box now, so can't verify myself, but those comments are what I recall. Reason why on Vista+ the hook, with OFN_Explorer, reverts to the middle of those 3 styles was I believe that on Vista+, Windows hooks the common dialog to provide the Vista style when OpenFileName API is used. Well if the user is hooking it, then Windows decided not to double hook it.

    If you use both OFN_EXPLORER and OFN_ENABLEHOOK in Windows Vista and 7, you will get the dialog boxes with XP style. If you remove OFN_EXPLORER you will get the older Win2k style. If you use OFN_ENABLEHOOK (or OFN_ENABLETEMPLATE) then the system will not use Vista/7 style.
    edited: on tanner's site (was a regular member here), some screenshots of the various styles
    Last edited by LaVolpe; Sep 16th, 2020 at 10:41 PM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  8. #8
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,652

    Re: Change the text of the Common Dialog button

    With IFileDialog it's super easy:

    Code:
    Dim fod As FileOpenDialog
    Set fod = New FileOpenDialog
    
    fod.SetOkButtonLabel "text"
    Here's my demo of all the other stuff in the interface:
    [VB6] Using the new IFileDialog interface for customizable Open/Save (TLB)

  9. #9

    Thread Starter
    Fanatic Member Episcopal's Avatar
    Join Date
    Mar 2019
    Location
    Brazil
    Posts
    547

    Re: Change the text of the Common Dialog button

    Quote Originally Posted by fafalone View Post
    With IFileDialog it's super easy:

    Code:
    Dim fod As FileOpenDialog
    Set fod = New FileOpenDialog
    
    fod.SetOkButtonLabel "text"

    It's really easy ...

  10. #10

    Thread Starter
    Fanatic Member Episcopal's Avatar
    Join Date
    Mar 2019
    Location
    Brazil
    Posts
    547

    Re: Change the text of the Common Dialog button

    Quote Originally Posted by LaVolpe View Post
    That's the modern equivalent, available since Vista: IFileDialog

    There are several variations of that in the code bank. Here is mine: https://www.vbforums.com/showthread....One)&p=5254303
    I will examine it slowly so that I can absorb as much as possible ...

  11. #11

    Thread Starter
    Fanatic Member Episcopal's Avatar
    Join Date
    Mar 2019
    Location
    Brazil
    Posts
    547

    Re: [RESOLVED] Change the text of the Common Dialog button

    Thanks

  12. #12
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Change the text of the Common Dialog button

    Quote Originally Posted by Episcopal View Post
    I will examine it slowly so that I can absorb as much as possible ...
    The biggest difference between my version and fafalone's is that his uses a typelib and mine does not; but does allow subclassing and customizing not available via a typelib directly.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  13. #13

    Thread Starter
    Fanatic Member Episcopal's Avatar
    Join Date
    Mar 2019
    Location
    Brazil
    Posts
    547

    Re: Change the text of the Common Dialog button

    Quote Originally Posted by LaVolpe View Post
    The biggest difference between my version and fafalone's is that his uses a typelib and mine does not; but does allow subclassing and customizing not available via a typelib directly.

    I don't like having to rely on external references ...

  14. #14
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,652

    Re: [RESOLVED] Change the text of the Common Dialog button

    As always there's pros and cons to each approach and you should use what works best for you, but do note that typelibs are references for the IDE only. They don't need to be present after your project is compiled, and don't need to be distributed to systems you install the program on. I'm not a fan of dependencies either, but given that it makes the benefits of TLBs worthwhile, especially when you're working with a large number of COM interfaces that are interdependent.


    --
    PS- @LaVolpe, are you suggesting IFileDialog can't be subclassed if created via TLB?
    Last edited by fafalone; Sep 21st, 2020 at 06:56 PM.

  15. #15

    Thread Starter
    Fanatic Member Episcopal's Avatar
    Join Date
    Mar 2019
    Location
    Brazil
    Posts
    547

    Re: [RESOLVED] Change the text of the Common Dialog button

    Quote Originally Posted by fafalone View Post
    As always there's pros and cons to each approach and you should use what works best for you, but do note that typelibs are references for the IDE only. They don't need to be present after your project is compiled, and don't need to be distributed to systems you install the program on. I'm not a fan of dependencies either, but given that it makes the benefits of TLBs worthwhile, especially when you're working with a large number of COM interfaces that are interdependent.
    I know that, friend. After compiling, goodbye reference.

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