-
Sep 16th, 2020, 06:37 PM
#1
Thread Starter
Fanatic Member
[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?
-
Sep 16th, 2020, 06:54 PM
#2
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.
-
Sep 16th, 2020, 06:55 PM
#3
Re: Change the text of the Common Dialog button
Originally Posted by Episcopal
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
-
Sep 16th, 2020, 06:58 PM
#4
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.
-
Sep 16th, 2020, 07:13 PM
#5
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.
-
Sep 16th, 2020, 09:19 PM
#6
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.
-
Sep 16th, 2020, 10:35 PM
#7
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.
-
Sep 16th, 2020, 11:41 PM
#8
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)
-
Sep 17th, 2020, 05:12 PM
#9
Thread Starter
Fanatic Member
Re: Change the text of the Common Dialog button
Originally Posted by fafalone
With IFileDialog it's super easy:
Code:
Dim fod As FileOpenDialog
Set fod = New FileOpenDialog
fod.SetOkButtonLabel "text"
It's really easy ...
-
Sep 17th, 2020, 05:13 PM
#10
Thread Starter
Fanatic Member
Re: Change the text of the Common Dialog button
Originally Posted by LaVolpe
I will examine it slowly so that I can absorb as much as possible ...
-
Sep 17th, 2020, 05:51 PM
#11
Thread Starter
Fanatic Member
Re: [RESOLVED] Change the text of the Common Dialog button
-
Sep 17th, 2020, 08:10 PM
#12
Re: Change the text of the Common Dialog button
Originally Posted by Episcopal
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.
-
Sep 20th, 2020, 08:12 PM
#13
Thread Starter
Fanatic Member
Re: Change the text of the Common Dialog button
Originally Posted by LaVolpe
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 ...
-
Sep 21st, 2020, 06:50 PM
#14
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.
-
Sep 21st, 2020, 06:52 PM
#15
Thread Starter
Fanatic Member
Re: [RESOLVED] Change the text of the Common Dialog button
Originally Posted by fafalone
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|