-
Feb 11th, 2018, 12:48 PM
#1
Thread Starter
New Member
CommonDialog.InitDir not functioning in VB6
I have an app that allows the user to select a picture to be included with the record when the record is being added or edited. Setting the .initdir to app.path & "\Pictures" does not work. It always finds the same directory which also contains pictures but for the wrong application. I have tried using the Environ() function with no help.
I am using Visual Basic 6.0 on WIndows 7.
Thanks for any help you can provide.
-
Feb 11th, 2018, 01:16 PM
#2
Re: CommonDialog.InitDir not functioning in VB6
Go to OPENFILENAME structure, scroll down to lpstrInitialDir to see the rules.
I can't believe how many times we have to answer this same question here. Doesn't anybody even try a search first?
-
Feb 11th, 2018, 02:01 PM
#3
Thread Starter
New Member
Re: CommonDialog.InitDir not functioning in VB6
If you have solved it before, I wasn't able to find anything that works. I tried the reset to .filename and that doesn't work for me.
-
Feb 11th, 2018, 02:04 PM
#4
Re: CommonDialog.InitDir not functioning in VB6
It is working as intended.
-
Feb 11th, 2018, 04:48 PM
#5
Re: CommonDialog.InitDir not functioning in VB6
Hello cwmusicman,
since Windows 7 and later, the common dialog remembers the last location selected by the user even if you supply a default path.
For better or worse (I think it is worse), it works like that now.
And there is no easy workaround.
There are some workarounds that I remember I've read on internet, but I don't have the addresses of those pages.
-
Feb 11th, 2018, 05:01 PM
#6
Re: CommonDialog.InitDir not functioning in VB6
Originally Posted by cwmusicman
If you have solved it before, I wasn't able to find anything that works. I tried the reset to .filename and that doesn't work for me.
Publish a VBP project (zipped) that reproduce the problem.
-
Feb 11th, 2018, 05:05 PM
#7
Re: CommonDialog.InitDir not functioning in VB6
Originally Posted by gibra
Publish a VBP project (zipped) that reproduce the problem.
That can't be possible, because the behaviour depends of previous actions in the end user machine.
-
Feb 11th, 2018, 05:05 PM
#8
Re: CommonDialog.InitDir not functioning in VB6
What worked for me was always also specify a filename, even if there is not filename yet. It's ugly, but worked.
An alternative is using the IFileDialog:
http://www.vbforums.com/showthread.p...ista-(No-TLBs)
-
Feb 17th, 2018, 10:05 PM
#9
Re: CommonDialog.InitDir not functioning in VB6
Since the above doesn't go into details, there's several ways of handling this with IFileDialog.
First, you can have the last folder remembered on a per-dialog basis, so that no other time the dialog is opened does it effect the last folder your user selected. See [VB6, Vista+] Remember Open/Save state per-dialog instead of per-app (IFileDialog)
The second, you can always clear the last saved folder, that way the default folder is always shown since there's no old one, by calling the .ClearClientData method before setting the default folder.
And third, you can manually navigate to your desired folder by calling the .SetFolder method.
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
|