CMFCEditBrowseCtrl issue
-
I've got a dialog app that uses several
CMFCEditBrowseCtrl
controls. For each, I've called theEnableFileBrowseButton()
method. The issue I'm having is that I want to set an initial directory depending on which control is used. This is similar to thelpstrInitialDir
member ofOPENFILENAME
. The problem is thatCMFCEditBrowseCtrl
has no such functionality. I tried deriving my own class fromCMFCEditBrowseCtrl
, overriding theOnBrowse()
method, and callingSetCurrentDirectory()
before calling the base class version. No luck. Yes, the CWD is indeed changed, but that is not what the internals ofOnBrowse()
is using. Each time the browse button is clicked, the initial directory is whatever was previously used. Thinking it may be storing something in the registry, I created a very oddly-named directory, ran the program, selected several of the browse buttons (each time opening to that oddly-named directory), and then exited. Searching the entire registry for that directory name came up empty. Any idea(s) as to what may be going on? <edit> Drilling down a bit further, the issue is with theCFileDialog
object thatOnBrowse()
creates and how it usesOPENFILENAME
. The solution was to simply copy theOnBrowse()
code into my overridden version, and assign a value todlg.m_ofn.lpstrInitialDir
beforeDoModal()
is called. </edit> Thanks. DC"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles