15 #error atldlgs.h requires atlapp.h to be included first 19 #error atldlgs.h requires atlwin.h to be included first 25 #if (_WIN32_WINNT >= 0x0600) && !defined(_WIN32_WCE) 27 #endif // (_WIN32_WINNT >= 0x0600) && !defined(_WIN32_WCE) 105 #if (_WIN32_WINNT >= 0x0500) && !defined(OPENFILENAME_SIZE_VERSION_400) 106 #ifndef CDSIZEOF_STRUCT 107 #define CDSIZEOF_STRUCT(structname, member) (((int)((LPBYTE)(&((structname*)0)->member) - ((LPBYTE)((structname*)0)))) + sizeof(((structname*)0)->member)) 109 #define OPENFILENAME_SIZE_VERSION_400A CDSIZEOF_STRUCT(OPENFILENAMEA,lpTemplateName) 110 #define OPENFILENAME_SIZE_VERSION_400W CDSIZEOF_STRUCT(OPENFILENAMEW,lpTemplateName) 112 #define OPENFILENAME_SIZE_VERSION_400 OPENFILENAME_SIZE_VERSION_400W 114 #define OPENFILENAME_SIZE_VERSION_400 OPENFILENAME_SIZE_VERSION_400A 116 #endif // (_WIN32_WINNT >= 0x0500) && !defined(OPENFILENAME_SIZE_VERSION_400) 118 #if !defined(_WIN32_WCE) && !defined(CDN_INCLUDEITEM) 119 #define CDN_INCLUDEITEM (CDN_FIRST - 0x0007) 126 #if defined(__AYGSHELL_H__) && (_WIN32_WCE >= 0x0501) 127 OPENFILENAMEEX m_ofn;
131 BOOL m_bOpenFileDialog;
132 TCHAR m_szFileTitle[_MAX_FNAME];
133 TCHAR m_szFileName[_MAX_PATH];
136 LPCTSTR lpszDefExt = NULL,
137 LPCTSTR lpszFileName = NULL,
138 DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
139 LPCTSTR lpszFilter = NULL,
140 HWND hWndParent = NULL)
142 memset(&m_ofn, 0,
sizeof(m_ofn));
143 m_szFileName[0] = _T(
'\0');
144 m_szFileTitle[0] = _T(
'\0');
146 m_bOpenFileDialog = bOpenFileDialog;
148 #if defined(__AYGSHELL_H__) && (_WIN32_WCE >= 0x0501) 149 m_ofn.lStructSize = bOpenFileDialog ?
sizeof(m_ofn) :
sizeof(OPENFILENAME);
151 m_ofn.lStructSize =
sizeof(m_ofn);
154 #if (_WIN32_WINNT >= 0x0500) 156 if(AtlIsOldWindows())
158 ATLASSERT(
sizeof(m_ofn) > OPENFILENAME_SIZE_VERSION_400);
159 m_ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
161 #endif // (_WIN32_WINNT >= 0x0500) 162 m_ofn.lpstrFile = m_szFileName;
163 m_ofn.nMaxFile = _MAX_PATH;
164 m_ofn.lpstrDefExt = lpszDefExt;
165 m_ofn.lpstrFileTitle = (LPTSTR)m_szFileTitle;
166 m_ofn.nMaxFileTitle = _MAX_FNAME;
168 m_ofn.Flags = dwFlags | OFN_EXPLORER | OFN_ENABLEHOOK | OFN_ENABLESIZING;
170 m_ofn.Flags = dwFlags | OFN_EXPLORER | OFN_ENABLEHOOK;
171 #endif // !_WIN32_WCE 172 m_ofn.lpstrFilter = lpszFilter;
173 m_ofn.hInstance = ModuleHelper::GetResourceInstance();
174 m_ofn.lpfnHook = (LPOFNHOOKPROC)T::StartDialogProc;
175 m_ofn.hwndOwner = hWndParent;
178 if(lpszFileName != NULL)
179 SecureHelper::strncpy_x(m_szFileName, _countof(m_szFileName), lpszFileName, _TRUNCATE);
182 INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow())
184 ATLASSERT((m_ofn.Flags & OFN_ENABLEHOOK) != 0);
185 ATLASSERT(m_ofn.lpfnHook != NULL);
187 ATLASSERT((m_ofn.Flags & OFN_EXPLORER) != 0);
189 if(m_ofn.hwndOwner == NULL)
190 m_ofn.hwndOwner = hWndParent;
192 ATLASSERT(m_hWnd == NULL);
194 #if (_ATL_VER >= 0x0800) 196 BOOL bRetTh = m_thunk.Init(NULL, NULL);
199 ::SetLastError(ERROR_OUTOFMEMORY);
202 #endif // (_ATL_VER >= 0x0800) 204 ModuleHelper::AddCreateWndData(&m_thunk.cd, (ATL::CDialogImplBase*)
this);
207 if(m_bOpenFileDialog)
208 #if defined(__AYGSHELL_H__) && (_WIN32_WCE >= 0x0501) 209 bRet = ::GetOpenFileNameEx(&m_ofn);
211 bRet = ::GetSaveFileName((LPOPENFILENAME)&m_ofn);
213 bRet = ::GetOpenFileName(&m_ofn);
215 bRet = ::GetSaveFileName(&m_ofn);
220 return bRet ? IDOK : IDCANCEL;
224 ATL::CWindow GetFileDialogWindow()
const 226 ATLASSERT(::IsWindow(m_hWnd));
227 return ATL::CWindow(GetParent());
230 int GetFilePath(LPTSTR lpstrFilePath,
int nLength)
const 232 ATLASSERT(::IsWindow(m_hWnd));
233 ATLASSERT((m_ofn.Flags & OFN_EXPLORER) != 0);
235 return (
int)GetFileDialogWindow().SendMessage(CDM_GETFILEPATH, nLength, (LPARAM)lpstrFilePath);
238 int GetFolderIDList(LPVOID lpBuff,
int nLength)
const 240 ATLASSERT(::IsWindow(m_hWnd));
241 ATLASSERT((m_ofn.Flags & OFN_EXPLORER) != 0);
243 return (
int)GetFileDialogWindow().SendMessage(CDM_GETFOLDERIDLIST, nLength, (LPARAM)lpBuff);
246 int GetFolderPath(LPTSTR lpstrFolderPath,
int nLength)
const 248 ATLASSERT(::IsWindow(m_hWnd));
249 ATLASSERT((m_ofn.Flags & OFN_EXPLORER) != 0);
251 return (
int)GetFileDialogWindow().SendMessage(CDM_GETFOLDERPATH, nLength, (LPARAM)lpstrFolderPath);
254 int GetSpec(LPTSTR lpstrSpec,
int nLength)
const 256 ATLASSERT(::IsWindow(m_hWnd));
257 ATLASSERT((m_ofn.Flags & OFN_EXPLORER) != 0);
259 return (
int)GetFileDialogWindow().SendMessage(CDM_GETSPEC, nLength, (LPARAM)lpstrSpec);
262 void SetControlText(
int nCtrlID, LPCTSTR lpstrText)
264 ATLASSERT(::IsWindow(m_hWnd));
265 ATLASSERT((m_ofn.Flags & OFN_EXPLORER) != 0);
267 GetFileDialogWindow().SendMessage(CDM_SETCONTROLTEXT, nCtrlID, (LPARAM)lpstrText);
270 void SetDefExt(LPCTSTR lpstrExt)
272 ATLASSERT(::IsWindow(m_hWnd));
273 ATLASSERT((m_ofn.Flags & OFN_EXPLORER) != 0);
275 GetFileDialogWindow().SendMessage(CDM_SETDEFEXT, 0, (LPARAM)lpstrExt);
278 BOOL GetReadOnlyPref()
const 280 return ((m_ofn.Flags & OFN_READONLY) != 0) ? TRUE : FALSE;
284 void HideControl(
int nCtrlID)
286 ATLASSERT(::IsWindow(m_hWnd));
287 ATLASSERT((m_ofn.Flags & OFN_EXPLORER) != 0);
289 GetFileDialogWindow().SendMessage(CDM_HIDECONTROL, nCtrlID);
293 BOOL EndDialog(INT_PTR = 0)
295 ATLASSERT(::IsWindow(m_hWnd));
296 GetFileDialogWindow().SendMessage(WM_COMMAND, MAKEWPARAM(IDCANCEL, 0));
302 NOTIFY_CODE_HANDLER(CDN_FILEOK, _OnFileOK)
303 NOTIFY_CODE_HANDLER(CDN_FOLDERCHANGE, _OnFolderChange)
304 NOTIFY_CODE_HANDLER(CDN_HELP, _OnHelp)
305 NOTIFY_CODE_HANDLER(CDN_INITDONE, _OnInitDone)
306 NOTIFY_CODE_HANDLER(CDN_SELCHANGE, _OnSelChange)
307 NOTIFY_CODE_HANDLER(CDN_SHAREVIOLATION, _OnShareViolation)
308 NOTIFY_CODE_HANDLER(CDN_TYPECHANGE, _OnTypeChange)
310 NOTIFY_CODE_HANDLER(CDN_INCLUDEITEM, _OnIncludeItem)
311 #endif // !_WIN32_WCE 314 LRESULT _OnFileOK(
int , LPNMHDR pnmh, BOOL& )
316 ATLASSERT(::IsWindow(m_hWnd));
317 T* pT =
static_cast<T*
>(
this);
318 return !pT->OnFileOK((LPOFNOTIFY)pnmh);
321 LRESULT _OnFolderChange(
int , LPNMHDR pnmh, BOOL& )
323 ATLASSERT(::IsWindow(m_hWnd));
324 T* pT =
static_cast<T*
>(
this);
325 pT->OnFolderChange((LPOFNOTIFY)pnmh);
329 LRESULT _OnHelp(
int , LPNMHDR pnmh, BOOL& )
331 ATLASSERT(::IsWindow(m_hWnd));
332 T* pT =
static_cast<T*
>(
this);
333 pT->OnHelp((LPOFNOTIFY)pnmh);
337 LRESULT _OnInitDone(
int , LPNMHDR pnmh, BOOL& )
339 ATLASSERT(::IsWindow(m_hWnd));
340 T* pT =
static_cast<T*
>(
this);
341 pT->OnInitDone((LPOFNOTIFY)pnmh);
345 LRESULT _OnSelChange(
int , LPNMHDR pnmh, BOOL& )
347 ATLASSERT(::IsWindow(m_hWnd));
348 T* pT =
static_cast<T*
>(
this);
349 pT->OnSelChange((LPOFNOTIFY)pnmh);
353 LRESULT _OnShareViolation(
int , LPNMHDR pnmh, BOOL& )
355 ATLASSERT(::IsWindow(m_hWnd));
356 T* pT =
static_cast<T*
>(
this);
357 return pT->OnShareViolation((LPOFNOTIFY)pnmh);
360 LRESULT _OnTypeChange(
int , LPNMHDR pnmh, BOOL& )
362 ATLASSERT(::IsWindow(m_hWnd));
363 T* pT =
static_cast<T*
>(
this);
364 pT->OnTypeChange((LPOFNOTIFY)pnmh);
369 LRESULT _OnIncludeItem(
int , LPNMHDR pnmh, BOOL& )
371 ATLASSERT(::IsWindow(m_hWnd));
372 T* pT =
static_cast<T*
>(
this);
373 return pT->OnIncludeItem((LPOFNOTIFYEX)pnmh);
375 #endif // !_WIN32_WCE 378 BOOL OnFileOK(LPOFNOTIFY )
383 void OnFolderChange(LPOFNOTIFY )
387 void OnHelp(LPOFNOTIFY )
391 void OnInitDone(LPOFNOTIFY )
395 void OnSelChange(LPOFNOTIFY )
399 int OnShareViolation(LPOFNOTIFY )
404 void OnTypeChange(LPOFNOTIFY )
409 BOOL OnIncludeItem(LPOFNOTIFYEX )
413 #endif // !_WIN32_WCE 420 LPCTSTR lpszDefExt = NULL,
421 LPCTSTR lpszFileName = NULL,
422 DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
423 LPCTSTR lpszFilter = NULL,
424 HWND hWndParent = NULL)
429 DECLARE_EMPTY_MSG_MAP()
432 #if defined(__AYGSHELL_H__) && (_WIN32_WCE >= 0x0501) 437 LPCTSTR lpszDefExt = NULL,
438 LPCTSTR lpszFileName = NULL,
439 DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
440 OFN_EXFLAG ExFlags = OFN_EXFLAG_THUMBNAILVIEW,
441 OFN_SORTORDER dwSortOrder = OFN_SORTORDER_AUTO,
442 LPCTSTR lpszFilter = NULL,
443 HWND hWndParent = NULL)
446 m_ofn.ExFlags = ExFlags;
447 m_ofn.dwSortOrder = dwSortOrder;
451 DECLARE_EMPTY_MSG_MAP()
453 #endif // defined(__AYGSHELL_H__) && (_WIN32_WCE >= 0x0501) 467 #ifndef _WTL_FIXED_OFN_BUFFER_LENGTH 468 #define _WTL_FIXED_OFN_BUFFER_LENGTH 0x10000 475 mutable LPCTSTR m_pNextFile;
481 LPCTSTR lpszDefExt = NULL,
482 LPCTSTR lpszFileName = NULL,
483 DWORD dwFlags = OFN_HIDEREADONLY,
484 LPCTSTR lpszFilter = NULL,
485 HWND hWndParent = NULL)
486 :
CFileDialogImpl<T>(TRUE, lpszDefExt, lpszFileName, dwFlags, lpszFilter, hWndParent),
489 m_ofn.Flags |= OFN_ALLOWMULTISELECT;
492 #ifdef _versionhelpers_H_INCLUDED_ 493 OSVERSIONINFOEX ovi = {
sizeof(OSVERSIONINFOEX) };
494 ovi.dwPlatformId = VER_PLATFORM_WIN32_NT;
495 DWORDLONG
const dwlConditionMask = ::VerSetConditionMask(0, VER_PLATFORMID, VER_EQUAL);
496 m_bIsNT = (::VerifyVersionInfo(&ovi, VER_PLATFORMID, dwlConditionMask) != FALSE);
497 #else // !_versionhelpers_H_INCLUDED_ 498 OSVERSIONINFO ovi = {
sizeof(OSVERSIONINFO) };
499 ::GetVersionEx(&ovi);
500 m_bIsNT = (ovi.dwPlatformId == VER_PLATFORM_WIN32_NT);
501 #endif // _versionhelpers_H_INCLUDED_ 506 ATLVERIFY(ResizeFilenameBuffer(_WTL_FIXED_OFN_BUFFER_LENGTH));
513 if (m_ofn.lpstrFile != m_szFileName)
514 delete[] m_ofn.lpstrFile;
522 int GetDirectory(LPTSTR pBuffer,
int nBufLen)
const 524 if (m_ofn.lpstrFile == NULL)
527 LPCTSTR pStr = m_ofn.lpstrFile;
528 int nLength = lstrlen(pStr);
529 if (pStr[nLength + 1] == 0)
532 LPCTSTR pSep = MinCrtHelper::_strrchr(pStr, _T(
'\\'));
534 nLength = (int)(DWORD_PTR)(pSep - pStr);
542 else if (nBufLen > nLength)
544 SecureHelper::strncpy_x(pBuffer, nBufLen, pStr, nLength);
551 #if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) 552 bool GetDirectory(_CSTRING_NS::CString& strDir)
const 556 int nLength = GetDirectory(NULL, 0);
559 bRet = (GetDirectory(strDir.GetBuffer(nLength), nLength) > 0);
560 strDir.ReleaseBuffer(nLength - 1);
565 #endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) 568 LPCTSTR GetFirstFileName()
const 570 if (m_ofn.lpstrFile == NULL)
575 LPCTSTR pStr = m_ofn.lpstrFile;
576 int nLength = lstrlen(pStr);
577 if (pStr[nLength + 1] != 0)
590 LPCTSTR pSep = MinCrtHelper::_strrchr(pStr, _T(
'\\'));
599 LPCTSTR GetNextFileName()
const 601 if (m_pNextFile == NULL)
604 LPCTSTR pStr = m_pNextFile;
607 int nLength = lstrlen(pStr);
608 m_pNextFile = (pStr[nLength + 1] != 0) ? &pStr[nLength + 1] : NULL;
617 int GetFirstPathName(LPTSTR pBuffer,
int nBufLen)
const 619 LPCTSTR pStr = GetFirstFileName();
620 int nLengthDir = GetDirectory(NULL, 0);
621 if((pStr == NULL) || (nLengthDir == 0))
625 int nLengthTotal = nLengthDir + lstrlen(pStr);
630 nRet = nLengthTotal + 1;
632 else if (nBufLen > nLengthTotal)
634 GetDirectory(pBuffer, nBufLen);
635 SecureHelper::strcat_x(pBuffer, nBufLen, _T(
"\\"));
636 SecureHelper::strcat_x(pBuffer, nBufLen, pStr);
643 #if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) 644 bool GetFirstPathName(_CSTRING_NS::CString& strPath)
const 648 int nLength = GetFirstPathName(NULL, 0);
651 bRet = (GetFirstPathName(strPath.GetBuffer(nLength), nLength) > 0);
652 strPath.ReleaseBuffer(nLength - 1);
657 #endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) 664 int GetNextPathName(LPTSTR pBuffer,
int nBufLen)
const 666 if (m_pNextFile == NULL)
670 LPCTSTR pStr = m_pNextFile;
672 if (MinCrtHelper::_strrchr(pStr, _T(
'\\')) != NULL)
675 int nLength = lstrlen(pStr);
681 else if (nBufLen > nLength)
683 SecureHelper::strcpy_x(pBuffer, nBufLen, GetNextFileName());
690 int nLengthDir = GetDirectory(NULL, 0);
694 int nLengthTotal = nLengthDir + lstrlen(pStr);
698 nRet = nLengthTotal + 1;
700 else if (nBufLen > nLengthTotal)
702 GetDirectory(pBuffer, nBufLen);
703 SecureHelper::strcat_x(pBuffer, nBufLen, _T(
"\\"));
704 SecureHelper::strcat_x(pBuffer, nBufLen, GetNextFileName());
713 #if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) 714 bool GetNextPathName(_CSTRING_NS::CString& strPath)
const 718 int nLength = GetNextPathName(NULL, 0);
721 bRet = (GetNextPathName(strPath.GetBuffer(nLength), nLength) > 0);
722 strPath.ReleaseBuffer(nLength - 1);
727 #endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) 730 bool ResizeFilenameBuffer(DWORD dwLength)
732 if (dwLength > m_ofn.nMaxFile)
735 if (m_ofn.lpstrFile != m_szFileName)
737 delete[] m_ofn.lpstrFile;
738 m_ofn.lpstrFile = NULL;
743 LPTSTR lpstrBuff = NULL;
744 ATLTRY(lpstrBuff =
new TCHAR[dwLength]);
745 if (lpstrBuff != NULL)
747 m_ofn.lpstrFile = lpstrBuff;
748 m_ofn.lpstrFile[0] = 0;
749 m_ofn.nMaxFile = dwLength;
753 return (m_ofn.lpstrFile != NULL);
756 void OnSelChange(LPOFNOTIFY )
765 int nLength = GetSpec(NULL, 0);
770 nLength += GetFolderPath(NULL, 0) + 1;
772 if (!ResizeFilenameBuffer(nLength))
779 if ((m_ofn.Flags & OFN_NODEREFERENCELINKS) != 0)
783 if (GetSpec(m_ofn.lpstrFile, m_ofn.nMaxFile) <= 0)
787 int nBytes = GetFolderIDList(NULL, 0);
788 #ifdef STRICT_TYPED_ITEMIDS 793 idlist.AllocateBytes(nBytes);
794 if ((nBytes <= 0) || (GetFolderIDList(idlist, nBytes) <= 0))
798 ATL::CComPtr<IShellFolder> pDesktop, pFolder;
799 if (FAILED(::SHGetDesktopFolder(&pDesktop)))
801 if (FAILED(pDesktop->BindToObject(idlist, NULL, IID_IShellFolder, (
void**)&pFolder)))
806 DWORD nExtraChars = 0;
807 bool bInsideQuotes =
false;
808 LPCTSTR pAnchor = m_ofn.lpstrFile;
809 LPCTSTR pChar = m_ofn.lpstrFile;
810 for ( ; *pChar; ++pChar)
813 if (*pChar == _T(
'\"'))
816 bInsideQuotes = !bInsideQuotes;
827 if (pChar - pAnchor >= MAX_PATH)
832 int nFileNameLength = (int)(DWORD_PTR)(pChar - pAnchor);
833 TCHAR szFileName[MAX_PATH] = { 0 };
834 SecureHelper::strncpy_x(szFileName, MAX_PATH, pAnchor, nFileNameLength);
835 #ifdef STRICT_TYPED_ITEMIDS 836 PIDLIST_RELATIVE pidl = NULL;
838 LPITEMIDLIST pidl = NULL;
840 DWORD dwAttrib = SFGAO_LINK;
841 if (SUCCEEDED(pFolder->ParseDisplayName(NULL, NULL, T2W(szFileName), NULL, &pidl, &dwAttrib)))
844 if (dwAttrib & SFGAO_LINK)
847 ATL::CComPtr<IShellLink> pLink;
848 if (SUCCEEDED(pFolder->BindToObject(pidl, NULL, IID_IShellLink, (
void**)&pLink)))
851 TCHAR szPath[MAX_PATH] = { 0 };
852 if (SUCCEEDED(pLink->GetPath(szPath, MAX_PATH, NULL, 0)))
856 int nNewLength = lstrlen(szPath);
857 if (nNewLength > nFileNameLength)
858 nExtraChars += nNewLength - nFileNameLength;
864 ::CoTaskMemFree(pidl);
872 ATLVERIFY(ResizeFilenameBuffer(m_ofn.nMaxFile + nExtraChars));
880 LPCTSTR lpszDefExt = NULL,
881 LPCTSTR lpszFileName = NULL,
882 DWORD dwFlags = OFN_HIDEREADONLY,
883 LPCTSTR lpszFilter = NULL,
884 HWND hWndParent = NULL)
893 #endif // !_WIN32_WCE 904 #if (_WIN32_WINNT >= 0x0600) && !defined(_WIN32_WCE) 910 class ATL_NO_VTABLE CShellFileDialogImpl :
public IFileDialogEvents
914 INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow())
918 T* pT =
static_cast<T*
>(
this);
919 if(pT->m_spFileDlg == NULL)
926 pT->_Advise(dwCookie);
928 HRESULT hRet = pT->m_spFileDlg->Show(hWndParent);
931 else if(hRet == HRESULT_FROM_WIN32(ERROR_CANCELLED))
936 pT->_Unadvise(dwCookie);
943 const T* pT =
static_cast<const T*
>(
this);
944 return (pT->m_spFileDlg == NULL);
948 HRESULT GetFilePath(LPWSTR lpstrFilePath,
int cchLength)
950 T* pT =
static_cast<T*
>(
this);
951 ATLASSERT(pT->m_spFileDlg != NULL);
953 ATL::CComPtr<IShellItem> spItem;
954 HRESULT hRet = pT->m_spFileDlg->GetResult(&spItem);
957 hRet = GetFileNameFromShellItem(spItem, SIGDN_FILESYSPATH, lpstrFilePath, cchLength);
962 HRESULT GetFileTitle(LPWSTR lpstrFileTitle,
int cchLength)
964 T* pT =
static_cast<T*
>(
this);
965 ATLASSERT(pT->m_spFileDlg != NULL);
967 ATL::CComPtr<IShellItem> spItem;
968 HRESULT hRet = pT->m_spFileDlg->GetResult(&spItem);
971 hRet = GetFileNameFromShellItem(spItem, SIGDN_NORMALDISPLAY, lpstrFileTitle, cchLength);
976 #if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) 977 HRESULT GetFilePath(_CSTRING_NS::CString& strFilePath)
979 T* pT =
static_cast<T*
>(
this);
980 ATLASSERT(pT->m_spFileDlg != NULL);
982 ATL::CComPtr<IShellItem> spItem;
983 HRESULT hRet = pT->m_spFileDlg->GetResult(&spItem);
986 hRet = GetFileNameFromShellItem(spItem, SIGDN_FILESYSPATH, strFilePath);
991 HRESULT GetFileTitle(_CSTRING_NS::CString& strFileTitle)
993 T* pT =
static_cast<T*
>(
this);
994 ATLASSERT(pT->m_spFileDlg != NULL);
996 ATL::CComPtr<IShellItem> spItem;
997 HRESULT hRet = pT->m_spFileDlg->GetResult(&spItem);
1000 hRet = GetFileNameFromShellItem(spItem, SIGDN_NORMALDISPLAY, strFileTitle);
1004 #endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) 1007 static HRESULT GetFileNameFromShellItem(IShellItem* pShellItem, SIGDN type, LPWSTR lpstr,
int cchLength)
1009 ATLASSERT(pShellItem != NULL);
1011 LPWSTR lpstrName = NULL;
1012 HRESULT hRet = pShellItem->GetDisplayName(type, &lpstrName);
1016 if(lstrlenW(lpstrName) < cchLength)
1018 SecureHelper::strcpyW_x(lpstr, cchLength, lpstrName);
1023 hRet = DISP_E_BUFFERTOOSMALL;
1026 ::CoTaskMemFree(lpstrName);
1032 #if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) 1033 static HRESULT GetFileNameFromShellItem(IShellItem* pShellItem, SIGDN type, _CSTRING_NS::CString& str)
1035 ATLASSERT(pShellItem != NULL);
1037 LPWSTR lpstrName = NULL;
1038 HRESULT hRet = pShellItem->GetDisplayName(type, &lpstrName);
1043 ::CoTaskMemFree(lpstrName);
1048 #endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) 1051 void _Advise(DWORD& dwCookie)
1053 T* pT =
static_cast<T*
>(
this);
1054 ATLASSERT(pT->m_spFileDlg != NULL);
1055 HRESULT hRet = pT->m_spFileDlg->Advise((IFileDialogEvents*)
this, &dwCookie);
1056 ATLVERIFY(SUCCEEDED(hRet));
1059 void _Unadvise(DWORD dwCookie)
1061 T* pT =
static_cast<T*
>(
this);
1062 ATLASSERT(pT->m_spFileDlg != NULL);
1063 HRESULT hRet = pT->m_spFileDlg->Unadvise(dwCookie);
1064 ATLVERIFY(SUCCEEDED(hRet));
1067 void _Init(LPCWSTR lpszFileName, DWORD dwOptions, LPCWSTR lpszDefExt,
const COMDLG_FILTERSPEC* arrFilterSpec, UINT uFilterSpecCount)
1069 T* pT =
static_cast<T*
>(
this);
1070 ATLASSERT(pT->m_spFileDlg != NULL);
1072 HRESULT hRet = E_FAIL;
1074 if(lpszFileName != NULL)
1076 hRet = pT->m_spFileDlg->SetFileName(lpszFileName);
1077 ATLASSERT(SUCCEEDED(hRet));
1080 hRet = pT->m_spFileDlg->SetOptions(dwOptions);
1081 ATLASSERT(SUCCEEDED(hRet));
1083 if(lpszDefExt != NULL)
1085 hRet = pT->m_spFileDlg->SetDefaultExtension(lpszDefExt);
1086 ATLASSERT(SUCCEEDED(hRet));
1089 if(arrFilterSpec != NULL && uFilterSpecCount != 0U)
1091 hRet = pT->m_spFileDlg->SetFileTypes(uFilterSpecCount, arrFilterSpec);
1092 ATLASSERT(SUCCEEDED(hRet));
1097 STDMETHOD(QueryInterface)(REFIID riid,
void** ppvObject)
1099 if(ppvObject == NULL)
1102 T* pT =
static_cast<T*
>(
this);
1103 if(IsEqualGUID(riid, IID_IUnknown) || IsEqualGUID(riid, IID_IFileDialogEvents))
1105 *ppvObject = (IFileDialogEvents*)pT;
1110 return E_NOINTERFACE;
1113 virtual ULONG STDMETHODCALLTYPE AddRef()
1118 virtual ULONG STDMETHODCALLTYPE Release()
1124 virtual HRESULT STDMETHODCALLTYPE IFileDialogEvents::OnFileOk(IFileDialog* pfd)
1126 T* pT =
static_cast<T*
>(
this);
1127 ATLASSERT(pT->m_spFileDlg.IsEqualObject(pfd));
1129 return pT->OnFileOk();
1132 virtual HRESULT STDMETHODCALLTYPE IFileDialogEvents::OnFolderChanging(IFileDialog* pfd, IShellItem* psiFolder)
1134 T* pT =
static_cast<T*
>(
this);
1135 ATLASSERT(pT->m_spFileDlg.IsEqualObject(pfd));
1137 return pT->OnFolderChanging(psiFolder);
1140 virtual HRESULT STDMETHODCALLTYPE IFileDialogEvents::OnFolderChange(IFileDialog* pfd)
1142 T* pT =
static_cast<T*
>(
this);
1143 ATLASSERT(pT->m_spFileDlg.IsEqualObject(pfd));
1145 return pT->OnFolderChange();
1148 virtual HRESULT STDMETHODCALLTYPE IFileDialogEvents::OnSelectionChange(IFileDialog* pfd)
1150 T* pT =
static_cast<T*
>(
this);
1151 ATLASSERT(pT->m_spFileDlg.IsEqualObject(pfd));
1153 return pT->OnSelectionChange();
1156 virtual HRESULT STDMETHODCALLTYPE IFileDialogEvents::OnShareViolation(IFileDialog* pfd, IShellItem* psi, FDE_SHAREVIOLATION_RESPONSE* pResponse)
1158 T* pT =
static_cast<T*
>(
this);
1159 ATLASSERT(pT->m_spFileDlg.IsEqualObject(pfd));
1161 return pT->OnShareViolation(psi, pResponse);
1164 virtual HRESULT STDMETHODCALLTYPE IFileDialogEvents::OnTypeChange(IFileDialog* pfd)
1166 T* pT =
static_cast<T*
>(
this);
1167 ATLASSERT(pT->m_spFileDlg.IsEqualObject(pfd));
1169 return pT->OnTypeChange();
1172 virtual HRESULT STDMETHODCALLTYPE IFileDialogEvents::OnOverwrite(IFileDialog* pfd, IShellItem* psi, FDE_OVERWRITE_RESPONSE* pResponse)
1174 T* pT =
static_cast<T*
>(
this);
1175 ATLASSERT(pT->m_spFileDlg.IsEqualObject(pfd));
1177 return pT->OnOverwrite(psi, pResponse);
1186 HRESULT OnFolderChanging(IShellItem* )
1191 HRESULT OnFolderChange()
1196 HRESULT OnSelectionChange()
1201 HRESULT OnShareViolation(IShellItem* , FDE_SHAREVIOLATION_RESPONSE* )
1206 HRESULT OnTypeChange()
1211 HRESULT OnOverwrite(IShellItem* , FDE_OVERWRITE_RESPONSE* )
1222 class ATL_NO_VTABLE CShellFileOpenDialogImpl :
public CShellFileDialogImpl< T >
1225 ATL::CComPtr<IFileOpenDialog> m_spFileDlg;
1227 CShellFileOpenDialogImpl(LPCWSTR lpszFileName = NULL,
1228 DWORD dwOptions = FOS_FORCEFILESYSTEM | FOS_PATHMUSTEXIST | FOS_FILEMUSTEXIST,
1229 LPCWSTR lpszDefExt = NULL,
1230 const COMDLG_FILTERSPEC* arrFilterSpec = NULL,
1231 UINT uFilterSpecCount = 0U)
1233 HRESULT hRet = m_spFileDlg.CoCreateInstance(CLSID_FileOpenDialog);
1236 _Init(lpszFileName, dwOptions, lpszDefExt, arrFilterSpec, uFilterSpecCount);
1239 IFileOpenDialog* GetPtr()
1249 class CShellFileOpenDialog :
public CShellFileOpenDialogImpl<CShellFileOpenDialog>
1252 CShellFileOpenDialog(LPCWSTR lpszFileName = NULL,
1253 DWORD dwOptions = FOS_FORCEFILESYSTEM | FOS_PATHMUSTEXIST | FOS_FILEMUSTEXIST,
1254 LPCWSTR lpszDefExt = NULL,
1255 const COMDLG_FILTERSPEC* arrFilterSpec = NULL,
1256 UINT uFilterSpecCount = 0U) : CShellFileOpenDialogImpl<CShellFileOpenDialog>(lpszFileName, dwOptions, lpszDefExt, arrFilterSpec, uFilterSpecCount)
1260 void _Advise(DWORD& )
1263 void _Unadvise(DWORD )
1272 class ATL_NO_VTABLE CShellFileSaveDialogImpl :
public CShellFileDialogImpl< T >
1275 ATL::CComPtr<IFileSaveDialog> m_spFileDlg;
1277 CShellFileSaveDialogImpl(LPCWSTR lpszFileName = NULL,
1278 DWORD dwOptions = FOS_FORCEFILESYSTEM | FOS_PATHMUSTEXIST | FOS_OVERWRITEPROMPT,
1279 LPCWSTR lpszDefExt = NULL,
1280 const COMDLG_FILTERSPEC* arrFilterSpec = NULL,
1281 UINT uFilterSpecCount = 0U)
1283 HRESULT hRet = m_spFileDlg.CoCreateInstance(CLSID_FileSaveDialog);
1286 _Init(lpszFileName, dwOptions, lpszDefExt, arrFilterSpec, uFilterSpecCount);
1289 IFileSaveDialog* GetPtr()
1299 class CShellFileSaveDialog :
public CShellFileSaveDialogImpl<CShellFileSaveDialog>
1302 CShellFileSaveDialog(LPCWSTR lpszFileName = NULL,
1303 DWORD dwOptions = FOS_FORCEFILESYSTEM | FOS_PATHMUSTEXIST | FOS_OVERWRITEPROMPT,
1304 LPCWSTR lpszDefExt = NULL,
1305 const COMDLG_FILTERSPEC* arrFilterSpec = NULL,
1306 UINT uFilterSpecCount = 0U) : CShellFileSaveDialogImpl<CShellFileSaveDialog>(lpszFileName, dwOptions, lpszDefExt, arrFilterSpec, uFilterSpecCount)
1310 void _Advise(DWORD& )
1313 void _Unadvise(DWORD )
1317 #endif // (_WIN32_WINNT >= 0x0600) && !defined(_WIN32_WCE) 1330 LPCTSTR m_lpstrInitialFolder;
1331 LPCITEMIDLIST m_pidlInitialSelection;
1332 bool m_bExpandInitialSelection;
1333 TCHAR m_szFolderDisplayName[MAX_PATH];
1334 TCHAR m_szFolderPath[MAX_PATH];
1335 #ifdef STRICT_TYPED_ITEMIDS 1336 PIDLIST_ABSOLUTE m_pidlSelected;
1338 LPITEMIDLIST m_pidlSelected;
1343 CFolderDialogImpl(HWND hWndParent = NULL, LPCTSTR lpstrTitle = NULL, UINT uFlags = BIF_RETURNONLYFSDIRS) :
1344 m_lpstrInitialFolder(NULL), m_pidlInitialSelection(NULL), m_bExpandInitialSelection(
false), m_pidlSelected(NULL), m_hWnd(NULL)
1346 memset(&m_bi, 0,
sizeof(m_bi));
1348 m_bi.hwndOwner = hWndParent;
1349 m_bi.pidlRoot = NULL;
1350 m_bi.pszDisplayName = m_szFolderDisplayName;
1351 m_bi.lpszTitle = lpstrTitle;
1352 m_bi.ulFlags = uFlags;
1353 m_bi.lpfn = BrowseCallbackProc;
1354 m_bi.lParam = (LPARAM)static_cast<T*>(
this);
1356 m_szFolderPath[0] = 0;
1357 m_szFolderDisplayName[0] = 0;
1362 ::CoTaskMemFree(m_pidlSelected);
1366 INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow())
1368 if(m_bi.hwndOwner == NULL)
1369 m_bi.hwndOwner = hWndParent;
1372 m_szFolderPath[0] = 0;
1373 m_szFolderDisplayName[0] = 0;
1374 ::CoTaskMemFree(m_pidlSelected);
1376 INT_PTR nRet = IDCANCEL;
1377 m_pidlSelected = ::SHBrowseForFolder(&m_bi);
1379 if(m_pidlSelected != NULL)
1385 if((m_bi.ulFlags & BIF_RETURNONLYFSDIRS) != 0)
1387 if(::SHGetPathFromIDList(m_pidlSelected, m_szFolderPath) == FALSE)
1396 void SetInitialFolder(LPCTSTR lpstrInitialFolder,
bool bExpand =
true)
1399 m_lpstrInitialFolder = lpstrInitialFolder;
1400 m_bExpandInitialSelection = bExpand;
1403 void SetInitialSelection(LPCITEMIDLIST pidl,
bool bExpand =
true)
1405 m_pidlInitialSelection = pidl;
1406 m_bExpandInitialSelection = bExpand;
1409 #ifdef STRICT_TYPED_ITEMIDS 1410 void SetRootFolder(PCIDLIST_ABSOLUTE pidl)
1412 void SetRootFolder(LPCITEMIDLIST pidl)
1415 m_bi.pidlRoot = pidl;
1419 LPITEMIDLIST GetSelectedItem(
bool bDetach =
false)
1421 LPITEMIDLIST pidl = m_pidlSelected;
1423 m_pidlSelected = NULL;
1428 LPCTSTR GetFolderPath()
const 1430 return m_szFolderPath;
1433 LPCTSTR GetFolderDisplayName()
const 1435 return m_szFolderDisplayName;
1438 int GetFolderImageIndex()
const 1444 static int CALLBACK BrowseCallbackProc(HWND hWnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
1446 #ifndef BFFM_VALIDATEFAILED 1448 const int BFFM_VALIDATEFAILED = 4;
1450 const int BFFM_VALIDATEFAILED = 3;
1452 #endif // !BFFM_VALIDATEFAILED 1453 #ifndef BFFM_IUNKNOWN 1454 const int BFFM_IUNKNOWN = 5;
1455 #endif // !BFFM_IUNKNOWN 1456 #ifndef BIF_NEWDIALOGSTYLE 1457 const UINT BIF_NEWDIALOGSTYLE = 0x0040;
1458 #endif // !BIF_NEWDIALOGSTYLE 1462 bool bClear =
false;
1463 if(pT->m_hWnd == NULL)
1470 ATLASSERT(pT->m_hWnd == hWnd);
1475 case BFFM_INITIALIZED:
1478 if(pT->m_pidlInitialSelection != NULL)
1479 pT->SetSelection(pT->m_pidlInitialSelection);
1480 else if(pT->m_lpstrInitialFolder != NULL)
1481 pT->SetSelection(pT->m_lpstrInitialFolder);
1484 if(pT->m_bExpandInitialSelection && ((pT->m_bi.ulFlags & BIF_NEWDIALOGSTYLE) != 0))
1486 if(pT->m_pidlInitialSelection != NULL)
1487 pT->SetExpanded(pT->m_pidlInitialSelection);
1488 else if(pT->m_lpstrInitialFolder != NULL)
1489 pT->SetExpanded(pT->m_lpstrInitialFolder);
1491 pT->OnInitialized();
1493 case BFFM_SELCHANGED:
1494 pT->OnSelChanged((LPITEMIDLIST)lParam);
1496 case BFFM_VALIDATEFAILED:
1497 nRet = pT->OnValidateFailed((LPCTSTR)lParam);
1500 pT->OnIUnknown((IUnknown*)lParam);
1503 ATLTRACE2(atlTraceUI, 0, _T(
"Unknown message received in CFolderDialogImpl::BrowseCallbackProc\n"));
1512 void OnInitialized()
1516 void OnSelChanged(LPITEMIDLIST )
1520 int OnValidateFailed(LPCTSTR )
1525 void OnIUnknown(IUnknown* )
1530 void EnableOK(BOOL bEnable)
1532 ATLASSERT(m_hWnd != NULL);
1533 ::SendMessage(m_hWnd, BFFM_ENABLEOK, 0, bEnable);
1536 void SetSelection(LPCITEMIDLIST pItemIDList)
1538 ATLASSERT(m_hWnd != NULL);
1539 ::SendMessage(m_hWnd, BFFM_SETSELECTION, FALSE, (LPARAM)pItemIDList);
1542 void SetSelection(LPCTSTR lpstrFolderPath)
1544 ATLASSERT(m_hWnd != NULL);
1545 ::SendMessage(m_hWnd, BFFM_SETSELECTION, TRUE, (LPARAM)lpstrFolderPath);
1548 void SetStatusText(LPCTSTR lpstrText)
1550 ATLASSERT(m_hWnd != NULL);
1551 ::SendMessage(m_hWnd, BFFM_SETSTATUSTEXT, 0, (LPARAM)lpstrText);
1554 void SetOKText(LPCTSTR lpstrOKText)
1556 #ifndef BFFM_SETOKTEXT 1557 const UINT BFFM_SETOKTEXT = WM_USER + 105;
1559 ATLASSERT(m_hWnd != NULL);
1561 LPCWSTR lpstr = T2CW(lpstrOKText);
1562 ::SendMessage(m_hWnd, BFFM_SETOKTEXT, 0, (LPARAM)lpstr);
1565 void SetExpanded(LPCITEMIDLIST pItemIDList)
1567 #ifndef BFFM_SETEXPANDED 1568 const UINT BFFM_SETEXPANDED = WM_USER + 106;
1570 ATLASSERT(m_hWnd != NULL);
1571 ::SendMessage(m_hWnd, BFFM_SETEXPANDED, FALSE, (LPARAM)pItemIDList);
1574 void SetExpanded(LPCTSTR lpstrFolderPath)
1576 #ifndef BFFM_SETEXPANDED 1577 const UINT BFFM_SETEXPANDED = WM_USER + 106;
1579 ATLASSERT(m_hWnd != NULL);
1581 LPCWSTR lpstr = T2CW(lpstrFolderPath);
1582 ::SendMessage(m_hWnd, BFFM_SETEXPANDED, TRUE, (LPARAM)lpstr);
1589 CFolderDialog(HWND hWndParent = NULL, LPCTSTR lpstrTitle = NULL, UINT uFlags = BIF_RETURNONLYFSDIRS)
1594 #endif // !_WIN32_WCE 1603 static UINT_PTR APIENTRY HookProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1605 if(uMsg != WM_INITDIALOG)
1608 ATLASSERT(pT != NULL);
1609 ATLASSERT(pT->m_hWnd == NULL);
1610 ATLASSERT(::IsWindow(hWnd));
1612 if(!pT->SubclassWindow(hWnd))
1614 ATLTRACE2(atlTraceUI, 0, _T(
"Subclassing a common dialog failed\n"));
1619 if(pT->ProcessWindowMessage(pT->m_hWnd, uMsg, wParam, lParam, lRes, 0) == FALSE)
1625 BOOL EndDialog(INT_PTR = 0)
1627 ATLASSERT(::IsWindow(m_hWnd));
1628 SendMessage(WM_COMMAND, MAKEWPARAM(IDABORT, 0));
1639 static LRESULT CALLBACK StartWindowProc(HWND , UINT , WPARAM , LPARAM )
1656 enum { _cchStyleName = 64 };
1659 TCHAR m_szStyleName[_cchStyleName];
1664 DWORD dwFlags = CF_EFFECTS | CF_SCREENFONTS,
1665 HDC hDCPrinter = NULL,
1666 HWND hWndParent = NULL)
1668 memset(&m_cf, 0,
sizeof(m_cf));
1669 memset(&m_lf, 0,
sizeof(m_lf));
1670 memset(&m_szStyleName, 0,
sizeof(m_szStyleName));
1672 m_cf.lStructSize =
sizeof(m_cf);
1673 m_cf.hwndOwner = hWndParent;
1674 m_cf.rgbColors = RGB(0, 0, 0);
1675 m_cf.lpszStyle = (LPTSTR)&m_szStyleName;
1676 m_cf.Flags = dwFlags | CF_ENABLEHOOK;
1677 m_cf.lpfnHook = (LPCFHOOKPROC)T::HookProc;
1679 if(lplfInitial != NULL)
1681 m_cf.lpLogFont = lplfInitial;
1682 m_cf.Flags |= CF_INITTOLOGFONTSTRUCT;
1683 m_lf = *lplfInitial;
1687 m_cf.lpLogFont = &m_lf;
1690 if(hDCPrinter != NULL)
1692 m_cf.hDC = hDCPrinter;
1693 m_cf.Flags |= CF_PRINTERFONTS;
1698 INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow())
1700 ATLASSERT((m_cf.Flags & CF_ENABLEHOOK) != 0);
1701 ATLASSERT(m_cf.lpfnHook != NULL);
1703 if(m_cf.hwndOwner == NULL)
1704 m_cf.hwndOwner = hWndParent;
1706 ATLASSERT(m_hWnd == NULL);
1708 #if (_ATL_VER >= 0x0800) 1710 BOOL bRetTh = m_thunk.Init(NULL, NULL);
1713 ::SetLastError(ERROR_OUTOFMEMORY);
1716 #endif // (_ATL_VER >= 0x0800) 1720 BOOL bRet = ::ChooseFont(&m_cf);
1725 SecureHelper::memcpy_x(&m_lf,
sizeof(m_lf), m_cf.lpLogFont,
sizeof(m_lf));
1727 return bRet ? IDOK : IDCANCEL;
1731 void GetCurrentFont(LPLOGFONT lplf)
const 1733 ATLASSERT(lplf != NULL);
1736 ::SendMessage(m_hWnd, WM_CHOOSEFONT_GETLOGFONT, 0, (LPARAM)lplf);
1743 void SetLogFont(LPLOGFONT lplf)
1745 ATLASSERT(lplf != NULL);
1746 #ifndef WM_CHOOSEFONT_SETLOGFONT 1747 const UINT WM_CHOOSEFONT_SETLOGFONT = (WM_USER + 101);
1751 ::SendMessage(m_hWnd, WM_CHOOSEFONT_SETLOGFONT, 0, (LPARAM)lplf);
1756 m_cf.Flags |= CF_INITTOLOGFONTSTRUCT;
1760 void SetFlags(DWORD dwFlags)
1762 #ifndef WM_CHOOSEFONT_SETFLAGS 1763 const UINT WM_CHOOSEFONT_SETFLAGS = (WM_USER + 102);
1767 CHOOSEFONT cf = {
sizeof(CHOOSEFONT) };
1769 ::SendMessage(m_hWnd, WM_CHOOSEFONT_SETFLAGS, 0, (LPARAM)&cf);
1773 m_cf.Flags = dwFlags;
1776 #endif // !_WIN32_WCE 1779 LPCTSTR GetFaceName()
const 1781 return (LPCTSTR)m_cf.lpLogFont->lfFaceName;
1784 LPCTSTR GetStyleName()
const 1786 return m_cf.lpszStyle;
1791 return m_cf.iPointSize;
1794 COLORREF GetColor()
const 1796 return m_cf.rgbColors;
1799 int GetWeight()
const 1801 return (
int)m_cf.lpLogFont->lfWeight;
1804 BOOL IsStrikeOut()
const 1806 return (m_cf.lpLogFont->lfStrikeOut) ? TRUE : FALSE;
1809 BOOL IsUnderline()
const 1811 return (m_cf.lpLogFont->lfUnderline) ? TRUE : FALSE;
1816 return (m_cf.lpLogFont->lfWeight == FW_BOLD) ? TRUE : FALSE;
1819 BOOL IsItalic()
const 1821 return m_cf.lpLogFont->lfItalic ? TRUE : FALSE;
1829 DWORD dwFlags = CF_EFFECTS | CF_SCREENFONTS,
1830 HDC hDCPrinter = NULL,
1831 HWND hWndParent = NULL)
1835 DECLARE_EMPTY_MSG_MAP()
1838 #endif // _WIN32_WCE 1844 #if defined(_RICHEDIT_) && !defined(_WIN32_WCE) 1847 class ATL_NO_VTABLE CRichEditFontDialogImpl :
public CFontDialogImpl< T >
1850 CRichEditFontDialogImpl(
const CHARFORMAT& charformat,
1851 DWORD dwFlags = CF_SCREENFONTS,
1852 HDC hDCPrinter = NULL,
1853 HWND hWndParent = NULL)
1856 m_cf.Flags |= CF_INITTOLOGFONTSTRUCT;
1857 m_cf.Flags |= FillInLogFont(charformat);
1858 m_cf.lpLogFont = &m_lf;
1860 if((charformat.dwMask & CFM_COLOR) != 0)
1861 m_cf.rgbColors = charformat.crTextColor;
1864 void GetCharFormat(CHARFORMAT& cf)
const 1869 if((m_cf.Flags & CF_NOSTYLESEL) == 0)
1871 cf.dwMask |= CFM_BOLD | CFM_ITALIC;
1872 cf.dwEffects |= IsBold() ? CFE_BOLD : 0;
1873 cf.dwEffects |= IsItalic() ? CFE_ITALIC : 0;
1875 if((m_cf.Flags & CF_NOSIZESEL) == 0)
1877 cf.dwMask |= CFM_SIZE;
1879 cf.yHeight = GetSize() * 2;
1882 if((m_cf.Flags & CF_NOFACESEL) == 0)
1884 cf.dwMask |= CFM_FACE;
1885 cf.bPitchAndFamily = m_cf.lpLogFont->lfPitchAndFamily;
1886 #if (_RICHEDIT_VER >= 0x0200) 1887 SecureHelper::strcpy_x(cf.szFaceName, _countof(cf.szFaceName), GetFaceName());
1888 #else // !(_RICHEDIT_VER >= 0x0200) 1889 SecureHelper::strcpyA_x(cf.szFaceName, _countof(cf.szFaceName), T2A((LPTSTR)(LPCTSTR)GetFaceName()));
1890 #endif // !(_RICHEDIT_VER >= 0x0200) 1893 if((m_cf.Flags & CF_EFFECTS) != 0)
1895 cf.dwMask |= CFM_UNDERLINE | CFM_STRIKEOUT | CFM_COLOR;
1896 cf.dwEffects |= IsUnderline() ? CFE_UNDERLINE : 0;
1897 cf.dwEffects |= IsStrikeOut() ? CFE_STRIKEOUT : 0;
1898 cf.crTextColor = GetColor();
1900 if((m_cf.Flags & CF_NOSCRIPTSEL) == 0)
1902 cf.bCharSet = m_cf.lpLogFont->lfCharSet;
1903 cf.dwMask |= CFM_CHARSET;
1908 DWORD FillInLogFont(
const CHARFORMAT& cf)
1912 if((cf.dwMask & CFM_SIZE) != 0)
1914 HDC hDC = ::CreateDC(_T(
"DISPLAY"), NULL, NULL, NULL);
1915 LONG yPerInch = ::GetDeviceCaps(hDC, LOGPIXELSY);
1916 m_lf.lfHeight = -(int)((cf.yHeight * yPerInch) / 1440);
1922 m_lf.lfEscapement = 0;
1923 m_lf.lfOrientation = 0;
1925 if((cf.dwMask & (CFM_ITALIC | CFM_BOLD)) == (CFM_ITALIC | CFM_BOLD))
1927 m_lf.lfWeight = ((cf.dwEffects & CFE_BOLD) != 0) ? FW_BOLD : FW_NORMAL;
1928 m_lf.lfItalic = (BYTE)(((cf.dwEffects & CFE_ITALIC) != 0) ? TRUE : FALSE);
1932 dwFlags |= CF_NOSTYLESEL;
1933 m_lf.lfWeight = FW_DONTCARE;
1934 m_lf.lfItalic = FALSE;
1937 if((cf.dwMask & (CFM_UNDERLINE | CFM_STRIKEOUT | CFM_COLOR)) == (CFM_UNDERLINE|CFM_STRIKEOUT|CFM_COLOR))
1939 dwFlags |= CF_EFFECTS;
1940 m_lf.lfUnderline = (BYTE)(((cf.dwEffects & CFE_UNDERLINE) != 0) ? TRUE : FALSE);
1941 m_lf.lfStrikeOut = (BYTE)(((cf.dwEffects & CFE_STRIKEOUT) != 0) ? TRUE : FALSE);
1945 m_lf.lfUnderline = (BYTE)FALSE;
1946 m_lf.lfStrikeOut = (BYTE)FALSE;
1949 if((cf.dwMask & CFM_CHARSET) != 0)
1950 m_lf.lfCharSet = cf.bCharSet;
1952 dwFlags |= CF_NOSCRIPTSEL;
1953 m_lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
1954 m_lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
1955 m_lf.lfQuality = DEFAULT_QUALITY;
1956 if((cf.dwMask & CFM_FACE) != 0)
1958 m_lf.lfPitchAndFamily = cf.bPitchAndFamily;
1959 #if (_RICHEDIT_VER >= 0x0200) 1960 SecureHelper::strcpy_x(m_lf.lfFaceName, _countof(m_lf.lfFaceName), cf.szFaceName);
1961 #else // !(_RICHEDIT_VER >= 0x0200) 1962 SecureHelper::strcpy_x(m_lf.lfFaceName, _countof(m_lf.lfFaceName), A2T((LPSTR)cf.szFaceName));
1963 #endif // !(_RICHEDIT_VER >= 0x0200) 1967 m_lf.lfPitchAndFamily = DEFAULT_PITCH|FF_DONTCARE;
1968 m_lf.lfFaceName[0] = (TCHAR)0;
1974 class CRichEditFontDialog :
public CRichEditFontDialogImpl<CRichEditFontDialog>
1977 CRichEditFontDialog(
const CHARFORMAT& charformat,
1978 DWORD dwFlags = CF_SCREENFONTS,
1979 HDC hDCPrinter = NULL,
1980 HWND hWndParent = NULL)
1981 : CRichEditFontDialogImpl<CRichEditFontDialog>(charformat, dwFlags, hDCPrinter, hWndParent)
1984 DECLARE_EMPTY_MSG_MAP()
1987 #endif // defined(_RICHEDIT_) && !defined(_WIN32_WCE) 1993 #if !defined(_WIN32_WCE) || ((_WIN32_WCE > 420) && !(defined(WIN32_PLATFORM_WFSP) && (_WIN32_WCE > 0x0500))) 1996 #pragma comment(lib, "commdlg.lib") 1998 #ifndef SETRGBSTRING 1999 #define SETRGBSTRING _T("commdlg_SetRGBColor") 2002 #ifndef COLOROKSTRING 2003 #define COLOROKSTRING _T("commdlg_ColorOK") 2014 CColorDialogImpl(COLORREF clrInit = 0, DWORD dwFlags = 0, HWND hWndParent = NULL)
2016 memset(&m_cc, 0,
sizeof(m_cc));
2018 m_cc.lStructSize =
sizeof(m_cc);
2019 m_cc.lpCustColors = GetCustomColors();
2020 m_cc.hwndOwner = hWndParent;
2021 m_cc.Flags = dwFlags | CC_ENABLEHOOK;
2022 m_cc.lpfnHook = (LPCCHOOKPROC)T::HookProc;
2026 m_cc.rgbResult = clrInit;
2027 m_cc.Flags |= CC_RGBINIT;
2032 INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow())
2034 ATLASSERT((m_cc.Flags & CC_ENABLEHOOK) != 0);
2035 ATLASSERT(m_cc.lpfnHook != NULL);
2037 if(m_cc.hwndOwner == NULL)
2038 m_cc.hwndOwner = hWndParent;
2040 ATLASSERT(m_hWnd == NULL);
2042 #if (_ATL_VER >= 0x0800) 2044 BOOL bRetTh = m_thunk.Init(NULL, NULL);
2047 ::SetLastError(ERROR_OUTOFMEMORY);
2050 #endif // (_ATL_VER >= 0x0800) 2054 BOOL bRet = ::ChooseColor(&m_cc);
2058 return bRet ? IDOK : IDCANCEL;
2062 void SetCurrentColor(COLORREF clr)
2064 ATLASSERT(::IsWindow(m_hWnd));
2065 SendMessage(_GetSetRGBMessage(), 0, (LPARAM)clr);
2069 COLORREF GetColor()
const 2071 return m_cc.rgbResult;
2075 static UINT_PTR APIENTRY HookProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
2077 if(uMsg != WM_INITDIALOG && uMsg != _GetColorOKMessage())
2080 LPCHOOSECOLOR lpCC = (LPCHOOSECOLOR)lParam;
2083 if(uMsg == WM_INITDIALOG)
2086 lpCC->lCustData = (LPARAM)pT;
2087 ATLASSERT(pT != NULL);
2088 ATLASSERT(pT->m_hWnd == NULL);
2089 ATLASSERT(::IsWindow(hWnd));
2091 if(!pT->SubclassWindow(hWnd))
2093 ATLTRACE2(atlTraceUI, 0, _T(
"Subclassing a Color common dialog failed\n"));
2097 else if(uMsg == _GetColorOKMessage())
2100 ATLASSERT(pT != NULL);
2101 ATLASSERT(::IsWindow(pT->m_hWnd));
2111 if(pT->ProcessWindowMessage(pT->m_hWnd, uMsg, wParam, lParam, lRes, 0) == FALSE)
2118 static COLORREF* GetCustomColors()
2120 static COLORREF rgbCustomColors[16] =
2122 RGB(255, 255, 255), RGB(255, 255, 255),
2123 RGB(255, 255, 255), RGB(255, 255, 255),
2124 RGB(255, 255, 255), RGB(255, 255, 255),
2125 RGB(255, 255, 255), RGB(255, 255, 255),
2126 RGB(255, 255, 255), RGB(255, 255, 255),
2127 RGB(255, 255, 255), RGB(255, 255, 255),
2128 RGB(255, 255, 255), RGB(255, 255, 255),
2129 RGB(255, 255, 255), RGB(255, 255, 255),
2132 return rgbCustomColors;
2135 static UINT _GetSetRGBMessage()
2137 static UINT uSetRGBMessage = 0;
2138 if(uSetRGBMessage == 0)
2141 if(FAILED(lock.Lock()))
2143 ATLTRACE2(atlTraceUI, 0, _T(
"ERROR : Unable to lock critical section in CColorDialogImpl::_GetSetRGBMessage.\n"));
2148 if(uSetRGBMessage == 0)
2149 uSetRGBMessage = ::RegisterWindowMessage(SETRGBSTRING);
2153 ATLASSERT(uSetRGBMessage != 0);
2154 return uSetRGBMessage;
2157 static UINT _GetColorOKMessage()
2159 static UINT uColorOKMessage = 0;
2160 if(uColorOKMessage == 0)
2163 if(FAILED(lock.Lock()))
2165 ATLTRACE2(atlTraceUI, 0, _T(
"ERROR : Unable to lock critical section in CColorDialogImpl::_GetColorOKMessage.\n"));
2170 if(uColorOKMessage == 0)
2171 uColorOKMessage = ::RegisterWindowMessage(COLOROKSTRING);
2175 ATLASSERT(uColorOKMessage != 0);
2176 return uColorOKMessage;
2181 MESSAGE_HANDLER(_GetColorOKMessage(), _OnColorOK)
2184 LRESULT _OnColorOK(UINT, WPARAM, LPARAM, BOOL&)
2186 T* pT =
static_cast<T*
>(
this);
2187 return pT->OnColorOK();
2200 CColorDialog(COLORREF clrInit = 0, DWORD dwFlags = 0, HWND hWndParent = NULL)
2205 DECLARE_EMPTY_MSG_MAP()
2208 #endif // !defined(_WIN32_WCE) || ((_WIN32_WCE > 420) && !(defined(WIN32_PLATFORM_WFSP) && (_WIN32_WCE > 0x0500))) 2217 static inline HDC _AtlCreateDC(HGLOBAL hDevNames, HGLOBAL hDevMode)
2219 if(hDevNames == NULL)
2222 LPDEVNAMES lpDevNames = (LPDEVNAMES)::GlobalLock(hDevNames);
2223 LPDEVMODE lpDevMode = (hDevMode != NULL) ? (LPDEVMODE)::GlobalLock(hDevMode) : NULL;
2225 if(lpDevNames == NULL)
2228 HDC hDC = ::CreateDC((LPCTSTR)lpDevNames + lpDevNames->wDriverOffset,
2229 (LPCTSTR)lpDevNames + lpDevNames->wDeviceOffset,
2230 (LPCTSTR)lpDevNames + lpDevNames->wOutputOffset,
2233 ::GlobalUnlock(hDevNames);
2234 if(hDevMode != NULL)
2235 ::GlobalUnlock(hDevMode);
2239 #pragma warning(push) 2240 #pragma warning(disable: 4512) // assignment operator could not be generated 2251 DWORD dwFlags = PD_ALLPAGES | PD_USEDEVMODECOPIES | PD_NOPAGENUMS | PD_NOSELECTION,
2252 HWND hWndParent = NULL)
2255 memset(&m_pdActual, 0,
sizeof(m_pdActual));
2257 m_pd.lStructSize =
sizeof(m_pdActual);
2258 m_pd.hwndOwner = hWndParent;
2259 m_pd.Flags = (dwFlags | PD_ENABLEPRINTHOOK | PD_ENABLESETUPHOOK);
2260 m_pd.lpfnPrintHook = (LPPRINTHOOKPROC)T::HookProc;
2261 m_pd.lpfnSetupHook = (LPSETUPHOOKPROC)T::HookProc;
2264 m_pd.Flags |= PD_PRINTSETUP;
2266 m_pd.Flags |= PD_RETURNDC;
2268 m_pd.Flags &= ~PD_RETURNIC;
2272 INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow())
2274 ATLASSERT((m_pd.Flags & PD_ENABLEPRINTHOOK) != 0);
2275 ATLASSERT((m_pd.Flags & PD_ENABLESETUPHOOK) != 0);
2276 ATLASSERT(m_pd.lpfnPrintHook != NULL);
2277 ATLASSERT(m_pd.lpfnSetupHook != NULL);
2278 ATLASSERT((m_pd.Flags & PD_RETURNDEFAULT) == 0);
2280 if(m_pd.hwndOwner == NULL)
2281 m_pd.hwndOwner = hWndParent;
2283 ATLASSERT(m_hWnd == NULL);
2285 #if (_ATL_VER >= 0x0800) 2287 BOOL bRetTh = m_thunk.Init(NULL, NULL);
2290 ::SetLastError(ERROR_OUTOFMEMORY);
2293 #endif // (_ATL_VER >= 0x0800) 2297 BOOL bRet = ::PrintDlg(&m_pd);
2301 return bRet ? IDOK : IDCANCEL;
2307 m_pd.Flags |= PD_RETURNDEFAULT;
2308 ATLASSERT(m_pd.hDevMode == NULL);
2309 ATLASSERT(m_pd.hDevNames == NULL);
2311 return ::PrintDlg(&m_pd);
2315 int GetCopies()
const 2317 if((m_pd.Flags & PD_USEDEVMODECOPIES) != 0)
2319 LPDEVMODE lpDevMode = GetDevMode();
2320 return (lpDevMode != NULL) ? lpDevMode->dmCopies : -1;
2323 return m_pd.nCopies;
2326 BOOL PrintCollate()
const 2328 return ((m_pd.Flags & PD_COLLATE) != 0) ? TRUE : FALSE;
2331 BOOL PrintSelection()
const 2333 return ((m_pd.Flags & PD_SELECTION) != 0) ? TRUE : FALSE;
2336 BOOL PrintAll()
const 2338 return (!PrintRange() && !PrintSelection()) ? TRUE : FALSE;
2341 BOOL PrintRange()
const 2343 return ((m_pd.Flags & PD_PAGENUMS) != 0) ? TRUE : FALSE;
2346 BOOL PrintToFile()
const 2348 return ((m_pd.Flags & PD_PRINTTOFILE) != 0) ? TRUE : FALSE;
2351 int GetFromPage()
const 2353 return PrintRange() ? m_pd.nFromPage : -1;
2356 int GetToPage()
const 2358 return PrintRange() ? m_pd.nToPage : -1;
2361 LPDEVMODE GetDevMode()
const 2363 if(m_pd.hDevMode == NULL)
2366 return (LPDEVMODE)::GlobalLock(m_pd.hDevMode);
2369 LPCTSTR GetDriverName()
const 2371 if(m_pd.hDevNames == NULL)
2374 LPDEVNAMES lpDev = (LPDEVNAMES)::GlobalLock(m_pd.hDevNames);
2378 return (LPCTSTR)lpDev + lpDev->wDriverOffset;
2381 LPCTSTR GetDeviceName()
const 2383 if(m_pd.hDevNames == NULL)
2386 LPDEVNAMES lpDev = (LPDEVNAMES)::GlobalLock(m_pd.hDevNames);
2390 return (LPCTSTR)lpDev + lpDev->wDeviceOffset;
2393 LPCTSTR GetPortName()
const 2395 if(m_pd.hDevNames == NULL)
2398 LPDEVNAMES lpDev = (LPDEVNAMES)::GlobalLock(m_pd.hDevNames);
2402 return (LPCTSTR)lpDev + lpDev->wOutputOffset;
2405 HDC GetPrinterDC()
const 2407 ATLASSERT((m_pd.Flags & PD_RETURNDC) != 0);
2416 HDC CreatePrinterDC()
2418 m_pd.hDC = _AtlCreateDC(m_pd.hDevNames, m_pd.hDevMode);
2423 PRINTDLG m_pdActual;
2431 COMMAND_ID_HANDLER(psh1, OnPrintSetup)
2433 COMMAND_ID_HANDLER(0x0400, OnPrintSetup)
2437 LRESULT OnPrintSetup(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& )
2441 return DefWindowProc(WM_COMMAND, MAKEWPARAM(wID, wNotifyCode), (LPARAM)hWndCtl);
2449 DWORD dwFlags = PD_ALLPAGES | PD_USEDEVMODECOPIES | PD_NOPAGENUMS | PD_NOSELECTION,
2450 HWND hWndParent = NULL)
2458 #pragma warning(pop) 2460 #endif // _WIN32_WCE 2466 #if (WINVER >= 0x0500) && !defined(_WIN32_WCE) 2472 extern "C" const __declspec(selectany) IID IID_IPrintDialogCallback = {0x5852a2c3, 0x6530, 0x11d1, {0xb6, 0xa3, 0x0, 0x0, 0xf8, 0x75, 0x7b, 0xf9}};
2473 extern "C" const __declspec(selectany) IID IID_IPrintDialogServices = {0x509aaeda, 0x5639, 0x11d1, {0xb6, 0xa1, 0x0, 0x0, 0xf8, 0x75, 0x7b, 0xf9}};
2479 class ATL_NO_VTABLE CPrintDialogExImpl :
2480 public ATL::CWindow,
2481 public ATL::CMessageMap,
2482 public IPrintDialogCallback,
2483 public ATL::IObjectWithSiteImpl< T >
2489 CPrintDialogExImpl(DWORD dwFlags = PD_ALLPAGES | PD_USEDEVMODECOPIES | PD_NOPAGENUMS | PD_NOSELECTION | PD_NOCURRENTPAGE,
2490 HWND hWndParent = NULL)
2492 memset(&m_pdex, 0,
sizeof(m_pdex));
2494 m_pdex.lStructSize =
sizeof(PRINTDLGEX);
2495 m_pdex.hwndOwner = hWndParent;
2496 m_pdex.Flags = dwFlags;
2497 m_pdex.nStartPage = START_PAGE_GENERAL;
2500 m_pdex.Flags &= ~PD_RETURNIC;
2504 HRESULT DoModal(HWND hWndParent = ::GetActiveWindow())
2506 ATLASSERT(m_hWnd == NULL);
2507 ATLASSERT((m_pdex.Flags & PD_RETURNDEFAULT) == 0);
2509 if(m_pdex.hwndOwner == NULL)
2510 m_pdex.hwndOwner = hWndParent;
2512 T* pT =
static_cast<T*
>(
this);
2513 m_pdex.lpCallback = (IUnknown*)(IPrintDialogCallback*)pT;
2515 HRESULT hResult = ::PrintDlgEx(&m_pdex);
2522 BOOL EndDialog(INT_PTR = 0)
2524 ATLASSERT(::IsWindow(m_hWnd));
2525 SendMessage(WM_COMMAND, MAKEWPARAM(IDABORT, 0));
2530 HRESULT GetDefaults()
2532 ATLASSERT(m_pdex.hDevMode == NULL);
2533 ATLASSERT(m_pdex.hDevNames == NULL);
2535 if(m_pdex.hwndOwner == NULL)
2536 m_pdex.hwndOwner = ::GetActiveWindow();
2538 m_pdex.Flags |= PD_RETURNDEFAULT;
2539 HRESULT hRet = ::PrintDlgEx(&m_pdex);
2540 m_pdex.Flags &= ~PD_RETURNDEFAULT;
2546 int GetCopies()
const 2548 if((m_pdex.Flags & PD_USEDEVMODECOPIES) != 0)
2550 LPDEVMODE lpDevMode = GetDevMode();
2551 return (lpDevMode != NULL) ? lpDevMode->dmCopies : -1;
2554 return m_pdex.nCopies;
2557 BOOL PrintCollate()
const 2559 return ((m_pdex.Flags & PD_COLLATE) != 0) ? TRUE : FALSE;
2562 BOOL PrintSelection()
const 2564 return ((m_pdex.Flags & PD_SELECTION) != 0) ? TRUE : FALSE;
2567 BOOL PrintAll()
const 2569 return (!PrintRange() && !PrintSelection()) ? TRUE : FALSE;
2572 BOOL PrintRange()
const 2574 return ((m_pdex.Flags & PD_PAGENUMS) != 0) ? TRUE : FALSE;
2577 BOOL PrintToFile()
const 2579 return ((m_pdex.Flags & PD_PRINTTOFILE) != 0) ? TRUE : FALSE;
2582 LPDEVMODE GetDevMode()
const 2584 if(m_pdex.hDevMode == NULL)
2587 return (LPDEVMODE)::GlobalLock(m_pdex.hDevMode);
2590 LPCTSTR GetDriverName()
const 2592 if(m_pdex.hDevNames == NULL)
2595 LPDEVNAMES lpDev = (LPDEVNAMES)::GlobalLock(m_pdex.hDevNames);
2599 return (LPCTSTR)lpDev + lpDev->wDriverOffset;
2602 LPCTSTR GetDeviceName()
const 2604 if(m_pdex.hDevNames == NULL)
2607 LPDEVNAMES lpDev = (LPDEVNAMES)::GlobalLock(m_pdex.hDevNames);
2611 return (LPCTSTR)lpDev + lpDev->wDeviceOffset;
2614 LPCTSTR GetPortName()
const 2616 if(m_pdex.hDevNames == NULL)
2619 LPDEVNAMES lpDev = (LPDEVNAMES)::GlobalLock(m_pdex.hDevNames);
2623 return (LPCTSTR)lpDev + lpDev->wOutputOffset;
2626 HDC GetPrinterDC()
const 2628 ATLASSERT((m_pdex.Flags & PD_RETURNDC) != 0);
2637 HDC CreatePrinterDC()
2639 m_pdex.hDC = _AtlCreateDC(m_pdex.hDevNames, m_pdex.hDevMode);
2646 STDMETHOD(QueryInterface)(REFIID riid,
void** ppvObject)
2648 if(ppvObject == NULL)
2651 T* pT =
static_cast<T*
>(
this);
2652 if(IsEqualGUID(riid, IID_IUnknown) || IsEqualGUID(riid, IID_IPrintDialogCallback))
2654 *ppvObject = (IPrintDialogCallback*)pT;
2658 else if(IsEqualGUID(riid, IID_IObjectWithSite))
2660 *ppvObject = (IObjectWithSite*)pT;
2665 return E_NOINTERFACE;
2668 virtual ULONG STDMETHODCALLTYPE AddRef()
2673 virtual ULONG STDMETHODCALLTYPE Release()
2679 STDMETHOD(InitDone)()
2684 STDMETHOD(SelectionChange)()
2689 STDMETHOD(HandleMessage)(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT* plResult)
2696 HRESULT hRet = ProcessWindowMessage(hWnd, uMsg, wParam, lParam, *plResult, 0) ? S_OK : S_FALSE;
2697 if(hRet == S_OK && uMsg == WM_NOTIFY)
2698 ::SetWindowLongPtr(GetParent(), DWLP_MSGRESULT, (LONG_PTR)*plResult);
2700 if(uMsg == WM_INITDIALOG && hRet == S_OK && (BOOL)*plResult != FALSE)
2707 class CPrintDialogEx :
public CPrintDialogExImpl<CPrintDialogEx>
2711 DWORD dwFlags = PD_ALLPAGES | PD_USEDEVMODECOPIES | PD_NOPAGENUMS | PD_NOSELECTION | PD_NOCURRENTPAGE,
2712 HWND hWndParent = NULL)
2713 : CPrintDialogExImpl<CPrintDialogEx>(dwFlags, hWndParent)
2716 DECLARE_EMPTY_MSG_MAP()
2719 #endif // (WINVER >= 0x0500) && !defined(_WIN32_WCE) 2732 ATL::CWndProcThunk m_thunkPaint;
2735 CPageSetupDialogImpl(DWORD dwFlags = PSD_MARGINS | PSD_INWININIINTLMEASURE, HWND hWndParent = NULL)
2737 memset(&m_psd, 0,
sizeof(m_psd));
2739 m_psd.lStructSize =
sizeof(m_psd);
2740 m_psd.hwndOwner = hWndParent;
2741 m_psd.Flags = (dwFlags | PSD_ENABLEPAGESETUPHOOK | PSD_ENABLEPAGEPAINTHOOK);
2742 m_psd.lpfnPageSetupHook = (LPPAGESETUPHOOK)T::HookProc;
2743 m_thunkPaint.Init((WNDPROC)T::PaintHookProc,
this);
2744 #if (_ATL_VER >= 0x0700) 2745 m_psd.lpfnPagePaintHook = (LPPAGEPAINTHOOK)m_thunkPaint.GetWNDPROC();
2747 m_psd.lpfnPagePaintHook = (LPPAGEPAINTHOOK)&(m_thunkPaint.thunk);
2751 DECLARE_EMPTY_MSG_MAP()
2754 LPDEVMODE GetDevMode()
const 2756 if(m_psd.hDevMode == NULL)
2759 return (LPDEVMODE)::GlobalLock(m_psd.hDevMode);
2762 LPCTSTR GetDriverName()
const 2764 if(m_psd.hDevNames == NULL)
2767 LPDEVNAMES lpDev = (LPDEVNAMES)::GlobalLock(m_psd.hDevNames);
2768 return (LPCTSTR)lpDev + lpDev->wDriverOffset;
2771 LPCTSTR GetDeviceName()
const 2773 if(m_psd.hDevNames == NULL)
2776 LPDEVNAMES lpDev = (LPDEVNAMES)::GlobalLock(m_psd.hDevNames);
2777 return (LPCTSTR)lpDev + lpDev->wDeviceOffset;
2780 LPCTSTR GetPortName()
const 2782 if(m_psd.hDevNames == NULL)
2785 LPDEVNAMES lpDev = (LPDEVNAMES)::GlobalLock(m_psd.hDevNames);
2786 return (LPCTSTR)lpDev + lpDev->wOutputOffset;
2789 HDC CreatePrinterDC()
2791 return _AtlCreateDC(m_psd.hDevNames, m_psd.hDevMode);
2794 SIZE GetPaperSize()
const 2796 SIZE size = { m_psd.ptPaperSize.x, m_psd.ptPaperSize.y };
2800 void GetMargins(LPRECT lpRectMargins, LPRECT lpRectMinMargins)
const 2802 if(lpRectMargins != NULL)
2803 *lpRectMargins = m_psd.rtMargin;
2804 if(lpRectMinMargins != NULL)
2805 *lpRectMinMargins = m_psd.rtMinMargin;
2809 INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow())
2811 ATLASSERT((m_psd.Flags & PSD_ENABLEPAGESETUPHOOK) != 0);
2812 ATLASSERT((m_psd.Flags & PSD_ENABLEPAGEPAINTHOOK) != 0);
2813 ATLASSERT(m_psd.lpfnPageSetupHook != NULL);
2814 ATLASSERT(m_psd.lpfnPagePaintHook != NULL);
2816 if(m_psd.hwndOwner == NULL)
2817 m_psd.hwndOwner = hWndParent;
2819 ATLASSERT(m_hWnd == NULL);
2821 #if (_ATL_VER >= 0x0800) 2823 BOOL bRetTh = m_thunk.Init(NULL, NULL);
2826 ::SetLastError(ERROR_OUTOFMEMORY);
2829 #endif // (_ATL_VER >= 0x0800) 2833 BOOL bRet = ::PageSetupDlg(&m_psd);
2837 return bRet ? IDOK : IDCANCEL;
2841 static UINT_PTR CALLBACK PaintHookProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
2847 case WM_PSD_PAGESETUPDLG:
2848 uRet = pT->PreDrawPage(LOWORD(wParam), HIWORD(wParam), (LPPAGESETUPDLG)lParam);
2850 case WM_PSD_FULLPAGERECT:
2851 case WM_PSD_MINMARGINRECT:
2852 case WM_PSD_MARGINRECT:
2853 case WM_PSD_GREEKTEXTRECT:
2854 case WM_PSD_ENVSTAMPRECT:
2855 case WM_PSD_YAFULLPAGERECT:
2856 uRet = pT->OnDrawPage(uMsg, (HDC)wParam, (LPRECT)lParam);
2859 ATLTRACE2(atlTraceUI, 0, _T(
"CPageSetupDialogImpl::PaintHookProc - unknown message received\n"));
2866 UINT_PTR PreDrawPage(WORD , WORD , LPPAGESETUPDLG )
2872 UINT_PTR OnDrawPage(UINT , HDC , LPRECT )
2881 CPageSetupDialog(DWORD dwFlags = PSD_MARGINS | PSD_INWININIINTLMEASURE, HWND hWndParent = NULL)
2886 static UINT_PTR CALLBACK PaintHookProc(HWND, UINT, WPARAM, LPARAM)
2892 #endif // _WIN32_WCE 2904 enum { _cchFindReplaceBuffer = 128 };
2907 TCHAR m_szFindWhat[_cchFindReplaceBuffer];
2908 TCHAR m_szReplaceWith[_cchFindReplaceBuffer];
2913 memset(&m_fr, 0,
sizeof(m_fr));
2914 m_szFindWhat[0] = _T(
'\0');
2915 m_szReplaceWith[0] = _T(
'\0');
2917 m_fr.lStructSize =
sizeof(m_fr);
2918 m_fr.Flags = FR_ENABLEHOOK;
2919 m_fr.lpfnHook = (LPFRHOOKPROC)T::HookProc;
2920 m_fr.lpstrFindWhat = (LPTSTR)m_szFindWhat;
2921 m_fr.wFindWhatLen = _cchFindReplaceBuffer;
2922 m_fr.lpstrReplaceWith = (LPTSTR)m_szReplaceWith;
2923 m_fr.wReplaceWithLen = _cchFindReplaceBuffer;
2928 virtual void OnFinalMessage(HWND )
2933 HWND Create(BOOL bFindDialogOnly,
2934 LPCTSTR lpszFindWhat,
2935 LPCTSTR lpszReplaceWith = NULL,
2936 DWORD dwFlags = FR_DOWN,
2937 HWND hWndParent = NULL)
2939 ATLASSERT((m_fr.Flags & FR_ENABLEHOOK) != 0);
2940 ATLASSERT(m_fr.lpfnHook != NULL);
2942 m_fr.Flags |= dwFlags;
2944 if(hWndParent == NULL)
2945 m_fr.hwndOwner = ::GetActiveWindow();
2947 m_fr.hwndOwner = hWndParent;
2948 ATLASSERT(m_fr.hwndOwner != NULL);
2950 if(lpszFindWhat != NULL)
2951 SecureHelper::strncpy_x(m_szFindWhat, _countof(m_szFindWhat), lpszFindWhat, _TRUNCATE);
2953 if(lpszReplaceWith != NULL)
2954 SecureHelper::strncpy_x(m_szReplaceWith, _countof(m_szReplaceWith), lpszReplaceWith, _TRUNCATE);
2956 ATLASSERT(m_hWnd == NULL);
2958 #if (_ATL_VER >= 0x0800) 2960 BOOL bRet = m_thunk.Init(NULL, NULL);
2963 ::SetLastError(ERROR_OUTOFMEMORY);
2966 #endif // (_ATL_VER >= 0x0800) 2972 hWnd = ::FindText(&m_fr);
2974 hWnd = ::ReplaceText(&m_fr);
2976 ATLASSERT(m_hWnd == hWnd);
2980 static const UINT GetFindReplaceMsg()
2982 static const UINT nMsgFindReplace = ::RegisterWindowMessage(FINDMSGSTRING);
2983 return nMsgFindReplace;
2987 static T* PASCAL GetNotifier(LPARAM lParam)
2989 ATLASSERT(lParam != NULL);
2990 T* pDlg = (T*)(lParam - offsetof(T, m_fr));
2996 LPCTSTR GetFindString()
const 2998 return (LPCTSTR)m_fr.lpstrFindWhat;
3001 LPCTSTR GetReplaceString()
const 3003 return (LPCTSTR)m_fr.lpstrReplaceWith;
3006 BOOL SearchDown()
const 3008 return ((m_fr.Flags & FR_DOWN) != 0) ? TRUE : FALSE;
3011 BOOL FindNext()
const 3013 return ((m_fr.Flags & FR_FINDNEXT) != 0) ? TRUE : FALSE;
3016 BOOL MatchCase()
const 3018 return ((m_fr.Flags & FR_MATCHCASE) != 0) ? TRUE : FALSE;
3021 BOOL MatchWholeWord()
const 3023 return ((m_fr.Flags & FR_WHOLEWORD) != 0) ? TRUE : FALSE;
3026 BOOL ReplaceCurrent()
const 3028 return ((m_fr. Flags & FR_REPLACE) != 0) ? TRUE : FALSE;
3031 BOOL ReplaceAll()
const 3033 return ((m_fr.Flags & FR_REPLACEALL) != 0) ? TRUE : FALSE;
3036 BOOL IsTerminating()
const 3038 return ((m_fr.Flags & FR_DIALOGTERM) != 0) ? TRUE : FALSE ;
3045 DECLARE_EMPTY_MSG_MAP()
3048 #endif // !_WIN32_WCE 3064 LONG nDlgBaseUnits = ::GetDialogBaseUnits();
3065 m_sizeUnits.cx = LOWORD(nDlgBaseUnits);
3066 m_sizeUnits.cy = HIWORD(nDlgBaseUnits);
3071 if(!InitDialogBaseUnits(hWnd)) {
3072 LONG nDlgBaseUnits = ::GetDialogBaseUnits();
3073 m_sizeUnits.cx = LOWORD(nDlgBaseUnits);
3074 m_sizeUnits.cy = HIWORD(nDlgBaseUnits);
3080 if(!InitDialogBaseUnits(hFont, hWnd)) {
3081 LONG nDlgBaseUnits = ::GetDialogBaseUnits();
3082 m_sizeUnits.cx = LOWORD(nDlgBaseUnits);
3083 m_sizeUnits.cy = HIWORD(nDlgBaseUnits);
3089 if(!InitDialogBaseUnits(lf, hWnd)) {
3090 LONG nDlgBaseUnits = ::GetDialogBaseUnits();
3091 m_sizeUnits.cx = LOWORD(nDlgBaseUnits);
3092 m_sizeUnits.cy = HIWORD(nDlgBaseUnits);
3097 BOOL InitDialogBaseUnits(HWND hWnd)
3099 ATLASSERT(::IsWindow(hWnd));
3100 RECT rc = { 0, 0, 4, 8 };
3101 if(!::MapDialogRect(hWnd, &rc))
return FALSE;
3102 m_sizeUnits.cx = rc.right;
3103 m_sizeUnits.cy = rc.bottom;
3107 BOOL InitDialogBaseUnits(LOGFONT lf, HWND hWnd = NULL)
3110 font.CreateFontIndirect(&lf);
3111 if(font.IsNull())
return FALSE;
3112 return InitDialogBaseUnits(font, hWnd);
3115 BOOL InitDialogBaseUnits(HFONT hFont, HWND hWnd = NULL)
3117 ATLASSERT(hFont != NULL);
3119 TEXTMETRIC tmText = { 0 };
3120 SIZE sizeText = { 0 };
3121 HFONT hFontOld = dc.SelectFont(hFont);
3122 dc.GetTextMetrics(&tmText);
3123 m_sizeUnits.cy = tmText.tmHeight + tmText.tmExternalLeading;
3124 dc.GetTextExtent(_T(
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"), 52, &sizeText);
3125 m_sizeUnits.cx = (sizeText.cx + 26) / 52;
3126 dc.SelectFont(hFontOld);
3130 SIZE GetDialogBaseUnits()
const 3135 INT MapDialogPixelsX(INT x)
const 3137 return ::MulDiv(x, 4, m_sizeUnits.cx);
3140 INT MapDialogPixelsY(INT y)
const 3142 return ::MulDiv(y, 8, m_sizeUnits.cy);
3145 POINT MapDialogPixels(POINT pt)
const 3147 POINT out = { MapDialogPixelsX(pt.x), MapDialogPixelsY(pt.y) };
3151 SIZE MapDialogPixels(SIZE input)
const 3153 SIZE out = { MapDialogPixelsX(input.cx), MapDialogPixelsY(input.cy) };
3157 RECT MapDialogPixels(
const RECT& input)
const 3159 RECT out = { MapDialogPixelsX(input.left), MapDialogPixelsY(input.top), MapDialogPixelsX(input.right), MapDialogPixelsY(input.bottom) };
3163 INT MapDialogUnitsX(INT x)
const 3165 return ::MulDiv(x, m_sizeUnits.cx, 4);
3168 INT MapDialogUnitsY(INT y)
const 3170 return ::MulDiv(y, m_sizeUnits.cy, 8);
3173 POINT MapDialogUnits(POINT pt)
const 3175 POINT out = { MapDialogUnitsX(pt.x), MapDialogUnitsY(pt.y) };
3179 SIZE MapDialogUnits(SIZE input)
const 3181 SIZE out = { MapDialogUnitsX(input.cx), MapDialogUnitsY(input.cy) };
3185 RECT MapDialogUnits(
const RECT& input)
const 3187 RECT out = { MapDialogUnitsX(input.left), MapDialogUnitsY(input.top), MapDialogUnitsX(input.right), MapDialogUnitsY(input.bottom) };
3196 #if (_ATL_VER >= 0x800) 3197 typedef ATL::_DialogSplitHelper::DLGTEMPLATEEX DLGTEMPLATEEX;
3199 #else // (_ATL_VER >= 0x800) 3200 typedef ATL::_DialogSizeHelper::_ATL_DLGTEMPLATEEX DLGTEMPLATEEX;
3201 #pragma pack(push, 4) 3202 struct DLGITEMTEMPLATEEX
3214 #endif // (_ATL_VER >= 0x800) 3217 template <
class TWinTraits>
3223 CTRL_BUTTON = 0x0080,
3225 CTRL_STATIC = 0x0082,
3226 CTRL_LISTBOX = 0x0083,
3227 CTRL_SCROLLBAR = 0x0084,
3228 CTRL_COMBOBOX = 0x0085
3234 SIZE_T m_cAllocated;
3236 CMemDlgTemplateT() : m_hData(NULL), m_pData(NULL), m_pPtr(NULL), m_cAllocated(0)
3244 bool IsValid()
const 3246 return (m_pData != NULL);
3249 bool IsTemplateEx()
const 3251 return (IsValid() && ((DLGTEMPLATEEX*)m_pData)->signature == 0xFFFF);
3254 LPDLGTEMPLATE GetTemplatePtr()
3256 return reinterpret_cast<LPDLGTEMPLATE
>(m_pData);
3259 DLGTEMPLATEEX* GetTemplateExPtr()
3261 return reinterpret_cast<DLGTEMPLATEEX*
>(m_pData);
3268 ::GlobalUnlock(m_pData);
3270 ATLVERIFY(::GlobalFree(m_hData) == NULL);
3279 void Create(
bool bDlgEx, LPCTSTR lpszCaption,
const RECT& rc, DWORD dwStyle = 0, DWORD dwExStyle = 0,
3280 LPCTSTR lpstrFontName = NULL, WORD wFontSize = 0, WORD wWeight = 0, BYTE bItalic = 0, BYTE bCharset = 0, DWORD dwHelpID = 0,
3283 Create(bDlgEx, lpszCaption, (
short) rc.left, (
short) rc.top, (
short) (rc.right - rc.left), (
short) (rc.bottom - rc.top), dwStyle, dwExStyle,
3284 lpstrFontName, wFontSize, wWeight, bItalic, bCharset, dwHelpID, ClassName.m_lpstr, Menu.m_lpstr);
3287 void Create(
bool bDlgEx, LPCTSTR lpszCaption,
short nX,
short nY,
short nWidth,
short nHeight, DWORD dwStyle = 0, DWORD dwExStyle = 0,
3288 LPCTSTR lpstrFontName = NULL, WORD wFontSize = 0, WORD wWeight = 0, BYTE bItalic = 0, BYTE bCharset = 0, DWORD dwHelpID = 0,
3292 if (lpstrFontName != NULL)
3294 dwStyle |= DS_SETFONT;
3298 dwStyle &= ~DS_SETFONT;
3303 DLGTEMPLATEEX dlg = {1, 0xFFFF, dwHelpID, dwExStyle, dwStyle, 0, nX, nY, nWidth, nHeight};
3304 AddData(&dlg,
sizeof(dlg));
3308 DLGTEMPLATE dlg = {dwStyle, dwExStyle, 0, nX, nY, nWidth, nHeight};
3309 AddData(&dlg,
sizeof(dlg));
3313 if (Menu.m_lpstr == NULL)
3316 AddData(&menuData,
sizeof(WORD));
3318 else if (IS_INTRESOURCE(Menu.m_lpstr))
3320 WORD menuData[] = { 0xFFFF, LOWORD(Menu.m_lpstr) };
3321 AddData(menuData,
sizeof(menuData));
3325 AddString(Menu.m_lpstr);
3329 ATLASSERT(Menu.m_lpstr == NULL);
3332 AddData(&menuData,
sizeof(WORD));
3333 #endif // _WIN32_WCE 3335 if (ClassName.m_lpstr == NULL)
3338 AddData(&classData,
sizeof(WORD));
3340 else if (IS_INTRESOURCE(ClassName.m_lpstr))
3342 WORD classData[] = { 0xFFFF, LOWORD(ClassName.m_lpstr) };
3343 AddData(classData,
sizeof(classData));
3347 AddString(ClassName.m_lpstr);
3351 AddString(lpszCaption);
3353 if (lpstrFontName != NULL)
3355 AddData(&wFontSize,
sizeof(wFontSize));
3359 AddData(&wWeight,
sizeof(wWeight));
3360 AddData(&bItalic,
sizeof(bItalic));
3361 AddData(&bCharset,
sizeof(bCharset));
3364 AddString(lpstrFontName);
3368 void AddControl(
ATL::_U_STRINGorID ClassName, WORD wId,
const RECT& rc, DWORD dwStyle, DWORD dwExStyle,
3369 ATL::_U_STRINGorID Text,
const WORD* pCreationData = NULL, WORD nCreationData = 0, DWORD dwHelpID = 0)
3371 AddControl(ClassName.m_lpstr, wId, (
short) rc.left, (
short) rc.top, (
short) (rc.right - rc.left), (
short) (rc.bottom - rc.top), dwStyle, dwExStyle,
3372 Text.m_lpstr, pCreationData, nCreationData, dwHelpID);
3375 void AddControl(
ATL::_U_STRINGorID ClassName, WORD wId,
short nX,
short nY,
short nWidth,
short nHeight, DWORD dwStyle, DWORD dwExStyle,
3376 ATL::_U_STRINGorID Text,
const WORD* pCreationData = NULL, WORD nCreationData = 0, DWORD dwHelpID = 0)
3378 ATLASSERT(IsValid());
3381 const DWORD_PTR dwDwordAlignBits =
sizeof(DWORD) - 1;
3382 m_pPtr = (LPBYTE)(((DWORD_PTR)m_pPtr + dwDwordAlignBits) & (~dwDwordAlignBits));
3386 DLGTEMPLATEEX* dlg = (DLGTEMPLATEEX*)m_pData;
3389 DLGITEMTEMPLATEEX item = {dwHelpID, TWinTraits::GetWndExStyle(0) | dwExStyle, TWinTraits::GetWndStyle(0) | dwStyle, nX, nY, nWidth, nHeight, wId};
3390 AddData(&item,
sizeof(item));
3394 LPDLGTEMPLATE dlg = (LPDLGTEMPLATE)m_pData;
3397 DLGITEMTEMPLATE item = {TWinTraits::GetWndStyle(0) | dwStyle, TWinTraits::GetWndExStyle(0) | dwExStyle, nX, nY, nWidth, nHeight, wId};
3398 AddData(&item,
sizeof(item));
3401 ATLASSERT(ClassName.m_lpstr != NULL);
3402 if (IS_INTRESOURCE(ClassName.m_lpstr))
3404 WORD wData[] = { 0xFFFF, LOWORD(ClassName.m_lpstr) };
3405 AddData(wData,
sizeof(wData));
3409 AddString(ClassName.m_lpstr);
3412 if (Text.m_lpstr == NULL)
3415 AddData(&classData,
sizeof(WORD));
3417 else if (IS_INTRESOURCE(Text.m_lpstr))
3419 WORD wData[] = { 0xFFFF, LOWORD(Text.m_lpstr) };
3420 AddData(wData,
sizeof(wData));
3424 AddString(Text.m_lpstr);
3427 AddData(&nCreationData,
sizeof(nCreationData));
3429 if ((nCreationData != 0))
3431 ATLASSERT(pCreationData != NULL);
3432 AddData(pCreationData, nCreationData *
sizeof(WORD));
3436 void AddStdControl(StdCtrlType CtrlType, WORD wId,
short nX,
short nY,
short nWidth,
short nHeight,
3437 DWORD dwStyle, DWORD dwExStyle,
ATL::_U_STRINGorID Text,
const WORD* pCreationData = NULL, WORD nCreationData = 0, DWORD dwHelpID = 0)
3439 AddControl(CtrlType, wId, nX, nY, nWidth, nHeight, dwStyle, dwExStyle, Text, pCreationData, nCreationData, dwHelpID);
3442 void AddData(LPCVOID pData,
size_t nData)
3444 ATLASSERT(pData != NULL);
3446 const SIZE_T ALLOCATION_INCREMENT = 1024;
3448 if (m_pData == NULL)
3450 m_cAllocated = ((nData / ALLOCATION_INCREMENT) + 1) * ALLOCATION_INCREMENT;
3451 m_hData = ::GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, m_cAllocated);
3452 ATLASSERT(m_hData != NULL);
3454 m_pPtr = m_pData =
static_cast<LPBYTE
>(::GlobalLock(m_hData));
3456 m_pPtr = m_pData =
static_cast<LPBYTE
>(m_hData);
3458 ATLASSERT(m_pData != NULL);
3460 else if (((m_pPtr - m_pData) + nData) > m_cAllocated)
3462 SIZE_T ptrPos = (m_pPtr - m_pData);
3463 m_cAllocated += ((nData / ALLOCATION_INCREMENT) + 1) * ALLOCATION_INCREMENT;
3465 ::GlobalUnlock(m_pData);
3467 m_hData = ::GlobalReAlloc(m_hData, m_cAllocated, GMEM_MOVEABLE | GMEM_ZEROINIT);
3468 ATLASSERT(m_hData != NULL);
3470 m_pData =
static_cast<LPBYTE
>(::GlobalLock(m_hData));
3472 m_pData =
static_cast<LPBYTE
>(m_hData);
3474 ATLASSERT(m_pData != NULL);
3475 m_pPtr = m_pData + ptrPos;
3478 SecureHelper::memcpy_x(m_pPtr, m_cAllocated - (m_pPtr - m_pData), pData, nData);
3483 void AddString(LPCTSTR lpszStr)
3485 if (lpszStr == NULL)
3488 AddData(&szEmpty,
sizeof(szEmpty));
3493 LPCWSTR lpstr = T2CW(lpszStr);
3494 int nSize = lstrlenW(lpstr) + 1;
3495 AddData(lpstr, nSize *
sizeof(WCHAR));
3507 #define BEGIN_DIALOG(x, y, width, height) \ 3508 void DoInitTemplate() \ 3510 bool bExTemplate = false; \ 3511 short nX = x, nY = y, nWidth = width, nHeight = height; \ 3512 LPCTSTR szCaption = NULL; \ 3513 DWORD dwStyle = WS_POPUP | WS_BORDER | WS_SYSMENU; \ 3514 DWORD dwExStyle = 0; \ 3515 LPCTSTR szFontName = NULL; \ 3516 WORD wFontSize = 0; \ 3519 BYTE bCharset = 0; \ 3520 DWORD dwHelpID = 0; \ 3521 ATL::_U_STRINGorID Menu = 0U; \ 3522 ATL::_U_STRINGorID ClassName = 0U; 3525 #define BEGIN_DIALOG_EX(x, y, width, height, helpID) \ 3526 void DoInitTemplate() \ 3528 bool bExTemplate = true; \ 3529 short nX = x, nY = y, nWidth = width, nHeight = height; \ 3530 LPCTSTR szCaption = NULL; \ 3531 DWORD dwStyle = WS_POPUP | WS_BORDER | WS_SYSMENU; \ 3532 DWORD dwExStyle = 0; \ 3533 LPCTSTR szFontName = NULL; \ 3534 WORD wFontSize = 0; \ 3537 BYTE bCharset = 0; \ 3538 DWORD dwHelpID = helpID; \ 3539 ATL::_U_STRINGorID Menu = 0U; \ 3540 ATL::_U_STRINGorID ClassName = 0U; 3542 #define END_DIALOG() \ 3543 m_Template.Create(bExTemplate, szCaption, nX, nY, nWidth, nHeight, dwStyle, dwExStyle, szFontName, wFontSize, wWeight, bItalic, bCharset, dwHelpID, ClassName, Menu); \ 3546 #define DIALOG_CAPTION(caption) \ 3547 szCaption = caption; 3548 #define DIALOG_STYLE(style) \ 3550 #define DIALOG_EXSTYLE(exStyle) \ 3551 dwExStyle = exStyle; 3552 #define DIALOG_FONT(pointSize, typeFace) \ 3553 wFontSize = pointSize; \ 3554 szFontName = typeFace; 3555 #define DIALOG_FONT_EX(pointsize, typeface, weight, italic, charset) \ 3556 ATLASSERT(bExTemplate); \ 3557 wFontSize = pointsize; \ 3558 szFontName = typeface; \ 3562 #define DIALOG_MENU(menuName) \ 3564 #define DIALOG_CLASS(className) \ 3565 ClassName = className; 3567 #define BEGIN_CONTROLS_MAP() \ 3568 void DoInitControls() \ 3571 #define END_CONTROLS_MAP() \ 3575 #define CONTROL_LTEXT(text, id, x, y, width, height, style, exStyle) \ 3576 m_Template.AddStdControl(m_Template.CTRL_STATIC, (WORD)id, x, y, width, height, style | SS_LEFT | WS_GROUP, exStyle, text, NULL, 0); 3577 #define CONTROL_CTEXT(text, id, x, y, width, height, style, exStyle) \ 3578 m_Template.AddStdControl(m_Template.CTRL_STATIC, (WORD)id, x, y, width, height, style | SS_CENTER | WS_GROUP, exStyle, text, NULL, 0); 3579 #define CONTROL_RTEXT(text, id, x, y, width, height, style, exStyle) \ 3580 m_Template.AddStdControl(m_Template.CTRL_STATIC, (WORD)id, x, y, width, height, style | SS_RIGHT | WS_GROUP, exStyle, text, NULL, 0); 3581 #define CONTROL_PUSHBUTTON(text, id, x, y, width, height, style, exStyle) \ 3582 m_Template.AddStdControl(m_Template.CTRL_BUTTON, (WORD)id, x, y, width, height, style | BS_PUSHBUTTON | WS_TABSTOP, exStyle, text, NULL, 0); 3583 #define CONTROL_DEFPUSHBUTTON(text, id, x, y, width, height, style, exStyle) \ 3584 m_Template.AddStdControl(m_Template.CTRL_BUTTON, (WORD)id, x, y, width, height, style | BS_DEFPUSHBUTTON | WS_TABSTOP, exStyle, text, NULL, 0); 3586 #define CONTROL_PUSHBOX(text, id, x, y, width, height, style, exStyle) \ 3587 m_Template.AddStdControl(m_Template.CTRL_BUTTON, (WORD)id, x, y, width, height, style | BS_PUSHBOX | WS_TABSTOP, exStyle, text, NULL, 0); 3588 #endif // !_WIN32_WCE 3589 #define CONTROL_STATE3(text, id, x, y, width, height, style, exStyle) \ 3590 m_Template.AddStdControl(m_Template.CTRL_BUTTON, (WORD)id, x, y, width, height, style | BS_3STATE | WS_TABSTOP, exStyle, text, NULL, 0); 3591 #define CONTROL_AUTO3STATE(text, id, x, y, width, height, style, exStyle) \ 3592 m_Template.AddStdControl(m_Template.CTRL_BUTTON, (WORD)id, x, y, width, height, style | BS_AUTO3STATE | WS_TABSTOP, exStyle, text, NULL, 0); 3593 #define CONTROL_CHECKBOX(text, id, x, y, width, height, style, exStyle) \ 3594 m_Template.AddStdControl(m_Template.CTRL_BUTTON, (WORD)id, x, y, width, height, style | BS_CHECKBOX | WS_TABSTOP, exStyle, text, NULL, 0); 3595 #define CONTROL_AUTOCHECKBOX(text, id, x, y, width, height, style, exStyle) \ 3596 m_Template.AddStdControl(m_Template.CTRL_BUTTON, (WORD)id, x, y, width, height, style | BS_AUTOCHECKBOX | WS_TABSTOP, exStyle, text, NULL, 0); 3597 #define CONTROL_RADIOBUTTON(text, id, x, y, width, height, style, exStyle) \ 3598 m_Template.AddStdControl(m_Template.CTRL_BUTTON, (WORD)id, x, y, width, height, style | BS_RADIOBUTTON | WS_TABSTOP, exStyle, text, NULL, 0); 3599 #define CONTROL_AUTORADIOBUTTON(text, id, x, y, width, height, style, exStyle) \ 3600 m_Template.AddStdControl(m_Template.CTRL_BUTTON, (WORD)id, x, y, width, height, style | BS_AUTORADIOBUTTON | WS_TABSTOP, exStyle, text, NULL, 0); 3601 #define CONTROL_COMBOBOX(id, x, y, width, height, style, exStyle) \ 3602 m_Template.AddStdControl(m_Template.CTRL_COMBOBOX, (WORD)id, x, y, width, height, style | CBS_DROPDOWN | WS_TABSTOP, exStyle, (LPCTSTR)NULL, NULL, 0); 3603 #define CONTROL_EDITTEXT(id, x, y, width, height, style, exStyle) \ 3604 m_Template.AddStdControl(m_Template.CTRL_EDIT, (WORD)id, x, y, width, height, style | ES_LEFT | WS_BORDER | WS_TABSTOP, exStyle, (LPCTSTR)NULL, NULL, 0); 3605 #define CONTROL_GROUPBOX(text, id, x, y, width, height, style, exStyle) \ 3606 m_Template.AddStdControl(m_Template.CTRL_BUTTON, (WORD)id, x, y, width, height, style | BS_GROUPBOX, exStyle, text, NULL, 0); 3607 #define CONTROL_LISTBOX(id, x, y, width, height, style, exStyle) \ 3608 m_Template.AddStdControl(m_Template.CTRL_LISTBOX, (WORD)id, x, y, width, height, style | LBS_NOTIFY | WS_BORDER, exStyle, (LPCTSTR)NULL, NULL, 0); 3609 #define CONTROL_SCROLLBAR(id, x, y, width, height, style, exStyle) \ 3610 m_Template.AddStdControl(m_Template.CTRL_SCROLLBAR, (WORD)id, x, y, width, height, style | SBS_HORZ, exStyle, (LPCTSTR)NULL, NULL, 0); 3611 #define CONTROL_ICON(text, id, x, y, width, height, style, exStyle) \ 3612 m_Template.AddStdControl(m_Template.CTRL_STATIC, (WORD)id, x, y, width, height, style | SS_ICON, exStyle, text, NULL, 0); 3613 #define CONTROL_CONTROL(text, id, className, style, x, y, width, height, exStyle) \ 3614 m_Template.AddControl(className, (WORD)id, x, y, width, height, style, exStyle, text, NULL, 0); 3620 template <
class T,
class TDlgTemplate = CMemDlgTemplate,
class TBase = ATL::CWindow>
3626 TDlgTemplate m_Template;
3628 void CreateTemplate()
3630 T* pT =
static_cast<T*
>(
this);
3631 pT->DoInitTemplate();
3632 pT->DoInitControls();
3635 INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow(), LPARAM dwInitParam = NULL)
3637 T* pT =
static_cast<T*
>(
this);
3638 ATLASSERT(pT->m_hWnd == NULL);
3640 if(!m_Template.IsValid())
3643 #if (_ATL_VER >= 0x0800) 3645 BOOL bRet = m_thunk.Init(NULL, NULL);
3648 ::SetLastError(ERROR_OUTOFMEMORY);
3651 #endif // (_ATL_VER >= 0x0800) 3653 ModuleHelper::AddCreateWndData(&m_thunk.cd, (ATL::CDialogImplBaseT< TBase >*)pT);
3659 return ::DialogBoxIndirectParam(ModuleHelper::GetResourceInstance(), m_Template.GetTemplatePtr(), hWndParent, (DLGPROC)T::StartDialogProc, dwInitParam);
3662 HWND Create(HWND hWndParent, LPARAM dwInitParam = NULL)
3664 T* pT =
static_cast<T*
>(
this);
3665 ATLASSERT(pT->m_hWnd == NULL);
3667 if(!m_Template.IsValid())
3670 #if (_ATL_VER >= 0x0800) 3672 BOOL bRet = m_thunk.Init(NULL, NULL);
3675 ::SetLastError(ERROR_OUTOFMEMORY);
3678 #endif // (_ATL_VER >= 0x0800) 3680 ModuleHelper::AddCreateWndData(&m_thunk.cd, (ATL::CDialogImplBaseT< TBase >*)pT);
3686 HWND hWnd = ::CreateDialogIndirectParam(ModuleHelper::GetResourceInstance(), (LPCDLGTEMPLATE)m_Template.GetTemplatePtr(), hWndParent, (DLGPROC)T::StartDialogProc, dwInitParam);
3687 ATLASSERT(m_hWnd == hWnd);
3693 HWND Create(HWND hWndParent, RECT&, LPARAM dwInitParam = NULL)
3695 return Create(hWndParent, dwInitParam);
3698 void DoInitTemplate()
3703 void DoInitControls()
3727 int GetPageCount()
const 3729 ATLASSERT(::IsWindow(m_hWnd));
3730 HWND hWndTabCtrl = GetTabControl();
3731 ATLASSERT(hWndTabCtrl != NULL);
3732 return (
int)::SendMessage(hWndTabCtrl, TCM_GETITEMCOUNT, 0, 0L);
3735 HWND GetActivePage()
const 3737 ATLASSERT(::IsWindow(m_hWnd));
3738 return (HWND)::SendMessage(m_hWnd, PSM_GETCURRENTPAGEHWND, 0, 0L);
3741 int GetActiveIndex()
const 3743 ATLASSERT(::IsWindow(m_hWnd));
3744 HWND hWndTabCtrl = GetTabControl();
3745 ATLASSERT(hWndTabCtrl != NULL);
3746 return (
int)::SendMessage(hWndTabCtrl, TCM_GETCURSEL, 0, 0L);
3749 BOOL SetActivePage(
int nPageIndex)
3751 ATLASSERT(::IsWindow(m_hWnd));
3752 return (BOOL)::SendMessage(m_hWnd, PSM_SETCURSEL, nPageIndex, 0L);
3755 BOOL SetActivePage(HPROPSHEETPAGE hPage)
3757 ATLASSERT(::IsWindow(m_hWnd));
3758 ATLASSERT(hPage != NULL);
3759 return (BOOL)::SendMessage(m_hWnd, PSM_SETCURSEL, 0, (LPARAM)hPage);
3762 BOOL SetActivePageByID(
int nPageID)
3764 ATLASSERT(::IsWindow(m_hWnd));
3765 return (BOOL)::SendMessage(m_hWnd, PSM_SETCURSELID, 0, nPageID);
3768 void SetTitle(LPCTSTR lpszText, UINT nStyle = 0)
3770 ATLASSERT(::IsWindow(m_hWnd));
3771 ATLASSERT((nStyle & ~PSH_PROPTITLE) == 0);
3772 ATLASSERT(lpszText != NULL);
3773 ::SendMessage(m_hWnd, PSM_SETTITLE, nStyle, (LPARAM)lpszText);
3776 HWND GetTabControl()
const 3778 ATLASSERT(::IsWindow(m_hWnd));
3779 return (HWND)::SendMessage(m_hWnd, PSM_GETTABCONTROL, 0, 0L);
3782 void SetFinishText(LPCTSTR lpszText)
3784 ATLASSERT(::IsWindow(m_hWnd));
3785 ::SendMessage(m_hWnd, PSM_SETFINISHTEXT, 0, (LPARAM)lpszText);
3788 void SetWizardButtons(DWORD dwFlags)
3790 ATLASSERT(::IsWindow(m_hWnd));
3791 ::PostMessage(m_hWnd, PSM_SETWIZBUTTONS, 0, dwFlags);
3795 BOOL AddPage(HPROPSHEETPAGE hPage)
3797 ATLASSERT(::IsWindow(m_hWnd));
3798 ATLASSERT(hPage != NULL);
3799 return (BOOL)::SendMessage(m_hWnd, PSM_ADDPAGE, 0, (LPARAM)hPage);
3802 BOOL AddPage(LPCPROPSHEETPAGE pPage)
3804 ATLASSERT(::IsWindow(m_hWnd));
3805 ATLASSERT(pPage != NULL);
3806 HPROPSHEETPAGE hPage = ::CreatePropertySheetPage(pPage);
3809 return (BOOL)::SendMessage(m_hWnd, PSM_ADDPAGE, 0, (LPARAM)hPage);
3813 BOOL InsertPage(
int nNewPageIndex, HPROPSHEETPAGE hPage)
3815 ATLASSERT(::IsWindow(m_hWnd));
3816 ATLASSERT(hPage != NULL);
3817 return (BOOL)::SendMessage(m_hWnd, PSM_INSERTPAGE, nNewPageIndex, (LPARAM)hPage);
3820 BOOL InsertPage(
int nNewPageIndex, LPCPROPSHEETPAGE pPage)
3822 ATLASSERT(::IsWindow(m_hWnd));
3823 ATLASSERT(pPage != NULL);
3824 HPROPSHEETPAGE hPage = ::CreatePropertySheetPage(pPage);
3827 return (BOOL)::SendMessage(m_hWnd, PSM_INSERTPAGE, nNewPageIndex, (LPARAM)hPage);
3830 BOOL InsertPage(HPROPSHEETPAGE hPageInsertAfter, HPROPSHEETPAGE hPage)
3832 ATLASSERT(::IsWindow(m_hWnd));
3833 ATLASSERT(hPage != NULL);
3834 return (BOOL)::SendMessage(m_hWnd, PSM_INSERTPAGE, (WPARAM)hPageInsertAfter, (LPARAM)hPage);
3837 BOOL InsertPage(HPROPSHEETPAGE hPageInsertAfter, LPCPROPSHEETPAGE pPage)
3839 ATLASSERT(::IsWindow(m_hWnd));
3840 ATLASSERT(pPage != NULL);
3841 HPROPSHEETPAGE hPage = ::CreatePropertySheetPage(pPage);
3844 return (BOOL)::SendMessage(m_hWnd, PSM_INSERTPAGE, (WPARAM)hPageInsertAfter, (LPARAM)hPage);
3846 #endif // !_WIN32_WCE 3848 void RemovePage(
int nPageIndex)
3850 ATLASSERT(::IsWindow(m_hWnd));
3851 ::SendMessage(m_hWnd, PSM_REMOVEPAGE, nPageIndex, 0L);
3854 void RemovePage(HPROPSHEETPAGE hPage)
3856 ATLASSERT(::IsWindow(m_hWnd));
3857 ATLASSERT(hPage != NULL);
3858 ::SendMessage(m_hWnd, PSM_REMOVEPAGE, 0, (LPARAM)hPage);
3861 BOOL PressButton(
int nButton)
3863 ATLASSERT(::IsWindow(m_hWnd));
3864 return (BOOL)::SendMessage(m_hWnd, PSM_PRESSBUTTON, nButton, 0L);
3869 ATLASSERT(::IsWindow(m_hWnd));
3870 return (BOOL)::SendMessage(m_hWnd, PSM_APPLY, 0, 0L);
3873 void CancelToClose()
3875 ATLASSERT(::IsWindow(m_hWnd));
3876 ::SendMessage(m_hWnd, PSM_CANCELTOCLOSE, 0, 0L);
3879 void SetModified(HWND hWndPage, BOOL bChanged = TRUE)
3881 ATLASSERT(::IsWindow(m_hWnd));
3882 ATLASSERT(::IsWindow(hWndPage));
3883 UINT uMsg = bChanged ? PSM_CHANGED : PSM_UNCHANGED;
3884 ::SendMessage(m_hWnd, uMsg, (WPARAM)hWndPage, 0L);
3887 LRESULT QuerySiblings(WPARAM wParam, LPARAM lParam)
3889 ATLASSERT(::IsWindow(m_hWnd));
3890 return ::SendMessage(m_hWnd, PSM_QUERYSIBLINGS, wParam, lParam);
3895 ATLASSERT(::IsWindow(m_hWnd));
3896 ::SendMessage(m_hWnd, PSM_REBOOTSYSTEM, 0, 0L);
3899 void RestartWindows()
3901 ATLASSERT(::IsWindow(m_hWnd));
3902 ::SendMessage(m_hWnd, PSM_RESTARTWINDOWS, 0, 0L);
3905 BOOL IsDialogMessage(LPMSG lpMsg)
3907 ATLASSERT(::IsWindow(m_hWnd));
3908 return (BOOL)::SendMessage(m_hWnd, PSM_ISDIALOGMESSAGE, 0, (LPARAM)lpMsg);
3911 #if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) 3912 int HwndToIndex(HWND hWnd)
const 3914 ATLASSERT(::IsWindow(m_hWnd));
3915 return (
int)::SendMessage(m_hWnd, PSM_HWNDTOINDEX, (WPARAM)hWnd, 0L);
3918 HWND IndexToHwnd(
int nIndex)
const 3920 ATLASSERT(::IsWindow(m_hWnd));
3921 return (HWND)::SendMessage(m_hWnd, PSM_INDEXTOHWND, nIndex, 0L);
3924 int PageToIndex(HPROPSHEETPAGE hPage)
const 3926 ATLASSERT(::IsWindow(m_hWnd));
3927 return (
int)::SendMessage(m_hWnd, PSM_PAGETOINDEX, 0, (LPARAM)hPage);
3930 HPROPSHEETPAGE IndexToPage(
int nIndex)
const 3932 ATLASSERT(::IsWindow(m_hWnd));
3933 return (HPROPSHEETPAGE)::SendMessage(m_hWnd, PSM_INDEXTOPAGE, nIndex, 0L);
3936 int IdToIndex(
int nID)
const 3938 ATLASSERT(::IsWindow(m_hWnd));
3939 return (
int)::SendMessage(m_hWnd, PSM_IDTOINDEX, 0, nID);
3942 int IndexToId(
int nIndex)
const 3944 ATLASSERT(::IsWindow(m_hWnd));
3945 return (
int)::SendMessage(m_hWnd, PSM_INDEXTOID, nIndex, 0L);
3948 int GetResult()
const 3950 ATLASSERT(::IsWindow(m_hWnd));
3951 return (
int)::SendMessage(m_hWnd, PSM_GETRESULT, 0, 0L);
3954 BOOL RecalcPageSizes()
3956 ATLASSERT(::IsWindow(m_hWnd));
3957 return (BOOL)::SendMessage(m_hWnd, PSM_RECALCPAGESIZES, 0, 0L);
3960 void SetHeaderTitle(
int nIndex, LPCTSTR lpstrHeaderTitle)
3962 ATLASSERT(::IsWindow(m_hWnd));
3963 ::SendMessage(m_hWnd, PSM_SETHEADERTITLE, nIndex, (LPARAM)lpstrHeaderTitle);
3966 void SetHeaderSubTitle(
int nIndex, LPCTSTR lpstrHeaderSubTitle)
3968 ATLASSERT(::IsWindow(m_hWnd));
3969 ::SendMessage(m_hWnd, PSM_SETHEADERSUBTITLE, nIndex, (LPARAM)lpstrHeaderSubTitle);
3971 #endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) 3984 template <
class T,
class TBase = CPropertySheetWindow>
3988 PROPSHEETHEADER m_psh;
3989 ATL::CSimpleArray<HPROPSHEETPAGE> m_arrPages;
3991 #if defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) // PPC specific 3992 #ifndef PROPSHEET_LINK_SIZE 3993 #define PROPSHEET_LINK_SIZE 128 3994 #endif // PROPSHEET_LINK_SIZE 3995 TCHAR m_szLink[PROPSHEET_LINK_SIZE];
3996 static LPCTSTR m_pszTitle;
3997 static LPCTSTR m_pszLink;
3998 #endif // defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) 4003 memset(&m_psh, 0,
sizeof(PROPSHEETHEADER));
4004 m_psh.dwSize =
sizeof(PROPSHEETHEADER);
4005 m_psh.dwFlags = PSH_USECALLBACK;
4006 m_psh.hInstance = ModuleHelper::GetResourceInstance();
4007 m_psh.phpage = NULL;
4009 m_psh.pszCaption = title.m_lpstr;
4010 m_psh.nStartPage = uStartPage;
4011 m_psh.hwndParent = hWndParent;
4012 m_psh.pfnCallback = T::PropSheetCallback;
4014 #if defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) // PPC specific 4015 m_psh.dwFlags |= PSH_MAXIMIZE;
4017 #endif // defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) 4022 if(m_arrPages.GetSize() > 0)
4024 for(
int i = 0; i < m_arrPages.GetSize(); i++)
4025 ::DestroyPropertySheetPage((HPROPSHEETPAGE)m_arrPages[i]);
4030 static int CALLBACK PropSheetCallback(HWND hWnd, UINT uMsg, LPARAM lParam)
4035 if(uMsg == PSCB_INITIALIZED)
4037 ATLASSERT(hWnd != NULL);
4038 T* pT = (T*)ModuleHelper::ExtractCreateWndData();
4040 pT->SubclassWindow(hWnd);
4042 pT->_CleanUpPages();
4044 #if defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) // PPC specific 4045 m_pszTitle = pT->m_psh.pszCaption;
4046 if(*pT->m_szLink != 0)
4047 m_pszLink = pT->m_szLink;
4048 #endif // defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) // PPC specific 4050 pT->OnSheetInitialized();
4052 #if defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) // PPC specific uMsg 4057 case PSCB_GETVERSION :
4058 nRet = COMCTL32_VERSION;
4060 case PSCB_GETTITLE :
4061 if(m_pszTitle != NULL)
4063 lstrcpy((LPTSTR)lParam, m_pszTitle);
4067 case PSCB_GETLINKTEXT:
4068 if(m_pszLink != NULL)
4070 lstrcpy((LPTSTR)lParam, m_pszLink);
4078 #endif // defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) 4083 void OnSheetInitialized()
4088 HWND Create(HWND hWndParent = NULL)
4090 ATLASSERT(m_hWnd == NULL);
4092 m_psh.dwFlags |= PSH_MODELESS;
4093 if(m_psh.hwndParent == NULL)
4094 m_psh.hwndParent = hWndParent;
4095 m_psh.phpage = (HPROPSHEETPAGE*)m_arrPages.GetData();
4096 m_psh.nPages = m_arrPages.GetSize();
4098 T* pT =
static_cast<T*
>(
this);
4100 #if (_ATL_VER >= 0x0800) 4102 BOOL bRet = pT->m_thunk.Init(NULL, NULL);
4105 ::SetLastError(ERROR_OUTOFMEMORY);
4108 #endif // (_ATL_VER >= 0x0800) 4110 ModuleHelper::AddCreateWndData(&pT->m_thunk.cd, pT);
4112 HWND hWnd = (HWND)::PropertySheet(&m_psh);
4115 ATLASSERT(m_hWnd == hWnd);
4120 INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow())
4122 ATLASSERT(m_hWnd == NULL);
4124 m_psh.dwFlags &= ~PSH_MODELESS;
4125 if(m_psh.hwndParent == NULL)
4126 m_psh.hwndParent = hWndParent;
4127 m_psh.phpage = (HPROPSHEETPAGE*)m_arrPages.GetData();
4128 m_psh.nPages = m_arrPages.GetSize();
4130 T* pT =
static_cast<T*
>(
this);
4132 #if (_ATL_VER >= 0x0800) 4134 BOOL bRet = pT->m_thunk.Init(NULL, NULL);
4137 ::SetLastError(ERROR_OUTOFMEMORY);
4140 #endif // (_ATL_VER >= 0x0800) 4142 ModuleHelper::AddCreateWndData(&pT->m_thunk.cd, pT);
4144 INT_PTR nRet = ::PropertySheet(&m_psh);
4151 void _CleanUpPages()
4154 m_psh.phpage = NULL;
4155 m_arrPages.RemoveAll();
4161 int GetPageCount()
const 4164 return m_arrPages.GetSize();
4165 return TBase::GetPageCount();
4168 int GetActiveIndex()
const 4171 return m_psh.nStartPage;
4172 return TBase::GetActiveIndex();
4175 HPROPSHEETPAGE GetPage(
int nPageIndex)
const 4177 ATLASSERT(m_hWnd == NULL);
4178 return (HPROPSHEETPAGE)m_arrPages[nPageIndex];
4181 int GetPageIndex(HPROPSHEETPAGE hPage)
const 4183 ATLASSERT(m_hWnd == NULL);
4184 return m_arrPages.Find((HPROPSHEETPAGE&)hPage);
4187 BOOL SetActivePage(
int nPageIndex)
4191 ATLASSERT(nPageIndex >= 0 && nPageIndex < m_arrPages.GetSize());
4192 m_psh.nStartPage = nPageIndex;
4195 return TBase::SetActivePage(nPageIndex);
4198 BOOL SetActivePage(HPROPSHEETPAGE hPage)
4200 ATLASSERT(hPage != NULL);
4203 int nPageIndex = GetPageIndex(hPage);
4204 if(nPageIndex == -1)
4207 return SetActivePage(nPageIndex);
4209 return TBase::SetActivePage(hPage);
4213 void SetTitle(LPCTSTR lpszText, UINT nStyle = 0)
4215 ATLASSERT((nStyle & ~PSH_PROPTITLE) == 0);
4216 ATLASSERT(lpszText != NULL);
4221 m_psh.pszCaption = lpszText;
4222 m_psh.dwFlags &= ~PSH_PROPTITLE;
4223 m_psh.dwFlags |= nStyle;
4228 TBase::SetTitle(lpszText, nStyle);
4232 #if defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) // PPC specific Link field 4233 void SetLinkText(LPCTSTR lpszText)
4235 ATLASSERT(lpszText != NULL);
4236 ATLASSERT(lstrlen(lpszText) < PROPSHEET_LINK_SIZE);
4237 lstrcpy(m_szLink, lpszText);
4239 #endif // defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) 4241 void SetWizardMode()
4243 m_psh.dwFlags |= PSH_WIZARD;
4248 m_psh.dwFlags |= PSH_HASHELP;
4252 BOOL AddPage(HPROPSHEETPAGE hPage)
4254 ATLASSERT(hPage != NULL);
4257 bRet = TBase::AddPage(hPage);
4259 bRet = m_arrPages.Add((HPROPSHEETPAGE&)hPage);
4263 BOOL AddPage(LPCPROPSHEETPAGE pPage)
4265 ATLASSERT(pPage != NULL);
4266 HPROPSHEETPAGE hPage = ::CreatePropertySheetPage(pPage);
4269 BOOL bRet = AddPage(hPage);
4271 ::DestroyPropertySheetPage(hPage);
4275 BOOL RemovePage(HPROPSHEETPAGE hPage)
4277 ATLASSERT(hPage != NULL);
4280 int nPage = GetPageIndex(hPage);
4283 return RemovePage(nPage);
4285 TBase::RemovePage(hPage);
4290 BOOL RemovePage(
int nPageIndex)
4294 TBase::RemovePage(nPageIndex);
4296 bRet = m_arrPages.RemoveAt(nPageIndex);
4300 #if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) 4301 void SetHeader(LPCTSTR szbmHeader)
4303 ATLASSERT(m_hWnd == NULL);
4305 m_psh.dwFlags &= ~PSH_WIZARD;
4306 m_psh.dwFlags |= (PSH_HEADER | PSH_WIZARD97);
4307 m_psh.pszbmHeader = szbmHeader;
4310 void SetHeader(HBITMAP hbmHeader)
4312 ATLASSERT(m_hWnd == NULL);
4314 m_psh.dwFlags &= ~PSH_WIZARD;
4315 m_psh.dwFlags |= (PSH_HEADER | PSH_USEHBMHEADER | PSH_WIZARD97);
4316 m_psh.hbmHeader = hbmHeader;
4319 void SetWatermark(LPCTSTR szbmWatermark, HPALETTE hplWatermark = NULL)
4321 ATLASSERT(m_hWnd == NULL);
4323 m_psh.dwFlags &= ~PSH_WIZARD;
4324 m_psh.dwFlags |= PSH_WATERMARK | PSH_WIZARD97;
4325 m_psh.pszbmWatermark = szbmWatermark;
4327 if (hplWatermark != NULL)
4329 m_psh.dwFlags |= PSH_USEHPLWATERMARK;
4330 m_psh.hplWatermark = hplWatermark;
4334 void SetWatermark(HBITMAP hbmWatermark, HPALETTE hplWatermark = NULL)
4336 ATLASSERT(m_hWnd == NULL);
4338 m_psh.dwFlags &= ~PSH_WIZARD;
4339 m_psh.dwFlags |= (PSH_WATERMARK | PSH_USEHBMWATERMARK | PSH_WIZARD97);
4340 m_psh.hbmWatermark = hbmWatermark;
4342 if (hplWatermark != NULL)
4344 m_psh.dwFlags |= PSH_USEHPLWATERMARK;
4345 m_psh.hplWatermark = hplWatermark;
4349 void StretchWatermark(
bool bStretchWatermark)
4351 ATLASSERT(m_hWnd == NULL);
4352 if (bStretchWatermark)
4353 m_psh.dwFlags |= PSH_STRETCHWATERMARK;
4355 m_psh.dwFlags &= ~PSH_STRETCHWATERMARK;
4357 #endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) 4361 MESSAGE_HANDLER(WM_COMMAND, OnCommand)
4362 MESSAGE_HANDLER(WM_SYSCOMMAND, OnSysCommand)
4365 LRESULT OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& )
4367 LRESULT lRet = DefWindowProc(uMsg, wParam, lParam);
4368 if(HIWORD(wParam) == BN_CLICKED && (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) &&
4369 ((m_psh.dwFlags & PSH_MODELESS) != 0) && (GetActivePage() == NULL))
4374 LRESULT OnSysCommand(UINT , WPARAM wParam, LPARAM , BOOL& bHandled)
4376 if(((m_psh.dwFlags & PSH_MODELESS) == PSH_MODELESS) && ((wParam & 0xFFF0) == SC_CLOSE))
4377 SendMessage(WM_CLOSE);
4384 #if defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) // PPC static pointers 4385 template <
class T,
class TBase >
4387 template <
class T,
class TBase>
4389 #endif // defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) 4420 ATLASSERT(::IsWindow(m_hWnd));
4427 ATLASSERT(::IsWindow(m_hWnd));
4428 ATLASSERT(GetParent() != NULL);
4429 return GetPropertySheet().Apply();
4432 void CancelToClose()
4434 ATLASSERT(::IsWindow(m_hWnd));
4435 ATLASSERT(GetParent() != NULL);
4436 GetPropertySheet().CancelToClose();
4439 void SetModified(BOOL bChanged = TRUE)
4441 ATLASSERT(::IsWindow(m_hWnd));
4442 ATLASSERT(GetParent() != NULL);
4443 GetPropertySheet().SetModified(m_hWnd, bChanged);
4446 LRESULT QuerySiblings(WPARAM wParam, LPARAM lParam)
4448 ATLASSERT(::IsWindow(m_hWnd));
4449 ATLASSERT(GetParent() != NULL);
4450 return GetPropertySheet().QuerySiblings(wParam, lParam);
4455 ATLASSERT(::IsWindow(m_hWnd));
4456 ATLASSERT(GetParent() != NULL);
4457 GetPropertySheet().RebootSystem();
4460 void RestartWindows()
4462 ATLASSERT(::IsWindow(m_hWnd));
4463 ATLASSERT(GetParent() != NULL);
4464 GetPropertySheet().RestartWindows();
4467 void SetWizardButtons(DWORD dwFlags)
4469 ATLASSERT(::IsWindow(m_hWnd));
4470 ATLASSERT(GetParent() != NULL);
4471 GetPropertySheet().SetWizardButtons(dwFlags);
4485 template <
class T,
class TBase = CPropertyPageWindow>
4489 PROPSHEETPAGE m_psp;
4491 operator PROPSHEETPAGE*() {
return &m_psp; }
4497 memset(&m_psp, 0,
sizeof(PROPSHEETPAGE));
4498 m_psp.dwSize =
sizeof(PROPSHEETPAGE);
4499 m_psp.dwFlags = PSP_USECALLBACK;
4500 m_psp.hInstance = ModuleHelper::GetResourceInstance();
4501 T* pT =
static_cast<T*
>(
this);
4502 m_psp.pszTemplate = MAKEINTRESOURCE(pT->IDD);
4503 m_psp.pfnDlgProc = (DLGPROC)T::StartDialogProc;
4504 m_psp.pfnCallback = T::PropPageCallback;
4505 m_psp.lParam = (LPARAM)pT;
4507 if(title.m_lpstr != NULL)
4512 static UINT CALLBACK PropPageCallback(HWND hWnd, UINT uMsg, LPPROPSHEETPAGE ppsp)
4515 ATLASSERT(hWnd == NULL);
4516 T* pT = (T*)ppsp->lParam;
4523 ATL::CDialogImplBaseT< TBase >* pPage = (ATL::CDialogImplBaseT< TBase >*)pT;
4524 ModuleHelper::AddCreateWndData(&pPage->m_thunk.cd, pPage);
4525 uRet = pT->OnPageCreate() ? 1 : 0;
4528 #if (_WIN32_IE >= 0x0500) 4532 #endif // (_WIN32_IE >= 0x0500) 4534 pT->OnPageRelease();
4548 #if (_WIN32_IE >= 0x0500) 4552 #endif // (_WIN32_IE >= 0x0500) 4554 void OnPageRelease()
4559 HPROPSHEETPAGE Create()
4561 return ::CreatePropertySheetPage(&m_psp);
4567 m_psp.pszTitle = title.m_lpstr;
4568 m_psp.dwFlags |= PSP_USETITLE;
4571 #if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) 4572 void SetHeaderTitle(LPCTSTR lpstrHeaderTitle)
4574 ATLASSERT(m_hWnd == NULL);
4575 m_psp.dwFlags |= PSP_USEHEADERTITLE;
4576 m_psp.pszHeaderTitle = lpstrHeaderTitle;
4579 void SetHeaderSubTitle(LPCTSTR lpstrHeaderSubTitle)
4581 ATLASSERT(m_hWnd == NULL);
4582 m_psp.dwFlags |= PSP_USEHEADERSUBTITLE;
4583 m_psp.pszHeaderSubTitle = lpstrHeaderSubTitle;
4585 #endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) 4590 m_psp.dwFlags |= PSP_HASHELP;
4595 MESSAGE_HANDLER(WM_NOTIFY, OnNotify)
4600 LRESULT OnNotify(UINT , WPARAM , LPARAM lParam, BOOL& bHandled)
4604 ATLASSERT(::IsWindow(m_hWnd));
4606 NMHDR* pNMHDR = (NMHDR*)lParam;
4609 if(pNMHDR->hwndFrom != m_hWnd && pNMHDR->hwndFrom != ::GetParent(m_hWnd))
4615 ATLASSERT(::IsWindow(m_hWnd));
4618 T* pT =
static_cast<T*
>(
this);
4619 LRESULT lResult = 0;
4620 switch(pNMHDR->code)
4622 #ifdef _WTL_NEW_PAGE_NOTIFY_HANDLERS 4624 lResult = pT->OnSetActive();
4626 case PSN_KILLACTIVE:
4627 lResult = pT->OnKillActive();
4630 lResult = pT->OnApply();
4635 case PSN_QUERYCANCEL:
4636 lResult = pT->OnQueryCancel();
4639 lResult = pT->OnWizardNext();
4642 lResult = pT->OnWizardBack();
4645 lResult = pT->OnWizardFinish();
4651 #if (_WIN32_IE >= 0x0400) 4653 if(!pT->OnGetObject((LPNMOBJECTNOTIFY)lParam))
4656 #endif // (_WIN32_IE >= 0x0400) 4657 #if (_WIN32_IE >= 0x0500) 4658 case PSN_TRANSLATEACCELERATOR:
4660 LPPSHNOTIFY lpPSHNotify = (LPPSHNOTIFY)lParam;
4661 lResult = pT->OnTranslateAccelerator((LPMSG)lpPSHNotify->lParam);
4664 case PSN_QUERYINITIALFOCUS:
4666 LPPSHNOTIFY lpPSHNotify = (LPPSHNOTIFY)lParam;
4667 lResult = (LRESULT)pT->OnQueryInitialFocus((HWND)lpPSHNotify->lParam);
4670 #endif // (_WIN32_IE >= 0x0500) 4671 #endif // !_WIN32_WCE 4673 #else // !_WTL_NEW_PAGE_NOTIFY_HANDLERS 4675 lResult = pT->OnSetActive() ? 0 : -1;
4677 case PSN_KILLACTIVE:
4678 lResult = !pT->OnKillActive();
4681 lResult = pT->OnApply() ? PSNRET_NOERROR : PSNRET_INVALID_NOCHANGEPAGE;
4686 case PSN_QUERYCANCEL:
4687 lResult = !pT->OnQueryCancel();
4690 lResult = pT->OnWizardNext();
4693 lResult = pT->OnWizardBack();
4696 lResult = !pT->OnWizardFinish();
4702 #if (_WIN32_IE >= 0x0400) 4704 if(!pT->OnGetObject((LPNMOBJECTNOTIFY)lParam))
4707 #endif // (_WIN32_IE >= 0x0400) 4708 #if (_WIN32_IE >= 0x0500) 4709 case PSN_TRANSLATEACCELERATOR:
4711 LPPSHNOTIFY lpPSHNotify = (LPPSHNOTIFY)lParam;
4712 lResult = pT->OnTranslateAccelerator((LPMSG)lpPSHNotify->lParam) ? PSNRET_MESSAGEHANDLED : PSNRET_NOERROR;
4715 case PSN_QUERYINITIALFOCUS:
4717 LPPSHNOTIFY lpPSHNotify = (LPPSHNOTIFY)lParam;
4718 lResult = (LRESULT)pT->OnQueryInitialFocus((HWND)lpPSHNotify->lParam);
4721 #endif // (_WIN32_IE >= 0x0500) 4722 #endif // !_WIN32_WCE 4724 #endif // !_WTL_NEW_PAGE_NOTIFY_HANDLERS 4735 #ifdef _WTL_NEW_PAGE_NOTIFY_HANDLERS 4756 return PSNRET_NOERROR;
4763 BOOL OnQueryCancel()
4786 INT_PTR OnWizardFinish()
4799 #if (_WIN32_IE >= 0x0400) 4800 BOOL OnGetObject(LPNMOBJECTNOTIFY )
4804 #endif // (_WIN32_IE >= 0x0400) 4806 #if (_WIN32_IE >= 0x0500) 4807 int OnTranslateAccelerator(LPMSG )
4811 return PSNRET_NOERROR;
4814 HWND OnQueryInitialFocus(HWND )
4820 #endif // (_WIN32_IE >= 0x0500) 4821 #endif // !_WIN32_WCE 4823 #else // !_WTL_NEW_PAGE_NOTIFY_HANDLERS 4843 BOOL OnQueryCancel()
4864 BOOL OnWizardFinish()
4874 #if (_WIN32_IE >= 0x0400) 4875 BOOL OnGetObject(LPNMOBJECTNOTIFY )
4879 #endif // (_WIN32_IE >= 0x0400) 4881 #if (_WIN32_IE >= 0x0500) 4882 BOOL OnTranslateAccelerator(LPMSG )
4887 HWND OnQueryInitialFocus(HWND )
4891 #endif // (_WIN32_IE >= 0x0500) 4892 #endif // !_WIN32_WCE 4894 #endif // !_WTL_NEW_PAGE_NOTIFY_HANDLERS 4898 template <WORD t_wDlgTemplateID>
4902 enum { IDD = t_wDlgTemplateID };
4907 DECLARE_EMPTY_MSG_MAP()
4913 #ifndef _ATL_NO_HOSTING 4917 template <
class T,
class TBase = CPropertyPageWindow>
4922 HGLOBAL m_hInitData;
4924 HGLOBAL m_hDlgResSplit;
4929 m_hInitData(NULL), m_hDlgRes(NULL), m_hDlgResSplit(NULL)
4931 T* pT =
static_cast<T*
>(
this);
4935 ATL::AtlAxWinInit();
4937 HINSTANCE hInstance = ModuleHelper::GetResourceInstance();
4938 LPCTSTR lpTemplateName = MAKEINTRESOURCE(pT->IDD);
4939 HRSRC hDlg = ::FindResource(hInstance, lpTemplateName, (LPTSTR)RT_DIALOG);
4942 HRSRC hDlgInit = ::FindResource(hInstance, lpTemplateName, (LPTSTR)_ATL_RT_DLGINIT);
4944 BYTE* pInitData = NULL;
4945 if(hDlgInit != NULL)
4947 m_hInitData = ::LoadResource(hInstance, hDlgInit);
4948 pInitData = (BYTE*)::LockResource(m_hInitData);
4951 m_hDlgRes = ::LoadResource(hInstance, hDlg);
4952 DLGTEMPLATE* pDlg = (DLGTEMPLATE*)::LockResource(m_hDlgRes);
4953 LPCDLGTEMPLATE lpDialogTemplate = ATL::_DialogSplitHelper::SplitDialogTemplate(pDlg, pInitData);
4954 if(lpDialogTemplate != pDlg)
4955 m_hDlgResSplit = GlobalHandle(lpDialogTemplate);
4958 if(lpDialogTemplate != NULL)
4960 m_psp.dwFlags |= PSP_DLGINDIRECT;
4961 m_psp.pResource = lpDialogTemplate;
4965 ATLASSERT(FALSE && _T(
"CAxPropertyPageImpl - ActiveX initializtion failed!"));
4970 ATLASSERT(FALSE && _T(
"CAxPropertyPageImpl - Cannot find dialog template!"));
4976 if(m_hInitData != NULL)
4978 UnlockResource(m_hInitData);
4979 FreeResource(m_hInitData);
4981 if(m_hDlgRes != NULL)
4983 UnlockResource(m_hDlgRes);
4984 FreeResource(m_hDlgRes);
4986 if(m_hDlgResSplit != NULL)
4988 ::GlobalFree(m_hDlgResSplit);
4994 BOOL PreTranslateMessage(LPMSG pMsg)
4996 if ((pMsg->message < WM_KEYFIRST || pMsg->message > WM_KEYLAST) &&
4997 (pMsg->message < WM_MOUSEFIRST || pMsg->message > WM_MOUSELAST))
5000 HWND hWndCtl = ::GetFocus();
5001 if (IsChild(hWndCtl) && ::GetParent(hWndCtl) != m_hWnd)
5005 hWndCtl = ::GetParent(hWndCtl);
5007 while (::GetParent(hWndCtl) != m_hWnd);
5010 return (BOOL)::SendMessage(hWndCtl, WM_FORWARDMSG, 0, (LPARAM)pMsg);
5014 #if (_WIN32_IE >= 0x0500) 5016 #ifdef _WTL_NEW_PAGE_NOTIFY_HANDLERS 5017 int OnTranslateAccelerator(LPMSG lpMsg)
5019 T* pT =
static_cast<T*
>(
this);
5020 return (pT->PreTranslateMessage(lpMsg) != FALSE) ? PSNRET_MESSAGEHANDLED : PSNRET_NOERROR;
5022 #else // !_WTL_NEW_PAGE_NOTIFY_HANDLERS 5023 BOOL OnTranslateAccelerator(LPMSG lpMsg)
5025 T* pT =
static_cast<T*
>(
this);
5026 return pT->PreTranslateMessage(lpMsg);
5028 #endif // !_WTL_NEW_PAGE_NOTIFY_HANDLERS 5029 #endif // (_WIN32_IE >= 0x0500) 5032 #if (_ATL_VER >= 0x0700) 5035 return( static_cast<T*>(
this)->IDD );
5038 virtual DLGPROC GetDialogProc()
5043 static INT_PTR CALLBACK DialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
5046 if (uMsg == WM_INITDIALOG)
5049 if (FAILED(hr = pThis->CreateActiveXControls(pThis->GetIDD())))
5059 virtual HRESULT CreateActiveXControls(UINT nID)
5062 HRSRC hDlgInit = ::FindResource(ATL::_AtlBaseModule.GetResourceInstance(), MAKEINTRESOURCE(nID), (LPTSTR)_ATL_RT_DLGINIT);
5063 BYTE* pInitData = NULL;
5064 HGLOBAL hData = NULL;
5066 if (hDlgInit != NULL)
5068 hData = ::LoadResource(ATL::_AtlBaseModule.GetResourceInstance(), hDlgInit);
5070 pInitData = (BYTE*) ::LockResource(hData);
5073 HRSRC hDlg = ::FindResource(ATL::_AtlBaseModule.GetResourceInstance(), MAKEINTRESOURCE(nID), (LPTSTR)RT_DIALOG);
5076 HGLOBAL hResource = ::LoadResource(ATL::_AtlBaseModule.GetResourceInstance(), hDlg);
5077 DLGTEMPLATE* pDlg = NULL;
5078 if (hResource != NULL)
5080 pDlg = (DLGTEMPLATE*) ::LockResource(hResource);
5084 BOOL bDialogEx = ATL::_DialogSplitHelper::IsDialogEx(pDlg);
5085 WORD nItems = ATL::_DialogSplitHelper::DlgTemplateItemCount(pDlg);
5088 DLGITEMTEMPLATE* pItem = ATL::_DialogSplitHelper::FindFirstDlgItem(pDlg);
5089 HWND hWndPrev = GetWindow(GW_CHILD);
5092 for (WORD nItem = 0; nItem < nItems; nItem++)
5094 DWORD wID = bDialogEx ? ((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem)->id : pItem->id;
5095 if (ATL::_DialogSplitHelper::IsActiveXControl(pItem, bDialogEx))
5098 DWORD dwLen = ATL::_DialogSplitHelper::FindCreateData(wID, pInitData, &pData);
5099 ATL::CComPtr<IStream> spStream;
5102 HGLOBAL h = GlobalAlloc(GHND, dwLen);
5105 BYTE* pBytes = (BYTE*) GlobalLock(h);
5106 BYTE* pSource = pData;
5107 SecureHelper::memcpy_x(pBytes, dwLen, pSource, dwLen);
5109 CreateStreamOnHGlobal(h, TRUE, &spStream);
5118 ATL::CComBSTR bstrLicKey;
5119 hr = ATL::_DialogSplitHelper::ParseInitData(spStream, &bstrLicKey.m_str);
5122 ATL::CAxWindow2 wnd;
5124 LPWSTR pszClassName =
5126 (LPWSTR)(((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem) + 1) :
5127 (LPWSTR)(pItem + 1);
5130 rect.left = bDialogEx ? ((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem)->x : pItem->x;
5131 rect.top = bDialogEx ? ((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem)->y : pItem->y;
5132 rect.right = rect.left + (bDialogEx ? ((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem)->cx : pItem->cx);
5133 rect.bottom = rect.top + (bDialogEx ? ((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem)->cy : pItem->cy);
5136 MapDialogRect(&rect);
5143 ((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem)->style :
5144 pItem->style) | WS_TABSTOP,
5146 ((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem)->exStyle :
5149 ((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem)->id :
5157 if (bDialogEx && ((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem)->helpID != 0)
5158 wnd.SetWindowContextHelpId(((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem)->helpID);
5159 #endif // !_WIN32_WCE 5161 hr = wnd.CreateControlLic(pszClassName, spStream, NULL, bstrLicKey);
5166 hWndPrev = HWND_TOP;
5167 wnd.SetWindowPos(hWndPrev, 0,0,0,0,SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
5172 hr = ATL::AtlHresultFromLastError();
5179 hWndPrev = ::GetWindow(hWndPrev, GW_HWNDNEXT);
5181 pItem = ATL::_DialogSplitHelper::FindNextDlgItem(pItem, bDialogEx);
5185 hr = ATL::AtlHresultFromLastError();
5188 hr = ATL::AtlHresultFromLastError();
5194 HRESULT AdviseSinkMap(
bool bAdvise)
5196 if(!bAdvise && m_hWnd == NULL)
5199 ATLTRACE2(atlTraceUI, 0, _T(
"CAxPropertyPageImpl::AdviseSinkMap called after the window was destroyed\n"));
5202 HRESULT hRet = E_NOTIMPL;
5203 __if_exists(T::_GetSinkMapFinder)
5205 T* pT =
static_cast<T*
>(
this);
5206 hRet = AtlAdviseSinkMap(pT, bAdvise);
5214 MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
5215 MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
5216 CHAIN_MSG_MAP(_baseClass)
5219 LRESULT OnInitDialog(UINT , WPARAM , LPARAM , BOOL& bHandled)
5222 ExecuteDlgInit(static_cast<T*>(
this)->IDD);
5223 AdviseSinkMap(
true);
5228 LRESULT OnDestroy(UINT , WPARAM , LPARAM , BOOL& bHandled)
5230 AdviseSinkMap(
false);
5234 #endif // (_ATL_VER >= 0x0700) 5238 template <WORD t_wDlgTemplateID>
5242 enum { IDD = t_wDlgTemplateID };
5247 #if (_WIN32_IE >= 0x0500) || (_ATL_VER >= 0x0700) 5252 #else // !((_WIN32_IE >= 0x0500) || (_ATL_VER >= 0x0700)) 5253 DECLARE_EMPTY_MSG_MAP()
5254 #endif // !((_WIN32_IE >= 0x0500) || (_ATL_VER >= 0x0700)) 5257 #endif // _ATL_NO_HOSTING 5263 #if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) 5334 CWizard97SheetWindow& operator =(HWND hWnd)
5341 HFONT GetExteriorPageTitleFont(
void)
5343 ATLASSERT(::IsWindow(m_hWnd));
5344 return (HFONT)::SendMessage(m_hWnd, GetMessage_GetExteriorPageTitleFont(), 0, 0L);
5347 HFONT GetBulletFont(
void)
5349 ATLASSERT(::IsWindow(m_hWnd));
5350 return (HFONT)::SendMessage(m_hWnd, GetMessage_GetBulletFont(), 0, 0L);
5354 static UINT GetMessage_GetExteriorPageTitleFont()
5356 static UINT uGetExteriorPageTitleFont = 0;
5357 if(uGetExteriorPageTitleFont == 0)
5360 if(FAILED(lock.Lock()))
5362 ATLTRACE2(atlTraceUI, 0, _T(
"ERROR : Unable to lock critical section in CWizard97SheetWindow::GetMessage_GetExteriorPageTitleFont().\n"));
5367 if(uGetExteriorPageTitleFont == 0)
5368 uGetExteriorPageTitleFont = ::RegisterWindowMessage(_T(
"GetExteriorPageTitleFont_531AF056-B8BE-4c4c-B786-AC608DF0DF12"));
5372 ATLASSERT(uGetExteriorPageTitleFont != 0);
5373 return uGetExteriorPageTitleFont;
5376 static UINT GetMessage_GetBulletFont()
5378 static UINT uGetBulletFont = 0;
5379 if(uGetBulletFont == 0)
5382 if(FAILED(lock.Lock()))
5384 ATLTRACE2(atlTraceUI, 0, _T(
"ERROR : Unable to lock critical section in CWizard97SheetWindow::GetMessage_GetBulletFont().\n"));
5389 if(uGetBulletFont == 0)
5390 uGetBulletFont = ::RegisterWindowMessage(_T(
"GetBulletFont_AD347D08-8F65-45ef-982E-6352E8218AD5"));
5394 ATLASSERT(uGetBulletFont != 0);
5395 return uGetBulletFont;
5410 template <
class T,
class TBase = CWizard97SheetWindow>
5415 typedef CWizard97SheetImpl< T, TBase > thisClass;
5419 CFont m_fontExteriorPageTitle;
5421 bool m_bReceivedFirstSizeMessage;
5425 baseClass(title, uStartPage, hWndParent),
5426 m_bReceivedFirstSizeMessage(
false)
5428 m_psh.dwFlags &= ~(PSH_NOCONTEXTHELP);
5429 m_psh.dwFlags &= ~(PSH_WIZARD | PSH_WIZARD_LITE);
5431 m_psh.dwFlags |= (PSH_HASHELP | PSH_WIZARDCONTEXTHELP);
5432 m_psh.dwFlags |= PSH_WIZARD97;
5434 baseClass::SetHeader(headerBitmap.m_lpstr);
5435 baseClass::SetWatermark(watermarkBitmap.m_lpstr);
5439 void OnSheetInitialized()
5441 T* pT =
static_cast<T*
>(
this);
5442 pT->_InitializeFonts();
5449 void _InitializeFonts()
5458 LOGFONT titleLogFont = {0};
5459 LOGFONT bulletLogFont = {0};
5460 fontThisDialog.GetLogFont(&titleLogFont);
5461 fontThisDialog.GetLogFont(&bulletLogFont);
5465 titleLogFont.lfCharSet = DEFAULT_CHARSET;
5466 titleLogFont.lfWeight = FW_BOLD;
5467 SecureHelper::strcpy_x(titleLogFont.lfFaceName, _countof(titleLogFont.lfFaceName), _T(
"Verdana Bold"));
5468 INT titleFontPointSize = 12;
5469 titleLogFont.lfHeight = -::MulDiv(titleFontPointSize, dcScreen.GetDeviceCaps(LOGPIXELSY), 72);
5470 m_fontExteriorPageTitle.CreateFontIndirect(&titleLogFont);
5474 bulletLogFont.lfCharSet = DEFAULT_CHARSET;
5475 bulletLogFont.lfWeight = FW_NORMAL;
5476 SecureHelper::strcpy_x(bulletLogFont.lfFaceName, _countof(bulletLogFont.lfFaceName), _T(
"Marlett"));
5477 INT bulletFontSize = 8;
5478 bulletLogFont.lfHeight = -::MulDiv(bulletFontSize, dcScreen.GetDeviceCaps(LOGPIXELSY), 72);
5479 m_fontBullet.CreateFontIndirect(&bulletLogFont);
5483 BEGIN_MSG_MAP(thisClass)
5484 MESSAGE_HANDLER(CWizard97SheetWindow::GetMessage_GetExteriorPageTitleFont(), OnGetExteriorPageTitleFont)
5485 MESSAGE_HANDLER(CWizard97SheetWindow::GetMessage_GetBulletFont(), OnGetBulletFont)
5486 MESSAGE_HANDLER(WM_SIZE, OnSize)
5487 CHAIN_MSG_MAP(baseClass)
5490 LRESULT OnGetExteriorPageTitleFont(UINT , WPARAM , LPARAM , BOOL& )
5492 return (LRESULT)(HFONT)m_fontExteriorPageTitle;
5495 LRESULT OnGetBulletFont(UINT , WPARAM , LPARAM , BOOL& )
5497 return (LRESULT)(HFONT)m_fontBullet;
5500 LRESULT OnSize(UINT , WPARAM , LPARAM , BOOL& bHandled)
5502 if(!m_bReceivedFirstSizeMessage)
5504 m_bReceivedFirstSizeMessage =
true;
5505 this->CenterWindow();
5514 class CWizard97Sheet :
public CWizard97SheetImpl<CWizard97Sheet>
5518 typedef CWizard97Sheet thisClass;
5519 typedef CWizard97SheetImpl<CWizard97Sheet> baseClass;
5523 baseClass(title, headerBitmap, watermarkBitmap, uStartPage, hWndParent)
5526 BEGIN_MSG_MAP(thisClass)
5527 CHAIN_MSG_MAP(baseClass)
5535 #define WIZARD97_EXTERIOR_CXDLG 317 5536 #define WIZARD97_EXTERIOR_CYDLG 193 5538 #define WIZARD97_INTERIOR_CXDLG 317 5539 #define WIZARD97_INTERIOR_CYDLG 143 5548 CWizard97PageWindow& operator =(HWND hWnd)
5555 CWizard97SheetWindow GetPropertySheet()
const 5557 ATLASSERT(::IsWindow(m_hWnd));
5558 return CWizard97SheetWindow(GetParent());
5562 HFONT GetExteriorPageTitleFont(
void)
5564 ATLASSERT(::IsWindow(m_hWnd));
5565 return GetPropertySheet().GetExteriorPageTitleFont();
5568 HFONT GetBulletFont(
void)
5570 ATLASSERT(::IsWindow(m_hWnd));
5571 return GetPropertySheet().GetBulletFont();
5587 template <
class T,
class TBase = CWizard97PageWindow>
5592 typedef CWizard97PageImpl< T, TBase > thisClass;
5600 BEGIN_MSG_MAP(thisClass)
5601 CHAIN_MSG_MAP(baseClass)
5609 template <
class T,
class TBase = CWizard97PageWindow>
5610 class ATL_NO_VTABLE CWizard97ExteriorPageImpl :
public CPropertyPageImpl< T, TBase >
5614 typedef CWizard97ExteriorPageImpl< T, TBase > thisClass;
5619 CWizard97ExteriorPageImpl(
ATL::_U_STRINGorID title = (LPCTSTR)NULL) : baseClass(title)
5621 m_psp.dwFlags |= PSP_HASHELP;
5622 m_psp.dwFlags |= PSP_HIDEHEADER;
5626 BEGIN_MSG_MAP(thisClass)
5627 CHAIN_MSG_MAP(baseClass)
5635 template <
class T,
class TBase = CWizard97PageWindow>
5636 class ATL_NO_VTABLE CWizard97InteriorPageImpl :
public CPropertyPageImpl< T, TBase >
5640 typedef CWizard97InteriorPageImpl< T, TBase > thisClass;
5645 CWizard97InteriorPageImpl(
ATL::_U_STRINGorID title = (LPCTSTR)NULL) : baseClass(title)
5647 m_psp.dwFlags |= PSP_HASHELP;
5648 m_psp.dwFlags &= ~PSP_HIDEHEADER;
5649 m_psp.dwFlags |= PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
5653 baseClass::SetHeaderTitle(_T(
"Call SetHeaderTitle in Derived Class"));
5654 baseClass::SetHeaderSubTitle(_T(
"Call SetHeaderSubTitle in the constructor of the Derived Class."));
5658 BEGIN_MSG_MAP(thisClass)
5659 CHAIN_MSG_MAP(baseClass)
5663 #endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) 5669 #if (_WIN32_WINNT >= 0x0600) && !defined(_WIN32_WCE) 5681 CAeroWizardFrameWindow& operator =(HWND hWnd)
5688 void SetNextText(LPCWSTR lpszText)
5690 ATLASSERT(::IsWindow(m_hWnd));
5691 ::SendMessage(m_hWnd, PSM_SETNEXTTEXT, 0, (LPARAM)lpszText);
5694 void ShowWizardButtons(DWORD dwButtons, DWORD dwStates)
5696 ATLASSERT(::IsWindow(m_hWnd));
5697 ::PostMessage(m_hWnd, PSM_SHOWWIZBUTTONS, (WPARAM)dwStates, (LPARAM)dwButtons);
5700 void EnableWizardButtons(DWORD dwButtons, DWORD dwStates)
5702 ATLASSERT(::IsWindow(m_hWnd));
5703 ::PostMessage(m_hWnd, PSM_ENABLEWIZBUTTONS, (WPARAM)dwStates, (LPARAM)dwButtons);
5706 void SetButtonText(DWORD dwButton, LPCWSTR lpszText)
5708 ATLASSERT(::IsWindow(m_hWnd));
5709 ::SendMessage(m_hWnd, PSM_SETBUTTONTEXT, (WPARAM)dwButton, (LPARAM)lpszText);
5717 template <
class T,
class TBase = CAeroWizardFrameWindow>
5722 CAeroWizardFrameImpl(
ATL::_U_STRINGorID title = (LPCTSTR)NULL, UINT uStartPage = 0, HWND hWndParent = NULL) :
5725 m_psh.dwFlags |= PSH_WIZARD | PSH_AEROWIZARD;
5729 void EnableResizing()
5731 ATLASSERT(m_hWnd == NULL);
5732 m_psh.dwFlags |= PSH_RESIZABLE;
5735 void UseHeaderBitmap()
5737 ATLASSERT(m_hWnd == NULL);
5738 m_psh.dwFlags |= PSH_HEADERBITMAP;
5743 ATLASSERT(m_hWnd == NULL);
5744 m_psh.dwFlags |= PSH_NOMARGIN;
5748 HWND Create(HWND = NULL)
5759 class CAeroWizardFrame :
public CAeroWizardFrameImpl<CAeroWizardFrame>
5762 CAeroWizardFrame(
ATL::_U_STRINGorID title = (LPCTSTR)NULL, UINT uStartPage = 0, HWND hWndParent = NULL)
5763 : CAeroWizardFrameImpl<CAeroWizardFrame>(title, uStartPage, hWndParent)
5766 BEGIN_MSG_MAP(CAeroWizardFrame)
5767 MESSAGE_HANDLER(WM_COMMAND, CAeroWizardFrameImpl<CAeroWizardFrame>::OnCommand)
5782 CAeroWizardPageWindow& operator =(HWND hWnd)
5789 CAeroWizardFrameWindow GetAeroWizardFrame()
const 5791 ATLASSERT(::IsWindow(m_hWnd));
5793 return CAeroWizardFrameWindow(GetParent());
5797 void SetNextText(LPCWSTR lpszText)
5799 ATLASSERT(::IsWindow(m_hWnd));
5800 ATLASSERT(GetParent() != NULL);
5801 GetAeroWizardFrame().SetNextText(lpszText);
5804 void ShowWizardButtons(DWORD dwButtons, DWORD dwStates)
5806 ATLASSERT(::IsWindow(m_hWnd));
5807 ATLASSERT(GetParent() != NULL);
5808 GetAeroWizardFrame().ShowWizardButtons(dwButtons, dwStates);
5811 void EnableWizardButtons(DWORD dwButtons, DWORD dwStates)
5813 ATLASSERT(::IsWindow(m_hWnd));
5814 ATLASSERT(GetParent() != NULL);
5815 GetAeroWizardFrame().EnableWizardButtons(dwButtons, dwStates);
5818 void SetButtonText(DWORD dwButton, LPCWSTR lpszText)
5820 ATLASSERT(::IsWindow(m_hWnd));
5821 ATLASSERT(GetParent() != NULL);
5822 GetAeroWizardFrame().SetButtonText(dwButton, lpszText);
5830 template <
class T,
class TBase = CAeroWizardPageWindow>
5842 template <WORD t_wDlgTemplateID>
5843 class CAeroWizardPage :
public CAeroWizardPageImpl<CAeroWizardPage<t_wDlgTemplateID> >
5846 enum { IDD = t_wDlgTemplateID };
5848 CAeroWizardPage(
ATL::_U_STRINGorID title = (LPCTSTR)NULL) : CAeroWizardPageImpl<CAeroWizardPage>(title)
5851 DECLARE_EMPTY_MSG_MAP()
5855 #ifndef _ATL_NO_HOSTING 5862 template <
class T,
class TBase = CAeroWizardPageWindow>
5874 template <WORD t_wDlgTemplateID>
5875 class CAeroWizardAxPage :
public CAeroWizardAxPageImpl<CAeroWizardAxPage<t_wDlgTemplateID> >
5878 enum { IDD = t_wDlgTemplateID };
5880 CAeroWizardAxPage(
ATL::_U_STRINGorID title = (LPCTSTR)NULL) : CAeroWizardAxPageImpl<CAeroWizardAxPage>(title)
5883 #if (_WIN32_IE >= 0x0500) || (_ATL_VER >= 0x0700) 5885 BEGIN_MSG_MAP(CAeroWizardAxPage)
5886 CHAIN_MSG_MAP(CAeroWizardAxPageImpl<CAeroWizardAxPage<t_wDlgTemplateID> >)
5888 #else // !((_WIN32_IE >= 0x0500) || (_ATL_VER >= 0x0700)) 5889 DECLARE_EMPTY_MSG_MAP()
5890 #endif // !((_WIN32_IE >= 0x0500) || (_ATL_VER >= 0x0700)) 5893 #endif // _ATL_NO_HOSTING 5895 #endif // (_WIN32_WINNT >= 0x0600) && !defined(_WIN32_WCE) 5901 #if ((_WIN32_WINNT >= 0x0600) || defined(_WTL_TASKDIALOG)) && !defined(_WIN32_WCE) 5906 inline int AtlTaskDialog(HWND hWndParent,
5908 TASKDIALOG_COMMON_BUTTON_FLAGS dwCommonButtons = 0U,
ATL::_U_STRINGorID Icon = (LPCTSTR)NULL)
5912 #ifdef _WTL_TASKDIALOG_DIRECT 5914 HRESULT hRet = ::TaskDialog(hWndParent, ModuleHelper::GetResourceInstance(),
5915 IS_INTRESOURCE(WindowTitle.m_lpstr) ? (LPCWSTR) WindowTitle.m_lpstr : T2CW(WindowTitle.m_lpstr),
5916 IS_INTRESOURCE(MainInstructionText.m_lpstr) ? (LPCWSTR) MainInstructionText.m_lpstr : T2CW(MainInstructionText.m_lpstr),
5917 IS_INTRESOURCE(ContentText.m_lpstr) ? (LPCWSTR) ContentText.m_lpstr : T2CW(ContentText.m_lpstr),
5919 IS_INTRESOURCE(Icon.m_lpstr) ? (LPCWSTR) Icon.m_lpstr : T2CW(Icon.m_lpstr),
5921 ATLVERIFY(SUCCEEDED(hRet));
5924 typedef HRESULT (STDAPICALLTYPE *PFN_TaskDialog)(HWND hwndParent, HINSTANCE hInstance, PCWSTR pszWindowTitle, PCWSTR pszMainInstruction, PCWSTR pszContent, TASKDIALOG_COMMON_BUTTON_FLAGS dwCommonButtons, PCWSTR pszIcon,
int* pnButton);
5926 HMODULE m_hCommCtrlDLL = ::LoadLibrary(_T(
"comctl32.dll"));
5927 if(m_hCommCtrlDLL != NULL)
5929 PFN_TaskDialog pfnTaskDialog = (PFN_TaskDialog)::GetProcAddress(m_hCommCtrlDLL,
"TaskDialog");
5930 if(pfnTaskDialog != NULL)
5933 HRESULT hRet = pfnTaskDialog(hWndParent, ModuleHelper::GetResourceInstance(),
5934 IS_INTRESOURCE(WindowTitle.m_lpstr) ? (LPCWSTR) WindowTitle.m_lpstr : T2CW(WindowTitle.m_lpstr),
5935 IS_INTRESOURCE(MainInstructionText.m_lpstr) ? (LPCWSTR) MainInstructionText.m_lpstr : T2CW(MainInstructionText.m_lpstr),
5936 IS_INTRESOURCE(ContentText.m_lpstr) ? (LPCWSTR) ContentText.m_lpstr : T2CW(ContentText.m_lpstr),
5938 IS_INTRESOURCE(Icon.m_lpstr) ? (LPCWSTR) Icon.m_lpstr : T2CW(Icon.m_lpstr),
5940 ATLVERIFY(SUCCEEDED(hRet));
5943 ::FreeLibrary(m_hCommCtrlDLL);
5954 class CTaskDialogConfig :
public TASKDIALOGCONFIG
5965 memset(
this, 0,
sizeof(TASKDIALOGCONFIG));
5966 this->cbSize =
sizeof(TASKDIALOGCONFIG);
5967 this->hInstance = ModuleHelper::GetResourceInstance();
5972 void SetCommonButtons(TASKDIALOG_COMMON_BUTTON_FLAGS dwCommonButtonsArg)
5974 this->dwCommonButtons = dwCommonButtonsArg;
5978 void SetWindowTitle(UINT nID)
5980 this->pszWindowTitle = MAKEINTRESOURCEW(nID);
5983 void SetWindowTitle(LPCWSTR lpstrWindowTitle)
5985 this->pszWindowTitle = lpstrWindowTitle;
5989 void SetMainIcon(HICON hIcon)
5991 this->dwFlags |= TDF_USE_HICON_MAIN;
5992 this->hMainIcon = hIcon;
5995 void SetMainIcon(UINT nID)
5997 this->dwFlags &= ~TDF_USE_HICON_MAIN;
5998 this->pszMainIcon = MAKEINTRESOURCEW(nID);
6001 void SetMainIcon(LPCWSTR lpstrMainIcon)
6003 this->dwFlags &= ~TDF_USE_HICON_MAIN;
6004 this->pszMainIcon = lpstrMainIcon;
6008 void SetMainInstructionText(UINT nID)
6010 this->pszMainInstruction = MAKEINTRESOURCEW(nID);
6013 void SetMainInstructionText(LPCWSTR lpstrMainInstruction)
6015 this->pszMainInstruction = lpstrMainInstruction;
6019 void SetContentText(UINT nID)
6021 this->pszContent = MAKEINTRESOURCEW(nID);
6024 void SetContentText(LPCWSTR lpstrContent)
6026 this->pszContent = lpstrContent;
6030 void SetButtons(
const TASKDIALOG_BUTTON* pButtonsArg, UINT cButtonsArg,
int nDefaultButtonArg = 0)
6032 this->pButtons = pButtonsArg;
6033 this->cButtons = cButtonsArg;
6034 if(nDefaultButtonArg != 0)
6035 this->nDefaultButton = nDefaultButtonArg;
6038 void SetDefaultButton(
int nDefaultButtonArg)
6040 this->nDefaultButton = nDefaultButtonArg;
6044 void SetRadioButtons(
const TASKDIALOG_BUTTON* pRadioButtonsArg, UINT cRadioButtonsArg,
int nDefaultRadioButtonArg = 0)
6046 this->pRadioButtons = pRadioButtonsArg;
6047 this->cRadioButtons = cRadioButtonsArg;
6048 if(nDefaultRadioButtonArg != 0)
6049 this->nDefaultRadioButton = nDefaultRadioButtonArg;
6052 void SetDefaultRadioButton(
int nDefaultRadioButtonArg)
6054 this->nDefaultRadioButton = nDefaultRadioButtonArg;
6058 void SetVerificationText(UINT nID)
6060 this->pszVerificationText = MAKEINTRESOURCEW(nID);
6063 void SetVerificationText(LPCWSTR lpstrVerificationText)
6065 this->pszVerificationText = lpstrVerificationText;
6069 void SetExpandedInformationText(UINT nID)
6071 this->pszExpandedInformation = MAKEINTRESOURCEW(nID);
6074 void SetExpandedInformationText(LPCWSTR lpstrExpandedInformation)
6076 this->pszExpandedInformation = lpstrExpandedInformation;
6080 void SetExpandedControlText(UINT nID)
6082 this->pszExpandedControlText = MAKEINTRESOURCEW(nID);
6085 void SetExpandedControlText(LPCWSTR lpstrExpandedControlText)
6087 this->pszExpandedControlText = lpstrExpandedControlText;
6091 void SetCollapsedControlText(UINT nID)
6093 this->pszCollapsedControlText = MAKEINTRESOURCEW(nID);
6096 void SetCollapsedControlText(LPCWSTR lpstrCollapsedControlText)
6098 this->pszCollapsedControlText = lpstrCollapsedControlText;
6102 void SetFooterIcon(HICON hIcon)
6104 this->dwFlags |= TDF_USE_HICON_FOOTER;
6105 this->hFooterIcon = hIcon;
6108 void SetFooterIcon(UINT nID)
6110 this->dwFlags &= ~TDF_USE_HICON_FOOTER;
6111 this->pszFooterIcon = MAKEINTRESOURCEW(nID);
6114 void SetFooterIcon(LPCWSTR lpstrFooterIcon)
6116 this->dwFlags &= ~TDF_USE_HICON_FOOTER;
6117 this->pszFooterIcon = lpstrFooterIcon;
6121 void SetFooterText(UINT nID)
6123 this->pszFooter = MAKEINTRESOURCEW(nID);
6126 void SetFooterText(LPCWSTR lpstrFooterText)
6128 this->pszFooter = lpstrFooterText;
6132 void SetWidth(UINT cxWidthArg)
6134 this->cxWidth = cxWidthArg;
6138 void ModifyFlags(DWORD dwRemove, DWORD dwAdd)
6140 this->dwFlags = (this->dwFlags & ~dwRemove) | dwAdd;
6149 class ATL_NO_VTABLE CTaskDialogImpl
6152 CTaskDialogConfig m_tdc;
6156 CTaskDialogImpl(HWND hWndParent = NULL) : m_hWnd(NULL)
6158 m_tdc.hwndParent = hWndParent;
6159 m_tdc.pfCallback = T::TaskDialogCallback;
6160 m_tdc.lpCallbackData = (LONG_PTR)static_cast<T*>(
this);
6164 HRESULT DoModal(HWND hWndParent = ::GetActiveWindow(),
int* pnButton = NULL,
int* pnRadioButton = NULL, BOOL* pfVerificationFlagChecked = NULL)
6166 if(m_tdc.hwndParent == NULL)
6167 m_tdc.hwndParent = hWndParent;
6169 #ifdef _WTL_TASKDIALOG_DIRECT 6170 return ::TaskDialogIndirect(&m_tdc, pnButton, pnRadioButton, pfVerificationFlagChecked);
6174 typedef HRESULT (STDAPICALLTYPE *PFN_TaskDialogIndirect)(
const TASKDIALOGCONFIG* pTaskConfig,
int* pnButton,
int* pnRadioButton, BOOL* pfVerificationFlagChecked);
6176 HRESULT hRet = E_UNEXPECTED;
6177 HMODULE m_hCommCtrlDLL = ::LoadLibrary(_T(
"comctl32.dll"));
6178 if(m_hCommCtrlDLL != NULL)
6180 PFN_TaskDialogIndirect pfnTaskDialogIndirect = (PFN_TaskDialogIndirect)::GetProcAddress(m_hCommCtrlDLL,
"TaskDialogIndirect");
6181 if(pfnTaskDialogIndirect != NULL)
6182 hRet = pfnTaskDialogIndirect(&m_tdc, pnButton, pnRadioButton, pfVerificationFlagChecked);
6184 ::FreeLibrary(m_hCommCtrlDLL);
6193 void SetCommonButtons(TASKDIALOG_COMMON_BUTTON_FLAGS dwCommonButtons)
6194 { m_tdc.SetCommonButtons(dwCommonButtons); }
6196 void SetWindowTitle(UINT nID)
6197 { m_tdc.SetWindowTitle(nID); }
6198 void SetWindowTitle(LPCWSTR lpstrWindowTitle)
6199 { m_tdc.SetWindowTitle(lpstrWindowTitle); }
6201 void SetMainIcon(HICON hIcon)
6202 { m_tdc.SetMainIcon(hIcon); }
6203 void SetMainIcon(UINT nID)
6204 { m_tdc.SetMainIcon(nID); }
6205 void SetMainIcon(LPCWSTR lpstrMainIcon)
6206 { m_tdc.SetMainIcon(lpstrMainIcon); }
6208 void SetMainInstructionText(UINT nID)
6209 { m_tdc.SetMainInstructionText(nID); }
6210 void SetMainInstructionText(LPCWSTR lpstrMainInstruction)
6211 { m_tdc.SetMainInstructionText(lpstrMainInstruction); }
6213 void SetContentText(UINT nID)
6214 { m_tdc.SetContentText(nID); }
6215 void SetContentText(LPCWSTR lpstrContent)
6216 { m_tdc.SetContentText(lpstrContent); }
6218 void SetButtons(
const TASKDIALOG_BUTTON* pButtons, UINT cButtons,
int nDefaultButton = 0)
6219 { m_tdc.SetButtons(pButtons, cButtons, nDefaultButton); }
6220 void SetDefaultButton(
int nDefaultButton)
6221 { m_tdc.SetDefaultButton(nDefaultButton); }
6223 void SetRadioButtons(
const TASKDIALOG_BUTTON* pRadioButtons, UINT cRadioButtons,
int nDefaultRadioButton = 0)
6224 { m_tdc.SetRadioButtons(pRadioButtons, cRadioButtons, nDefaultRadioButton); }
6225 void SetDefaultRadioButton(
int nDefaultRadioButton)
6226 { m_tdc.SetDefaultRadioButton(nDefaultRadioButton); }
6228 void SetVerificationText(UINT nID)
6229 { m_tdc.SetVerificationText(nID); }
6230 void SetVerificationText(LPCWSTR lpstrVerificationText)
6231 { m_tdc.SetVerificationText(lpstrVerificationText); }
6233 void SetExpandedInformationText(UINT nID)
6234 { m_tdc.SetExpandedInformationText(nID); }
6235 void SetExpandedInformationText(LPCWSTR lpstrExpandedInformation)
6236 { m_tdc.SetExpandedInformationText(lpstrExpandedInformation); }
6238 void SetExpandedControlText(UINT nID)
6239 { m_tdc.SetExpandedControlText(nID); }
6240 void SetExpandedControlText(LPCWSTR lpstrExpandedControlText)
6241 { m_tdc.SetExpandedControlText(lpstrExpandedControlText); }
6243 void SetCollapsedControlText(UINT nID)
6244 { m_tdc.SetCollapsedControlText(nID); }
6245 void SetCollapsedControlText(LPCWSTR lpstrCollapsedControlText)
6246 { m_tdc.SetCollapsedControlText(lpstrCollapsedControlText); }
6248 void SetFooterIcon(HICON hIcon)
6249 { m_tdc.SetFooterIcon(hIcon); }
6250 void SetFooterIcon(UINT nID)
6251 { m_tdc.SetFooterIcon(nID); }
6252 void SetFooterIcon(LPCWSTR lpstrFooterIcon)
6253 { m_tdc.SetFooterIcon(lpstrFooterIcon); }
6255 void SetFooterText(UINT nID)
6256 { m_tdc.SetFooterText(nID); }
6257 void SetFooterText(LPCWSTR lpstrFooterText)
6258 { m_tdc.SetFooterText(lpstrFooterText); }
6260 void SetWidth(UINT cxWidth)
6261 { m_tdc.SetWidth(cxWidth); }
6263 void ModifyFlags(DWORD dwRemove, DWORD dwAdd)
6264 { m_tdc.ModifyFlags(dwRemove, dwAdd); }
6267 static HRESULT CALLBACK TaskDialogCallback(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LONG_PTR lpRefData)
6269 T* pT = (T*)lpRefData;
6270 ATLASSERT(pT->m_hWnd == NULL || pT->m_hWnd == hWnd);
6275 case TDN_DIALOG_CONSTRUCTED:
6277 pT->OnDialogConstructed();
6282 case TDN_BUTTON_CLICKED:
6283 bRet = pT->OnButtonClicked((
int)wParam);
6285 case TDN_RADIO_BUTTON_CLICKED:
6286 pT->OnRadioButtonClicked((
int)wParam);
6288 case TDN_HYPERLINK_CLICKED:
6289 pT->OnHyperlinkClicked((LPCWSTR)lParam);
6291 case TDN_EXPANDO_BUTTON_CLICKED:
6292 pT->OnExpandoButtonClicked((wParam != 0));
6294 case TDN_VERIFICATION_CLICKED:
6295 pT->OnVerificationClicked((wParam != 0));
6301 bRet = pT->OnTimer((DWORD)wParam);
6311 ATLTRACE2(atlTraceUI, 0, _T(
"Unknown notification received in CTaskDialogImpl::TaskDialogCallback\n"));
6315 return (bRet != FALSE) ? S_OK : S_FALSE;
6319 void OnDialogConstructed()
6327 BOOL OnButtonClicked(
int )
6332 void OnRadioButtonClicked(
int )
6336 void OnHyperlinkClicked(LPCWSTR )
6340 void OnExpandoButtonClicked(
bool )
6344 void OnVerificationClicked(
bool )
6352 BOOL OnTimer(DWORD )
6366 void NavigatePage(TASKDIALOGCONFIG& tdc)
6368 ATLASSERT(m_hWnd != NULL);
6370 tdc.cbSize =
sizeof(TASKDIALOGCONFIG);
6371 if(tdc.hwndParent == NULL)
6372 tdc.hwndParent = m_tdc.hwndParent;
6373 tdc.pfCallback = m_tdc.pfCallback;
6374 tdc.lpCallbackData = m_tdc.lpCallbackData;
6375 (TASKDIALOGCONFIG)m_tdc = tdc;
6377 ::SendMessage(m_hWnd, TDM_NAVIGATE_PAGE, 0, (LPARAM)&tdc);
6383 ATLASSERT(m_hWnd != NULL);
6384 ::SendMessage(m_hWnd, TDM_NAVIGATE_PAGE, 0, (LPARAM)&m_tdc);
6387 void ClickButton(
int nButton)
6389 ATLASSERT(m_hWnd != NULL);
6390 ::SendMessage(m_hWnd, TDM_CLICK_BUTTON, nButton, 0L);
6393 void SetMarqueeProgressBar(BOOL bMarquee)
6395 ATLASSERT(m_hWnd != NULL);
6396 ::SendMessage(m_hWnd, TDM_SET_MARQUEE_PROGRESS_BAR, bMarquee, 0L);
6399 BOOL SetProgressBarState(
int nNewState)
6401 ATLASSERT(m_hWnd != NULL);
6402 return (BOOL)::SendMessage(m_hWnd, TDM_SET_PROGRESS_BAR_STATE, nNewState, 0L);
6405 DWORD SetProgressBarRange(
int nMinRange,
int nMaxRange)
6407 ATLASSERT(m_hWnd != NULL);
6408 return (DWORD)::SendMessage(m_hWnd, TDM_SET_PROGRESS_BAR_RANGE, 0, MAKELPARAM(nMinRange, nMaxRange));
6411 int SetProgressBarPos(
int nNewPos)
6413 ATLASSERT(m_hWnd != NULL);
6414 return (
int)::SendMessage(m_hWnd, TDM_SET_PROGRESS_BAR_POS, nNewPos, 0L);
6417 BOOL SetProgressBarMarquee(BOOL bMarquee, UINT uSpeed)
6419 ATLASSERT(m_hWnd != NULL);
6420 return (BOOL)::SendMessage(m_hWnd, TDM_SET_PROGRESS_BAR_MARQUEE, bMarquee, uSpeed);
6423 void SetElementText(TASKDIALOG_ELEMENTS element, LPCWSTR lpstrText)
6425 ATLASSERT(m_hWnd != NULL);
6426 ::SendMessage(m_hWnd, TDM_SET_ELEMENT_TEXT, element, (LPARAM)lpstrText);
6429 void ClickRadioButton(
int nRadioButton)
6431 ATLASSERT(m_hWnd != NULL);
6432 ::SendMessage(m_hWnd, TDM_CLICK_RADIO_BUTTON, nRadioButton, 0L);
6435 void EnableButton(
int nButton, BOOL bEnable)
6437 ATLASSERT(m_hWnd != NULL);
6438 ::SendMessage(m_hWnd, TDM_ENABLE_BUTTON, nButton, bEnable);
6441 void EnableRadioButton(
int nButton, BOOL bEnable)
6443 ATLASSERT(m_hWnd != NULL);
6444 ::SendMessage(m_hWnd, TDM_ENABLE_RADIO_BUTTON, nButton, bEnable);
6447 void ClickVerification(BOOL bCheck, BOOL bFocus)
6449 ATLASSERT(m_hWnd != NULL);
6450 ::SendMessage(m_hWnd, TDM_CLICK_VERIFICATION, bCheck, bFocus);
6453 void UpdateElementText(TASKDIALOG_ELEMENTS element, LPCWSTR lpstrText)
6455 ATLASSERT(m_hWnd != NULL);
6456 ::SendMessage(m_hWnd, TDM_UPDATE_ELEMENT_TEXT, element, (LPARAM)lpstrText);
6459 void SetButtonElevationRequiredState(
int nButton, BOOL bElevation)
6461 ATLASSERT(m_hWnd != NULL);
6462 ::SendMessage(m_hWnd, TDM_SET_BUTTON_ELEVATION_REQUIRED_STATE, nButton, bElevation);
6465 void UpdateIcon(TASKDIALOG_ICON_ELEMENTS element, HICON hIcon)
6467 ATLASSERT(m_hWnd != NULL);
6469 if(element == TDIE_ICON_MAIN)
6470 ATLASSERT((m_tdc.dwFlags & TDF_USE_HICON_MAIN) != 0);
6471 else if(element == TDIE_ICON_FOOTER)
6472 ATLASSERT((m_tdc.dwFlags & TDF_USE_HICON_FOOTER) != 0);
6474 ::SendMessage(m_hWnd, TDM_UPDATE_ICON, element, (LPARAM)hIcon);
6477 void UpdateIcon(TASKDIALOG_ICON_ELEMENTS element, LPCWSTR lpstrIcon)
6479 ATLASSERT(m_hWnd != NULL);
6481 if(element == TDIE_ICON_MAIN)
6482 ATLASSERT((m_tdc.dwFlags & TDF_USE_HICON_MAIN) == 0);
6483 else if(element == TDIE_ICON_FOOTER)
6484 ATLASSERT((m_tdc.dwFlags & TDF_USE_HICON_FOOTER) == 0);
6486 ::SendMessage(m_hWnd, TDM_UPDATE_ICON, element, (LPARAM)lpstrIcon);
6494 class CTaskDialog :
public CTaskDialogImpl<CTaskDialog>
6497 CTaskDialog(HWND hWndParent = NULL) : CTaskDialogImpl<CTaskDialog>(hWndParent)
6499 m_tdc.pfCallback = NULL;
6503 #endif // ((_WIN32_WINNT >= 0x0600) || defined(_WTL_TASKDIALOG)) && !defined(_WIN32_WCE) 6507 #endif // __ATLDLGS_H__ Definition: atlwinx.h:452
Definition: atldlgs.h:3218
Definition: atldlgs.h:3985
Definition: atldlgs.h:1600
Definition: atldlgs.h:2197
Definition: atldlgs.h:3621
Definition: atldlgs.h:4392
Definition: atldlgs.h:1653
Definition: atldlgs.h:5239
Definition: atldlgs.h:4918
Definition: atlapp.h:1368
Definition: atldlgs.h:2728
Definition: atldlgs.h:2878
Definition: atlgdi.h:3386
Definition: atldlgs.h:2243
Definition: atldlgs.h:4404
Definition: atldlgs.h:876
Definition: atldlgs.h:1326
Definition: atldlgs.h:3202
Definition: atldlgs.h:416
Definition: atldlgs.h:2901
Definition: atldlgs.h:2008
Definition: atlapp.h:1455
Definition: atldlgs.h:2445
Definition: atldlgs.h:1825
Definition: atldlgs.h:3055
Definition: atlwinx.h:432
Definition: atlgdi.h:3407
Definition: atldlgs.h:3713
Definition: atldlgs.h:472
Definition: atldlgs.h:1586
Definition: atldlgs.h:4899
Definition: atldlgs.h:123
Definition: atldlgs.h:3042
Definition: atldlgs.h:4486