Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DDX Problem

Status
Not open for further replies.

Kalisto

Programmer
Feb 18, 2003
997
GB
In My dialog box (Actually a Dialog application) I have a Browse for Directory Button, and a CEditBox Control.
The Browse for directory command works, and I can (via debug) check the contents of hte return parameter.

I have a Private CString, Mapped to the value of the EditBox, but when I change the Directory I am browsing, the value of the EditBox isn't changing.

Looking at the DDX, I can see that the CString has the Right Value, and the Right Control is passed as well. It's just that the data isn't being Mapped into the edit box

Any ideas ?

K
 
If you use classes derived from the common dialog classes
(for example CFileDialog) in the MFC, DDX member variables do not get updated when you choose the "OK" button. The reason for this is that the base class "OnOK()", provided for these classes, does not call UpdateData(). For example, CFileDialog::OnOk() does not call UpdateData().

The workaround for this is to override OnOK() in your derived class and call UpdateData(). See CDialog::OnOK()in <drive>:\MSVC\MFC\SRC\DLGCORE.CPP for an example of how to set up the code and message-map entry.

This was taken from ID Q117607 in the MSDN Library.
Hope this helps.....
 
Problem is, I have used
//Open the Dialog Box, and Retrieve the Root Directory
lpid = SHBrowseForFolder(&bi);

to create a browse for folder dlg automatically. I know that it returns a correct value, it's just that I can't then update my edit box with the selected value, even if I call UpdateData(1);
 
>> even if I call UpdateData(1);
Code:
UpdateData(FALSE);

Use false to update the window with the data in the member variable. Use true to update the variable from the data in the window.

They hide those facts in the documentation.

From SDK for CWnd::UpdateData()
[blue]Parameters

bSaveAndValidate

Flag that indicates whether dialog box is being initialized (FALSE) or data is being retrieved (TRUE).
[/blue]

-pete
 
Cheers Pete, via trial and error I had got that sorted out, but it didn't help me as all it does is return the folder selected not the path. But I have that sorted out now as well.

My latest gripe is if I set the flag BIF_NONEWFOLDERBUTTON a new folder button still appears. (It doesn't affect what I am doing, but it just doesn't look right)

Thanks

Matt
 
>> BIF_NONEWFOLDERBUTTON

Matt, that option is only supported on version 6 of the shell. What version do you have installed?

-pete
 
Not sure, how do I check (But I have Win2k, and Vis.net 2003

 
I lost this from my last post [sadeyes]

>> as all it does is return the folder selected not the
>> path. But I have that sorted out now as well.

So by that you mean you now get the entire path using SHGetPathFromIDList()?


-pete
 
Yes, it's amazing what you find if you rtfm properly isn't it :-/

I assume I have an incorrect shell version simply as I cannot turn the New folder button off.

Thanks for your help, informative as usual,

K
 
>> Yes, it's amazing what you find if you rtfm properly isn't it

[lol] Yeah, but i'm not sure it's technically a manual these days cause it's pretty much infinite eh? For every page i read i get another 100 behind [lol]


-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top