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.
Subject |
Author |
Date |
|
Ivan Shmakov
|
Sep 13, 2007 - 5:51 AM
|
Hello!
I’m trying to open FileOpen and FileSave common dialog looks like all application style (CExtPaintManagerOffice2007_Black).
I try to subclass FileOpen dialog:
class CProfUISFileDialog : public CExtNCW<CExtResizableDialog> { public: CProfUISFileDialog(CWnd* pParent = NULL) : m_pParent(pParent) { m_bAutoSubclassChildControls = true; m_bShowResizingGripper = false; }
virtual ~CProfUISFileDialog() {}
public: virtual INT_PTR DoModal() { // Test Opening OPENFILENAME ofn; // common dialog box structure TCHAR szFile[MAX_PATH]; // buffer for file name HANDLE hf; // file handle
// Initialize OPENFILENAME ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = m_pParent->m_hWnd; ofn.lpstrFile = szFile; ofn.lpstrFile[0] = _T(’\0’); ofn.nMaxFile = sizeof(szFile); ofn.lpstrFilter = _T("All\0*.*\0Text\0*.TXT\0"); ofn.nFilterIndex = 1; ofn.lpstrFileTitle = NULL; ofn.nMaxFileTitle = 0; ofn.lpstrInitialDir = NULL; ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
AfxHookWindowCreate(this); if (GetOpenFileName(&ofn)==TRUE) {
} return IDOK; } private: CWnd* m_pParent; };
and use by
CProfUISFileDialog dlg(this); dlg.DoModal();
But this solution crashed... at
void CExtComboBoxBase::DrawItem( LPDRAWITEMSTRUCT lpDIS ) { ... if( lpDIS->itemID >= 0 ) { LB_ITEM * pItemDataExt = (LB_ITEM *) lResult; if( pItemDataExt != NULL && AfxIsMemoryBlock( static_cast < LPVOID > ( pItemDataExt ), sizeof( LB_ITEM ) ) // <- Crash here ...
}
Help me to solve this problem or please send me sample how to create CFileDialog in same style as other application.
|
|
Technical Support
|
Sep 13, 2007 - 11:24 AM
|
Actually the combo box in the File Dialog is an extended version of the simple combo box control which provides support for image lists (CComboBoxEx ). So it is incorrect to subclass it with the CExtComboBox class which is derived from the simple CComboBox . We spent a lot of time to create the Prof-UIS skinned extended combo box but failed. It simply ignores the WM_PAINT message and draws itself in some other way. If you find a way how to create a skinned version of CComboBoxEx then you will be able to use it in the File Dialog window.
If you are creating these dialogs from the scratch and encounter this error, please send us the source code so we can test it on our side and find out what is wrong.
|
|