CFileDialog Subclass Problem 
Author Message
 CFileDialog Subclass Problem

I found the following question at Experts Exchange, which I hope someone has
a working solution to..

Quote:
> I have a class derived from CFileDialog. I have inserted a CComboBox at

the bottom of the dialog. In the added combo box are a list of previously
used directories for saving reading.
What I want to do is when somebody selects a directory on the ComboBox this
will change the default directory in the CFileDialog to the one selected in
the ComboBox.

Accepted Solution:

I send another suggestion after that. But I can not see it. I do not know
what's wrong. I want to tell you that add this line in your program:
GetParent()->PostMessage( WM_NOTIFY,  CDN_FOLDERCHANGE, 0);
Please try to see if it works. If the message can be receive by the window,
may be you do not need to fill the structure after you use
SetCurrentDirectory.

The problem is that the solution does not work. It Just Crashes! I don't
believe you can Post a WM_NOTIFY message in that manner.

I tried the following in my CFileDialogEx::OnComboBoxSelect() and it had no
effect.
CFileDialogEx::OnComboBoxSelect()
{
// ...Some code left out

// m_notify is defined as NMHDR notify and is a class member.
 m_notify.hwndFrom = m_hWnd;
 m_notify.idFrom = 0; // I tried the actual Ctrl ID here but it did not make
a difference
 m_notify.code = CDN_FOLDERCHANGE;
 GetParent()->PostMessage( WM_NOTIFY,0,(LPARAM)&m_notify);

// ...Some code left out

Quote:
}

Any Help is appreciated,
Thanks in Advance,
John M. Drescher

http://www.*-*-*.com/


Mon, 09 Jul 2001 03:00:00 GMT  
 CFileDialog Subclass Problem
Answering my own question,

I found the following to work, by adding a hook to the window and tracing
the messages sent to the window after pressing the enter key:

CFileDialogEx::OnComboBoxSelect()
{
// ...Some code left out

CWnd* pWnd = GetParent()->GetDlgItem(edt1);
GetParent()->PostMessage(WM_COMMAND,1,(LPARAM)pWnd->m_hWnd);

// ...Some code left out

Quote:
}

Sending this message to the edit control for the file name, windows refreshes the dialog as if the user pressed the enter key.

John M. Drescher

http://www.geocities.com/SiliconValley/Haven/1654/



Wed, 11 Jul 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Subclass CFileDialog - Return Regeneration

2. CFileDialog subclass

3. CDialog, subclass or not to subclass?

4. Serializing subclass-objects problem

5. Problem with COleControl subclasses a combobox control

6. Problem: Classwizard does not handle 2nd generation subclass and its events/messages properly

7. Subclass / Hook Problems

8. <Help !> SubClass problem

9. <Help !> SubClass problem

10. CFileDialog within a CFileDialog

11. CFileDialog problem.

12. Problem with the class CFileDialog

 

 
Powered by phpBB® Forum Software