Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > General Discussion
  New Posts New Posts RSS Feed - CFileDialog using MFC on Vista
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CFileDialog using MFC on Vista

 Post Reply Post Reply
Author
Message
cpede View Drop Down
Senior Member
Senior Member


Joined: 13 August 2004
Location: Denmark
Status: Offline
Points: 668
Post Options Post Options   Thanks (0) Thanks(0)   Quote cpede Quote  Post ReplyReply Direct Link To This Post Topic: CFileDialog using MFC on Vista
    Posted: 08 May 2008 at 2:59am
When using VS2008 and MFC I automatically get the Vista look on my file open dialogs. But when I have added a template this is not included :-(
 
I can then retrieve the GetIFileDialogCustomize interface and add controls. And this also works for me.
  • How can I better control the placement of the controls? E.g. if I wan to add a large edit field called Comments, I cannot control the size of it?
    My other question is about the events.
  • Is there an easy way to overwrite the control events in MFC CFileDialog? In the MFC implementation I can see the the events are implemented, but how do I get access or overwrites then. E.g. the OnButtonClicked?

Thanks, cpede

Back to Top
cpede View Drop Down
Senior Member
Senior Member


Joined: 13 August 2004
Location: Denmark
Status: Offline
Points: 668
Post Options Post Options   Thanks (0) Thanks(0)   Quote cpede Quote  Post ReplyReply Direct Link To This Post Posted: 01 December 2008 at 8:17am
I would really appreciate if someone knows answers to these problems
 
The positioning is only cosmetic, but the control events are important. Browsing the web only reveals that I should make a class derived from IFileDialogControlEvents abd use the Advise method, but since VS2008 MFC CFileDialog already does that, there must be an easier way??
 
-cpede
Back to Top
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post Posted: 01 December 2008 at 11:30am
The new file dialog is one of the reasons why I switched back to XP
PokerMemento - http://www.pokermemento.com/
Back to Top
Sven View Drop Down
Senior Member
Senior Member


Joined: 21 August 2003
Location: Germany
Status: Offline
Points: 127
Post Options Post Options   Thanks (0) Thanks(0)   Quote Sven Quote  Post ReplyReply Direct Link To This Post Posted: 02 December 2008 at 5:40am
Set the last parameter in CFileDialogs constructor to FALSE and you will get the XP implementation on Vista too.
Back to Top
cpede View Drop Down
Senior Member
Senior Member


Joined: 13 August 2004
Location: Denmark
Status: Offline
Points: 668
Post Options Post Options   Thanks (0) Thanks(0)   Quote cpede Quote  Post ReplyReply Direct Link To This Post Posted: 02 December 2008 at 7:04am
Well I was actually looking for a solution. Going back to old technology is not my style, I would rather solve the issues in front of me, - too early for me to resign.
 
Am I the only one making a custom CFileDialog? Looking in MSDN did not solve anything, and they are also terrible in answering posts at there forum.
 
-cpede
Back to Top
robin_l View Drop Down
Senior Member
Senior Member


Joined: 15 October 2006
Status: Offline
Points: 117
Post Options Post Options   Thanks (0) Thanks(0)   Quote robin_l Quote  Post ReplyReply Direct Link To This Post Posted: 02 December 2008 at 11:35am

Look at the IFileDialogControlEvents interface for handling button clicks etc.

I'm not sure how you change from the default control size though....

Product: Xtreme ToolkitPro 2009 (13.4.1)
Platform: Windows 7 Ultimate(64bit)
Language: Visual Studio 2010 (C++)
Back to Top
cpede View Drop Down
Senior Member
Senior Member


Joined: 13 August 2004
Location: Denmark
Status: Offline
Points: 668
Post Options Post Options   Thanks (0) Thanks(0)   Quote cpede Quote  Post ReplyReply Direct Link To This Post Posted: 02 December 2008 at 2:43pm
Thanks for the reply.
I know that this is the interface to look for, and what I should do is to implement this interface and Advise the IFileDialog with this event connection point.
 
But when using CFileDialog in MFC 9 this already implements this interface, but by looking in the MFC code this implementation is empty.
 
My question is really can I redirect this interface to my own implementation?
Or is it possible to do a simple virtual inheritance?
What happens if I advice with my own, where does it leave the MFC implementation?
 
-cpede
Back to Top
robin_l View Drop Down
Senior Member
Senior Member


Joined: 15 October 2006
Status: Offline
Points: 117
Post Options Post Options   Thanks (0) Thanks(0)   Quote robin_l Quote  Post ReplyReply Direct Link To This Post Posted: 02 December 2008 at 3:28pm

It is a while since I did this, but what I do is the following. In a class derived from CFileDialog, I include the following in the declaration:


protected:
DECLARE_INTERFACE_MAP()
BEGIN_INTERFACE_PART(FileDialogControlEvents, IFileDialogControlEvents)
  STDMETHOD(OnItemSelected)(IFileDialogCustomize *, DWORD, DWORD);
  STDMETHOD(OnButtonClicked)(IFileDialogCustomize *, DWORD);
  STDMETHOD(OnCheckButtonToggled)(IFileDialogCustomize *, DWORD, BOOL);
  STDMETHOD(OnControlActivating)(IFileDialogCustomize *, DWORD);
END_INTERFACE_PART_OPTIONAL(FileDialogControlEvents)


Then in the source file, something like:

BEGIN_INTERFACE_MAP(CMyDialog, CFileDialog)
  INTERFACE_PART(CMyDialog, ID_IFileDialogControlEvents_MFC, FileDialogControlEvents)
END_INTERFACE_MAP()

in the constructor you need to include

USE_INTERFACE_PART_STD(FileDialogControlEvents);


you then need to implement the methods (the ones below are blank)

STDMETHODIMP CMyDialog::XFileDialogControlEvents::OnItemSelected( IFileDialogCustomize *pfdc, DWORD dwIDCtl, DWORD dwIDItem )
{
 METHOD_PROLOGUE(CMyDialog, FileDialogControlEvents)
 return S_OK;
}


STDMETHODIMP CMyDialog::XFileDialogControlEvents::OnButtonClicked( IFileDialogCustomize *pfdc, DWORD dwIDCtl )
{
 METHOD_PROLOGUE(CMyDialog, FileDialogControlEvents)
 return S_OK;
}

STDMETHODIMP CMyDialog::XFileDialogControlEvents::OnCheckButtonToggled( IFileDialogCustomize *pfdc, DWORD dwIDCtl, BOOL bChecked )
{
 METHOD_PROLOGUE(CMyDialog, FileDialogControlEvents)
 return S_OK;
}

STDMETHODIMP CMyDialog::XFileDialogControlEvents::OnControlActivating( IFileDialogCustomize *pfdc, DWORD dwIDCtl )
{
 METHOD_PROLOGUE(CMyDialog, FileDialogControlEvents)
 return S_OK;
}

STDMETHODIMP_(ULONG) CMyDialog::XFileDialogControlEvents::AddRef()
{
 METHOD_PROLOGUE(CMyDialog, FileDialogControlEvents)
 return pThis->ExternalAddRef();
}

STDMETHODIMP_(ULONG) CMyDialog::XFileDialogControlEvents::Release()
{
 METHOD_PROLOGUE(CMyDialog, FileDialogControlEvents)
 return pThis->ExternalRelease();
}

STDMETHODIMP CMyDialog::XFileDialogControlEvents::QueryInterface(
 REFIID iid, void FAR* FAR* ppvObj)
{
 METHOD_PROLOGUE(CMyDialog, FileDialogControlEvents)
 ENSURE(ppvObj != NULL);
 return (HRESULT)pThis->ExternalQueryInterface(&iid, ppvObj);
}

Product: Xtreme ToolkitPro 2009 (13.4.1)
Platform: Windows 7 Ultimate(64bit)
Language: Visual Studio 2010 (C++)
Back to Top
cpede View Drop Down
Senior Member
Senior Member


Joined: 13 August 2004
Location: Denmark
Status: Offline
Points: 668
Post Options Post Options   Thanks (0) Thanks(0)   Quote cpede Quote  Post ReplyReply Direct Link To This Post Posted: 02 December 2008 at 4:52pm
Wow I really appreciate thanks
 
-cpede
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.203 seconds.