15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Subclassing CFileDialog

F. Hassainia -- hassainf@PSY.UMontreal.CA
Thursday, March 06, 1997

Environment : MSVC 4.0, Win95
Hi,
I need to create a dialog that looks like the one displayed for adding files 
to a project in Visual C++ 1.0 or 1.5 (it is also the same as the one 
displayed when we re-create  a class wizard file (*.clw) ). So, in this 
dialog I have a FileOpen common dialog, a list box, and 3 buttons (Add, 
Remove and Remove All). My list box is intend to contain the files that I 
select from the common dialog list box. 
I designed a dialog template that includes all these items (My list box, and 
3 buttons) with a WS_CHILD style. Then I derived a new class CGrpFileDlg from 
CFileDialog. Every thing works fine... but I need to "subclass" CFileDialog 
so I can change the behavior of a double click in CFileDialog list box (lst1 
box)from opening the file to adding it to my list box. 
I read that I have to add the OFN_ENABLEHOOK to the m_ofn.Flags, and supply 
m_ofn.lpfnHook but I don't figure how to trap the double click in "lst1" list 
box.
Can anyone explain me how to implement that.

Thanks in advance for any help.

Farid.



Paul Martinsen -- p.martinsen@auckland.ac.nz
Tuesday, March 11, 1997

Take a look at your dialog window using Spy++. You will see that your
CGrpFileDlg is actually a child window of the standard file dialog, and the
double click message is sent to the parent window, but not your child
window. To get those double click messages you'll need to subclass the
parent window of CGrpFileDlg in your hook function.
Paul.

----------
> Environment : MSVC 4.0, Win95
> I designed a dialog template that includes all these items (My list box,
and 
> 3 buttons) with a WS_CHILD style. Then I derived a new class CGrpFileDlg
from 
> CFileDialog. Every thing works fine... but I need to "subclass"
CFileDialog 
> so I can change the behavior of a double click in CFileDialog list box
(lst1 
> box)from opening the file to adding it to my list box. 
> I read that I have to add the OFN_ENABLEHOOK to the m_ofn.Flags, and
supply 
> m_ofn.lpfnHook but I don't figure how to trap the double click in "lst1"
list 
> box.





Become an MFC-L member | Вернуться в корень Архива |