Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » How to change a CFileDialog derived dialog aspect like a CExtResizableDialog Collapse All
Subject Author Date
Roberto MAnes Feb 18, 2005 - 4:40 AM

I have a dialog derived from CFileDialog. I would like to change the aspect of this dialog depending on the current in use paint manager. Do I have any chance ? Regards

Technical Support Feb 21, 2005 - 8:03 AM

You could traverse all child windows in the code for your file dialog and subclass windows with Prof-UIS classes like as follows:

class CMyDynamicButton : public CExtButton
{
public:
    void PostNcDestroy()
    {
        delete this;
    }
};

Your code may look like:
HWND hWnd = ::GetWindow( m_hWnd, GW_CHILD );
for( ; hWnd != NULL;
       hWnd = ::GetWindow( hWnd, GW_HWNDNEXT )
    )
{
    CString s;
    ::GetClassName(
        hWnd,
        s.GetBuffer(256),
        255
        );
    s.ReleaseBuffer();
    s.MakeLower();
    if( s == "button" )
    {
        CMyDynamicButton * pMyDynamicButton =
            new CMyDynamicButton;
        pMyDynamicButton ->
            SubclassWindow( hWnd );
        continue;
    }
}

Besides, please use CExtWS < CFileDialog > as a base type for your file dialog, which adds a theme-based background.

Roberto Manes Mar 1, 2005 - 1:46 AM

I declared my derived CFileDialog class as follows<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>


<o:p> </o:p>class AFX_EXT_CLASS CUIDialogImageFiles<o:p></o:p>


      : public CExtWS < CFileDialog ><o:p></o:p>


{<o:p></o:p>


      DECLARE_DYNAMIC(CUIDialogImageFiles)<o:p></o:p>


….<o:p></o:p>


….<o:p></o:p>


}<o:p></o:p>


<o:p> </o:p>IMPLEMENT_DYNAMIC(CUIDialogImageFiles, CExtWS < CFileDialog >)<o:p></o:p>


<o:p> </o:p>CUIDialogImageFiles::CUIDialogImageFiles(<o:p></o:p>


            BOOL bOpenFileDialog,<o:p></o:p>


            CString szTitle,<o:p></o:p>


            UINT *pFileTypes,<o:p></o:p>


            LPCTSTR szSection, LPCTSTR szKeyPath, LPCTSTR szKeyFilter,<o:p></o:p>


            LPCTSTR lpszDefExt, LPCTSTR lpszFileName,<o:p></o:p>


            DWORD dwFlags, LPCTSTR lpszFilter, CWnd* pParentWnd)<o:p></o:p>


: CExtWS < CFileDialog >(bOpenFileDialog, lpszDefExt, lpszFileName, dwFlags, FileTypesFilter(pFileTypes), pParentWnd)<o:p></o:p>


{<o:p></o:p>


…<o:p></o:p>


…<o:p></o:p>


}<o:p></o:p>


<o:p> </o:p>But I’ve got this error message during compiling the application<o:p></o:p>


<o:p> </o:p>error C2661: ’CExtWS<CExtWSBase>::__ctor’ : no overloaded function takes 6 arguments<o:p></o:p>


        with<o:p></o:p>


        [<o:p></o:p>


            CExtWSBase=CFileDialog<o:p></o:p>


        ]<o:p></o:p>


        and<o:p></o:p>


        [<o:p></o:p>


            CExtWSBase=CFileDialog<o:p></o:p>


        ]<o:p></o:p>


<o:p> </o:p>


Could you give me any suggestion to solve this problem ?<o:p></o:p>


Thanks in advance<o:p></o:p>

Technical Support Mar 1, 2005 - 7:35 AM

You could add a new constructor to the CExtWS class. This constructor should be like that used in CFileDialog. The CExtWS < CFileDialog > type will be compilable and, if you use a more correct IMPLEMENT_DYNAMIC(CUIDialogImageFiles,CFileDialog) macro implementation, then, you will be able to run your file dialog. But, unfortunately you will never get a stylish dialog background like that found in any CExtResizableDialog. We created a test project with a CFileDialog-derived class and the WM_PAINT message handler. We noticed that this message never gets our file dialog class. It is never received by CExtWS::WindowProc() method. This means that the standard file dialog handles painting somewhere outside the window procedure (may be in its message loop code) or it uses some hooks over its own window which eats up painting messages.

Roberto Manes Mar 7, 2005 - 7:17 AM

This means I have no chance for a CFileDialog derived class, is it ? Just to make some trials could you send me the test project you created just to see if I can find out any walk around ? Thanks

Technical Support Mar 7, 2005 - 12:00 PM

Unfortunately, we have not saved this project. You can simply try to handle the WM_PAINT message in your own CFileDialog-derived class. But we think it is hardly possible. The only way is to write such a class from scratch.