18 #error atldlgs.h requires atlapp.h to be included first 22 #error atldlgs.h requires atlwin.h to be included first 28 #if (_WIN32_WINNT >= 0x0600) && !defined(_WIN32_WCE) 30 #endif // (_WIN32_WINNT >= 0x0600) && !defined(_WIN32_WCE) 108 #if (_WIN32_WINNT >= 0x0500) && !defined(OPENFILENAME_SIZE_VERSION_400) 109 #ifndef CDSIZEOF_STRUCT 110 #define CDSIZEOF_STRUCT(structname, member) (((int)((LPBYTE)(&((structname*)0)->member) - ((LPBYTE)((structname*)0)))) + sizeof(((structname*)0)->member)) 112 #define OPENFILENAME_SIZE_VERSION_400A CDSIZEOF_STRUCT(OPENFILENAMEA,lpTemplateName) 113 #define OPENFILENAME_SIZE_VERSION_400W CDSIZEOF_STRUCT(OPENFILENAMEW,lpTemplateName) 115 #define OPENFILENAME_SIZE_VERSION_400 OPENFILENAME_SIZE_VERSION_400W 117 #define OPENFILENAME_SIZE_VERSION_400 OPENFILENAME_SIZE_VERSION_400A 119 #endif // (_WIN32_WINNT >= 0x0500) && !defined(OPENFILENAME_SIZE_VERSION_400) 121 #if !defined(_WIN32_WCE) && !defined(CDN_INCLUDEITEM) 122 #define CDN_INCLUDEITEM (CDN_FIRST - 0x0007) 129 #if defined(__AYGSHELL_H__) && (_WIN32_WCE >= 0x0501) 130 OPENFILENAMEEX m_ofn;
134 BOOL m_bOpenFileDialog;
135 TCHAR m_szFileTitle[_MAX_FNAME];
136 TCHAR m_szFileName[_MAX_PATH];
139 LPCTSTR lpszDefExt = NULL,
140 LPCTSTR lpszFileName = NULL,
141 DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
142 LPCTSTR lpszFilter = NULL,
143 HWND hWndParent = NULL)
145 memset(&m_ofn, 0,
sizeof(m_ofn));
146 m_szFileName[0] = _T(
'\0');
147 m_szFileTitle[0] = _T(
'\0');
149 m_bOpenFileDialog = bOpenFileDialog;
151 #if defined(__AYGSHELL_H__) && (_WIN32_WCE >= 0x0501) 152 m_ofn.lStructSize = bOpenFileDialog ?
sizeof(m_ofn) :
sizeof(OPENFILENAME);
154 m_ofn.lStructSize =
sizeof(m_ofn);
157 #if (_WIN32_WINNT >= 0x0500) 159 if(AtlIsOldWindows())
161 ATLASSERT(
sizeof(m_ofn) > OPENFILENAME_SIZE_VERSION_400);
162 m_ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
164 #endif // (_WIN32_WINNT >= 0x0500) 165 m_ofn.lpstrFile = m_szFileName;
166 m_ofn.nMaxFile = _MAX_PATH;
167 m_ofn.lpstrDefExt = lpszDefExt;
168 m_ofn.lpstrFileTitle = (LPTSTR)m_szFileTitle;
169 m_ofn.nMaxFileTitle = _MAX_FNAME;
171 m_ofn.Flags = dwFlags | OFN_EXPLORER | OFN_ENABLEHOOK | OFN_ENABLESIZING;
173 m_ofn.Flags = dwFlags | OFN_EXPLORER | OFN_ENABLEHOOK;
174 #endif // !_WIN32_WCE 175 m_ofn.lpstrFilter = lpszFilter;
176 m_ofn.hInstance = ModuleHelper::GetResourceInstance();
177 m_ofn.lpfnHook = (LPOFNHOOKPROC)T::StartDialogProc;
178 m_ofn.hwndOwner = hWndParent;
181 if(lpszFileName != NULL)
182 SecureHelper::strncpy_x(m_szFileName, _countof(m_szFileName), lpszFileName, _TRUNCATE);
185 INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow())
187 ATLASSERT((m_ofn.Flags & OFN_ENABLEHOOK) != 0);
188 ATLASSERT(m_ofn.lpfnHook != NULL);
190 ATLASSERT((m_ofn.Flags & OFN_EXPLORER) != 0);
192 if(m_ofn.hwndOwner == NULL)
193 m_ofn.hwndOwner = hWndParent;
195 ATLASSERT(m_hWnd == NULL);
196 ModuleHelper::AddCreateWndData(&m_thunk.cd, (ATL::CDialogImplBase*)
this);
199 if(m_bOpenFileDialog)
200 #if defined(__AYGSHELL_H__) && (_WIN32_WCE >= 0x0501) 201 bRet = ::GetOpenFileNameEx(&m_ofn);
203 bRet = ::GetSaveFileName((LPOPENFILENAME)&m_ofn);
205 bRet = ::GetOpenFileName(&m_ofn);
207 bRet = ::GetSaveFileName(&m_ofn);
212 return bRet ? IDOK : IDCANCEL;
216 ATL::CWindow GetFileDialogWindow()
const 218 ATLASSERT(::IsWindow(m_hWnd));
219 return ATL::CWindow(GetParent());
222 int GetFilePath(LPTSTR lpstrFilePath,
int nLength)
const 224 ATLASSERT(::IsWindow(m_hWnd));
225 ATLASSERT((m_ofn.Flags & OFN_EXPLORER) != 0);
227 return (
int)GetFileDialogWindow().SendMessage(CDM_GETFILEPATH, nLength, (LPARAM)lpstrFilePath);
230 int GetFolderIDList(LPVOID lpBuff,
int nLength)
const 232 ATLASSERT(::IsWindow(m_hWnd));
233 ATLASSERT((m_ofn.Flags & OFN_EXPLORER) != 0);
235 return (
int)GetFileDialogWindow().SendMessage(CDM_GETFOLDERIDLIST, nLength, (LPARAM)lpBuff);
238 int GetFolderPath(LPTSTR lpstrFolderPath,
int nLength)
const 240 ATLASSERT(::IsWindow(m_hWnd));
241 ATLASSERT((m_ofn.Flags & OFN_EXPLORER) != 0);
243 return (
int)GetFileDialogWindow().SendMessage(CDM_GETFOLDERPATH, nLength, (LPARAM)lpstrFolderPath);
246 int GetSpec(LPTSTR lpstrSpec,
int nLength)
const 248 ATLASSERT(::IsWindow(m_hWnd));
249 ATLASSERT((m_ofn.Flags & OFN_EXPLORER) != 0);
251 return (
int)GetFileDialogWindow().SendMessage(CDM_GETSPEC, nLength, (LPARAM)lpstrSpec);
254 void SetControlText(
int nCtrlID, LPCTSTR lpstrText)
256 ATLASSERT(::IsWindow(m_hWnd));
257 ATLASSERT((m_ofn.Flags & OFN_EXPLORER) != 0);
259 GetFileDialogWindow().SendMessage(CDM_SETCONTROLTEXT, nCtrlID, (LPARAM)lpstrText);
262 void SetDefExt(LPCTSTR lpstrExt)
264 ATLASSERT(::IsWindow(m_hWnd));
265 ATLASSERT((m_ofn.Flags & OFN_EXPLORER) != 0);
267 GetFileDialogWindow().SendMessage(CDM_SETDEFEXT, 0, (LPARAM)lpstrExt);
270 BOOL GetReadOnlyPref()
const 272 return ((m_ofn.Flags & OFN_READONLY) != 0) ? TRUE : FALSE;
276 void HideControl(
int nCtrlID)
278 ATLASSERT(::IsWindow(m_hWnd));
279 ATLASSERT((m_ofn.Flags & OFN_EXPLORER) != 0);
281 GetFileDialogWindow().SendMessage(CDM_HIDECONTROL, nCtrlID);
285 BOOL EndDialog(INT_PTR = 0)
287 ATLASSERT(::IsWindow(m_hWnd));
288 GetFileDialogWindow().SendMessage(WM_COMMAND, MAKEWPARAM(IDCANCEL, 0));
294 NOTIFY_CODE_HANDLER(CDN_FILEOK, _OnFileOK)
295 NOTIFY_CODE_HANDLER(CDN_FOLDERCHANGE, _OnFolderChange)
296 NOTIFY_CODE_HANDLER(CDN_HELP, _OnHelp)
297 NOTIFY_CODE_HANDLER(CDN_INITDONE, _OnInitDone)
298 NOTIFY_CODE_HANDLER(CDN_SELCHANGE, _OnSelChange)
299 NOTIFY_CODE_HANDLER(CDN_SHAREVIOLATION, _OnShareViolation)
300 NOTIFY_CODE_HANDLER(CDN_TYPECHANGE, _OnTypeChange)
302 NOTIFY_CODE_HANDLER(CDN_INCLUDEITEM, _OnIncludeItem)
303 #endif // !_WIN32_WCE 306 LRESULT _OnFileOK(
int , LPNMHDR pnmh, BOOL& )
308 ATLASSERT(::IsWindow(m_hWnd));
309 T* pT =
static_cast<T*
>(
this);
310 return !pT->OnFileOK((LPOFNOTIFY)pnmh);
313 LRESULT _OnFolderChange(
int , LPNMHDR pnmh, BOOL& )
315 ATLASSERT(::IsWindow(m_hWnd));
316 T* pT =
static_cast<T*
>(
this);
317 pT->OnFolderChange((LPOFNOTIFY)pnmh);
321 LRESULT _OnHelp(
int , LPNMHDR pnmh, BOOL& )
323 ATLASSERT(::IsWindow(m_hWnd));
324 T* pT =
static_cast<T*
>(
this);
325 pT->OnHelp((LPOFNOTIFY)pnmh);
329 LRESULT _OnInitDone(
int , LPNMHDR pnmh, BOOL& )
331 ATLASSERT(::IsWindow(m_hWnd));
332 T* pT =
static_cast<T*
>(
this);
333 pT->OnInitDone((LPOFNOTIFY)pnmh);
337 LRESULT _OnSelChange(
int , LPNMHDR pnmh, BOOL& )
339 ATLASSERT(::IsWindow(m_hWnd));
340 T* pT =
static_cast<T*
>(
this);
341 pT->OnSelChange((LPOFNOTIFY)pnmh);
345 LRESULT _OnShareViolation(
int , LPNMHDR pnmh, BOOL& )
347 ATLASSERT(::IsWindow(m_hWnd));
348 T* pT =
static_cast<T*
>(
this);
349 return pT->OnShareViolation((LPOFNOTIFY)pnmh);
352 LRESULT _OnTypeChange(
int , LPNMHDR pnmh, BOOL& )
354 ATLASSERT(::IsWindow(m_hWnd));
355 T* pT =
static_cast<T*
>(
this);
356 pT->OnTypeChange((LPOFNOTIFY)pnmh);
361 LRESULT _OnIncludeItem(
int , LPNMHDR pnmh, BOOL& )
363 ATLASSERT(::IsWindow(m_hWnd));
364 T* pT =
static_cast<T*
>(
this);
365 return pT->OnIncludeItem((LPOFNOTIFYEX)pnmh);
367 #endif // !_WIN32_WCE 370 BOOL OnFileOK(LPOFNOTIFY )
375 void OnFolderChange(LPOFNOTIFY )
379 void OnHelp(LPOFNOTIFY )
383 void OnInitDone(LPOFNOTIFY )
387 void OnSelChange(LPOFNOTIFY )
391 int OnShareViolation(LPOFNOTIFY )
396 void OnTypeChange(LPOFNOTIFY )
401 BOOL OnIncludeItem(LPOFNOTIFYEX )
405 #endif // !_WIN32_WCE 412 LPCTSTR lpszDefExt = NULL,
413 LPCTSTR lpszFileName = NULL,
414 DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
415 LPCTSTR lpszFilter = NULL,
416 HWND hWndParent = NULL)
421 DECLARE_EMPTY_MSG_MAP()
424 #if defined(__AYGSHELL_H__) && (_WIN32_WCE >= 0x0501) 429 LPCTSTR lpszDefExt = NULL,
430 LPCTSTR lpszFileName = NULL,
431 DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
432 OFN_EXFLAG ExFlags = OFN_EXFLAG_THUMBNAILVIEW,
433 OFN_SORTORDER dwSortOrder = OFN_SORTORDER_AUTO,
434 LPCTSTR lpszFilter = NULL,
435 HWND hWndParent = NULL)
438 m_ofn.ExFlags = ExFlags;
439 m_ofn.dwSortOrder = dwSortOrder;
443 DECLARE_EMPTY_MSG_MAP()
445 #endif // defined(__AYGSHELL_H__) && (_WIN32_WCE >= 0x0501) 459 #ifndef _WTL_FIXED_OFN_BUFFER_LENGTH 460 #define _WTL_FIXED_OFN_BUFFER_LENGTH 0x10000 467 mutable LPCTSTR m_pNextFile;
473 LPCTSTR lpszDefExt = NULL,
474 LPCTSTR lpszFileName = NULL,
475 DWORD dwFlags = OFN_HIDEREADONLY,
476 LPCTSTR lpszFilter = NULL,
477 HWND hWndParent = NULL)
478 :
CFileDialogImpl<T>(TRUE, lpszDefExt, lpszFileName, dwFlags, lpszFilter, hWndParent),
481 m_ofn.Flags |= OFN_ALLOWMULTISELECT;
484 OSVERSIONINFO ovi = {
sizeof(OSVERSIONINFO) };
485 ::GetVersionEx(&ovi);
486 m_bIsNT = (ovi.dwPlatformId == VER_PLATFORM_WIN32_NT);
491 ATLVERIFY(ResizeFilenameBuffer(_WTL_FIXED_OFN_BUFFER_LENGTH));
498 if (m_ofn.lpstrFile != m_szFileName)
499 delete[] m_ofn.lpstrFile;
507 int GetDirectory(LPTSTR pBuffer,
int nBufLen)
const 509 if (m_ofn.lpstrFile == NULL)
512 LPCTSTR pStr = m_ofn.lpstrFile;
513 int nLength = lstrlen(pStr);
514 if (pStr[nLength + 1] == 0)
517 LPCTSTR pSep = MinCrtHelper::_strrchr(pStr, _T(
'\\'));
519 nLength = (int)(DWORD_PTR)(pSep - pStr);
527 else if (nBufLen > nLength)
529 SecureHelper::strncpy_x(pBuffer, nBufLen, pStr, nLength);
536 #if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) 537 bool GetDirectory(_CSTRING_NS::CString& strDir)
const 541 int nLength = GetDirectory(NULL, 0);
544 bRet = (GetDirectory(strDir.GetBuffer(nLength), nLength) > 0);
545 strDir.ReleaseBuffer(nLength - 1);
550 #endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) 553 LPCTSTR GetFirstFileName()
const 555 if (m_ofn.lpstrFile == NULL)
560 LPCTSTR pStr = m_ofn.lpstrFile;
561 int nLength = lstrlen(pStr);
562 if (pStr[nLength + 1] != 0)
575 LPCTSTR pSep = MinCrtHelper::_strrchr(pStr, _T(
'\\'));
584 LPCTSTR GetNextFileName()
const 586 if (m_pNextFile == NULL)
589 LPCTSTR pStr = m_pNextFile;
592 int nLength = lstrlen(pStr);
593 m_pNextFile = (pStr[nLength + 1] != 0) ? &pStr[nLength + 1] : NULL;
602 int GetFirstPathName(LPTSTR pBuffer,
int nBufLen)
const 604 LPCTSTR pStr = GetFirstFileName();
605 int nLengthDir = GetDirectory(NULL, 0);
606 if((pStr == NULL) || (nLengthDir == 0))
610 int nLengthTotal = nLengthDir + lstrlen(pStr);
615 nRet = nLengthTotal + 1;
617 else if (nBufLen > nLengthTotal)
619 GetDirectory(pBuffer, nBufLen);
620 SecureHelper::strcat_x(pBuffer, nBufLen, _T(
"\\"));
621 SecureHelper::strcat_x(pBuffer, nBufLen, pStr);
628 #if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) 629 bool GetFirstPathName(_CSTRING_NS::CString& strPath)
const 633 int nLength = GetFirstPathName(NULL, 0);
636 bRet = (GetFirstPathName(strPath.GetBuffer(nLength), nLength) > 0);
637 strPath.ReleaseBuffer(nLength - 1);
642 #endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) 649 int GetNextPathName(LPTSTR pBuffer,
int nBufLen)
const 651 if (m_pNextFile == NULL)
655 LPCTSTR pStr = m_pNextFile;
657 if (MinCrtHelper::_strrchr(pStr, _T(
'\\')) != NULL)
660 int nLength = lstrlen(pStr);
666 else if (nBufLen > nLength)
668 SecureHelper::strcpy_x(pBuffer, nBufLen, GetNextFileName());
675 int nLengthDir = GetDirectory(NULL, 0);
679 int nLengthTotal = nLengthDir + lstrlen(pStr);
683 nRet = nLengthTotal + 1;
685 else if (nBufLen > nLengthTotal)
687 GetDirectory(pBuffer, nBufLen);
688 SecureHelper::strcat_x(pBuffer, nBufLen, _T(
"\\"));
689 SecureHelper::strcat_x(pBuffer, nBufLen, GetNextFileName());
698 #if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) 699 bool GetNextPathName(_CSTRING_NS::CString& strPath)
const 703 int nLength = GetNextPathName(NULL, 0);
706 bRet = (GetNextPathName(strPath.GetBuffer(nLength), nLength) > 0);
707 strPath.ReleaseBuffer(nLength - 1);
712 #endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) 715 bool ResizeFilenameBuffer(DWORD dwLength)
717 if (dwLength > m_ofn.nMaxFile)
720 if (m_ofn.lpstrFile != m_szFileName)
722 delete[] m_ofn.lpstrFile;
723 m_ofn.lpstrFile = NULL;
728 LPTSTR lpstrBuff = NULL;
729 ATLTRY(lpstrBuff =
new TCHAR[dwLength]);
730 if (lpstrBuff != NULL)
732 m_ofn.lpstrFile = lpstrBuff;
733 m_ofn.lpstrFile[0] = 0;
734 m_ofn.nMaxFile = dwLength;
738 return (m_ofn.lpstrFile != NULL);
741 void OnSelChange(LPOFNOTIFY )
750 int nLength = GetSpec(NULL, 0);
755 nLength += GetFolderPath(NULL, 0) + 1;
757 if (!ResizeFilenameBuffer(nLength))
764 if ((m_ofn.Flags & OFN_NODEREFERENCELINKS) != 0)
768 if (GetSpec(m_ofn.lpstrFile, m_ofn.nMaxFile) <= 0)
772 int nBytes = GetFolderIDList(NULL, 0);
774 idlist.AllocateBytes(nBytes);
775 if ((nBytes <= 0) || (GetFolderIDList(idlist, nBytes) <= 0))
779 ATL::CComPtr<IShellFolder> pDesktop, pFolder;
780 if (FAILED(::SHGetDesktopFolder(&pDesktop)))
782 if (FAILED(pDesktop->BindToObject(idlist, NULL, IID_IShellFolder, (
void**)&pFolder)))
787 DWORD nExtraChars = 0;
788 bool bInsideQuotes =
false;
789 LPCTSTR pAnchor = m_ofn.lpstrFile;
790 LPCTSTR pChar = m_ofn.lpstrFile;
791 for ( ; *pChar; ++pChar)
794 if (*pChar == _T(
'\"'))
797 bInsideQuotes = !bInsideQuotes;
808 if (pChar - pAnchor >= MAX_PATH)
813 int nFileNameLength = (int)(DWORD_PTR)(pChar - pAnchor);
814 TCHAR szFileName[MAX_PATH] = { 0 };
815 SecureHelper::strncpy_x(szFileName, MAX_PATH, pAnchor, nFileNameLength);
816 LPITEMIDLIST pidl = NULL;
817 DWORD dwAttrib = SFGAO_LINK;
818 if (SUCCEEDED(pFolder->ParseDisplayName(NULL, NULL, T2W(szFileName), NULL, &pidl, &dwAttrib)))
821 if (dwAttrib & SFGAO_LINK)
824 ATL::CComPtr<IShellLink> pLink;
825 if (SUCCEEDED(pFolder->BindToObject(pidl, NULL, IID_IShellLink, (
void**)&pLink)))
828 TCHAR szPath[MAX_PATH] = { 0 };
829 if (SUCCEEDED(pLink->GetPath(szPath, MAX_PATH, NULL, 0)))
833 int nNewLength = lstrlen(szPath);
834 if (nNewLength > nFileNameLength)
835 nExtraChars += nNewLength - nFileNameLength;
841 ::CoTaskMemFree(pidl);
849 ATLVERIFY(ResizeFilenameBuffer(m_ofn.nMaxFile + nExtraChars));
857 LPCTSTR lpszDefExt = NULL,
858 LPCTSTR lpszFileName = NULL,
859 DWORD dwFlags = OFN_HIDEREADONLY,
860 LPCTSTR lpszFilter = NULL,
861 HWND hWndParent = NULL)
870 #endif // !_WIN32_WCE 881 #if (_WIN32_WINNT >= 0x0600) && !defined(_WIN32_WCE) 887 class ATL_NO_VTABLE CShellFileDialogImpl :
public IFileDialogEvents
891 INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow())
895 T* pT =
static_cast<T*
>(
this);
896 if(pT->m_spFileDlg == NULL)
903 pT->_Advise(dwCookie);
905 HRESULT hRet = pT->m_spFileDlg->Show(hWndParent);
908 else if(hRet == HRESULT_FROM_WIN32(ERROR_CANCELLED))
913 pT->_Unadvise(dwCookie);
920 const T* pT =
static_cast<const T*
>(
this);
921 return (pT->m_spFileDlg == NULL);
925 HRESULT GetFilePath(LPWSTR lpstrFilePath,
int cchLength)
927 T* pT =
static_cast<T*
>(
this);
928 ATLASSERT(pT->m_spFileDlg != NULL);
930 ATL::CComPtr<IShellItem> spItem;
931 HRESULT hRet = pT->m_spFileDlg->GetResult(&spItem);
934 hRet = GetFileNameFromShellItem(spItem, SIGDN_FILESYSPATH, lpstrFilePath, cchLength);
939 HRESULT GetFileTitle(LPWSTR lpstrFileTitle,
int cchLength)
941 T* pT =
static_cast<T*
>(
this);
942 ATLASSERT(pT->m_spFileDlg != NULL);
944 ATL::CComPtr<IShellItem> spItem;
945 HRESULT hRet = pT->m_spFileDlg->GetResult(&spItem);
948 hRet = GetFileNameFromShellItem(spItem, SIGDN_NORMALDISPLAY, lpstrFileTitle, cchLength);
953 #if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) 954 HRESULT GetFilePath(_CSTRING_NS::CString& strFilePath)
956 T* pT =
static_cast<T*
>(
this);
957 ATLASSERT(pT->m_spFileDlg != NULL);
959 ATL::CComPtr<IShellItem> spItem;
960 HRESULT hRet = pT->m_spFileDlg->GetResult(&spItem);
963 hRet = GetFileNameFromShellItem(spItem, SIGDN_FILESYSPATH, strFilePath);
968 HRESULT GetFileTitle(_CSTRING_NS::CString& strFileTitle)
970 T* pT =
static_cast<T*
>(
this);
971 ATLASSERT(pT->m_spFileDlg != NULL);
973 ATL::CComPtr<IShellItem> spItem;
974 HRESULT hRet = pT->m_spFileDlg->GetResult(&spItem);
977 hRet = GetFileNameFromShellItem(spItem, SIGDN_NORMALDISPLAY, strFileTitle);
981 #endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) 984 static HRESULT GetFileNameFromShellItem(IShellItem* pShellItem, SIGDN type, LPWSTR lpstr,
int cchLength)
986 ATLASSERT(pShellItem != NULL);
988 LPWSTR lpstrName = NULL;
989 HRESULT hRet = pShellItem->GetDisplayName(type, &lpstrName);
993 if(lstrlenW(lpstrName) < cchLength)
995 SecureHelper::strcpyW_x(lpstr, cchLength, lpstrName);
1000 hRet = DISP_E_BUFFERTOOSMALL;
1003 ::CoTaskMemFree(lpstrName);
1009 #if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) 1010 static HRESULT GetFileNameFromShellItem(IShellItem* pShellItem, SIGDN type, _CSTRING_NS::CString& str)
1012 ATLASSERT(pShellItem != NULL);
1014 LPWSTR lpstrName = NULL;
1015 HRESULT hRet = pShellItem->GetDisplayName(type, &lpstrName);
1020 ::CoTaskMemFree(lpstrName);
1025 #endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) 1028 void _Advise(DWORD& dwCookie)
1030 T* pT =
static_cast<T*
>(
this);
1031 ATLASSERT(pT->m_spFileDlg != NULL);
1032 HRESULT hRet = pT->m_spFileDlg->Advise((IFileDialogEvents*)
this, &dwCookie);
1033 ATLVERIFY(SUCCEEDED(hRet));
1036 void _Unadvise(DWORD dwCookie)
1038 T* pT =
static_cast<T*
>(
this);
1039 ATLASSERT(pT->m_spFileDlg != NULL);
1040 HRESULT hRet = pT->m_spFileDlg->Unadvise(dwCookie);
1041 ATLVERIFY(SUCCEEDED(hRet));
1044 void _Init(LPCWSTR lpszFileName, DWORD dwOptions, LPCWSTR lpszDefExt,
const COMDLG_FILTERSPEC* arrFilterSpec, UINT uFilterSpecCount)
1046 T* pT =
static_cast<T*
>(
this);
1047 ATLASSERT(pT->m_spFileDlg != NULL);
1049 HRESULT hRet = E_FAIL;
1051 if(lpszFileName != NULL)
1053 hRet = pT->m_spFileDlg->SetFileName(lpszFileName);
1054 ATLASSERT(SUCCEEDED(hRet));
1057 hRet = pT->m_spFileDlg->SetOptions(dwOptions);
1058 ATLASSERT(SUCCEEDED(hRet));
1060 if(lpszDefExt != NULL)
1062 hRet = pT->m_spFileDlg->SetDefaultExtension(lpszDefExt);
1063 ATLASSERT(SUCCEEDED(hRet));
1066 if(arrFilterSpec != NULL && uFilterSpecCount != 0U)
1068 hRet = pT->m_spFileDlg->SetFileTypes(uFilterSpecCount, arrFilterSpec);
1069 ATLASSERT(SUCCEEDED(hRet));
1074 STDMETHOD(QueryInterface)(REFIID riid,
void** ppvObject)
1076 if(ppvObject == NULL)
1079 T* pT =
static_cast<T*
>(
this);
1080 if(IsEqualGUID(riid, IID_IUnknown) || IsEqualGUID(riid, IID_IFileDialogEvents))
1082 *ppvObject = (IFileDialogEvents*)pT;
1087 return E_NOINTERFACE;
1090 virtual ULONG STDMETHODCALLTYPE AddRef()
1095 virtual ULONG STDMETHODCALLTYPE Release()
1101 virtual HRESULT STDMETHODCALLTYPE IFileDialogEvents::OnFileOk(IFileDialog* pfd)
1103 T* pT =
static_cast<T*
>(
this);
1104 ATLASSERT(pT->m_spFileDlg.IsEqualObject(pfd));
1106 return pT->OnFileOk();
1109 virtual HRESULT STDMETHODCALLTYPE IFileDialogEvents::OnFolderChanging(IFileDialog* pfd, IShellItem* psiFolder)
1111 T* pT =
static_cast<T*
>(
this);
1112 ATLASSERT(pT->m_spFileDlg.IsEqualObject(pfd));
1114 return pT->OnFolderChanging(psiFolder);
1117 virtual HRESULT STDMETHODCALLTYPE IFileDialogEvents::OnFolderChange(IFileDialog* pfd)
1119 T* pT =
static_cast<T*
>(
this);
1120 ATLASSERT(pT->m_spFileDlg.IsEqualObject(pfd));
1122 return pT->OnFolderChange();
1125 virtual HRESULT STDMETHODCALLTYPE IFileDialogEvents::OnSelectionChange(IFileDialog* pfd)
1127 T* pT =
static_cast<T*
>(
this);
1128 ATLASSERT(pT->m_spFileDlg.IsEqualObject(pfd));
1130 return pT->OnSelectionChange();
1133 virtual HRESULT STDMETHODCALLTYPE IFileDialogEvents::OnShareViolation(IFileDialog* pfd, IShellItem* psi, FDE_SHAREVIOLATION_RESPONSE* pResponse)
1135 T* pT =
static_cast<T*
>(
this);
1136 ATLASSERT(pT->m_spFileDlg.IsEqualObject(pfd));
1138 return pT->OnShareViolation(psi, pResponse);
1141 virtual HRESULT STDMETHODCALLTYPE IFileDialogEvents::OnTypeChange(IFileDialog* pfd)
1143 T* pT =
static_cast<T*
>(
this);
1144 ATLASSERT(pT->m_spFileDlg.IsEqualObject(pfd));
1146 return pT->OnTypeChange();
1149 virtual HRESULT STDMETHODCALLTYPE IFileDialogEvents::OnOverwrite(IFileDialog* pfd, IShellItem* psi, FDE_OVERWRITE_RESPONSE* pResponse)
1151 T* pT =
static_cast<T*
>(
this);
1152 ATLASSERT(pT->m_spFileDlg.IsEqualObject(pfd));
1154 return pT->OnOverwrite(psi, pResponse);
1163 HRESULT OnFolderChanging(IShellItem* )
1168 HRESULT OnFolderChange()
1173 HRESULT OnSelectionChange()
1178 HRESULT OnShareViolation(IShellItem* , FDE_SHAREVIOLATION_RESPONSE* )
1183 HRESULT OnTypeChange()
1188 HRESULT OnOverwrite(IShellItem* , FDE_OVERWRITE_RESPONSE* )
1199 class ATL_NO_VTABLE CShellFileOpenDialogImpl :
public CShellFileDialogImpl< T >
1202 ATL::CComPtr<IFileOpenDialog> m_spFileDlg;
1204 CShellFileOpenDialogImpl(LPCWSTR lpszFileName = NULL,
1205 DWORD dwOptions = FOS_FORCEFILESYSTEM | FOS_PATHMUSTEXIST | FOS_FILEMUSTEXIST,
1206 LPCWSTR lpszDefExt = NULL,
1207 const COMDLG_FILTERSPEC* arrFilterSpec = NULL,
1208 UINT uFilterSpecCount = 0U)
1210 HRESULT hRet = m_spFileDlg.CoCreateInstance(CLSID_FileOpenDialog);
1213 _Init(lpszFileName, dwOptions, lpszDefExt, arrFilterSpec, uFilterSpecCount);
1216 IFileOpenDialog* GetPtr()
1226 class CShellFileOpenDialog :
public CShellFileOpenDialogImpl<CShellFileOpenDialog>
1229 CShellFileOpenDialog(LPCWSTR lpszFileName = NULL,
1230 DWORD dwOptions = FOS_FORCEFILESYSTEM | FOS_PATHMUSTEXIST | FOS_FILEMUSTEXIST,
1231 LPCWSTR lpszDefExt = NULL,
1232 const COMDLG_FILTERSPEC* arrFilterSpec = NULL,
1233 UINT uFilterSpecCount = 0U) : CShellFileOpenDialogImpl<CShellFileOpenDialog>(lpszFileName, dwOptions, lpszDefExt, arrFilterSpec, uFilterSpecCount)
1237 void _Advise(DWORD& )
1240 void _Unadvise(DWORD )
1249 class ATL_NO_VTABLE CShellFileSaveDialogImpl :
public CShellFileDialogImpl< T >
1252 ATL::CComPtr<IFileSaveDialog> m_spFileDlg;
1254 CShellFileSaveDialogImpl(LPCWSTR lpszFileName = NULL,
1255 DWORD dwOptions = FOS_FORCEFILESYSTEM | FOS_PATHMUSTEXIST | FOS_OVERWRITEPROMPT,
1256 LPCWSTR lpszDefExt = NULL,
1257 const COMDLG_FILTERSPEC* arrFilterSpec = NULL,
1258 UINT uFilterSpecCount = 0U)
1260 HRESULT hRet = m_spFileDlg.CoCreateInstance(CLSID_FileSaveDialog);
1263 _Init(lpszFileName, dwOptions, lpszDefExt, arrFilterSpec, uFilterSpecCount);
1266 IFileSaveDialog* GetPtr()
1276 class CShellFileSaveDialog :
public CShellFileSaveDialogImpl<CShellFileSaveDialog>
1279 CShellFileSaveDialog(LPCWSTR lpszFileName = NULL,
1280 DWORD dwOptions = FOS_FORCEFILESYSTEM | FOS_PATHMUSTEXIST | FOS_OVERWRITEPROMPT,
1281 LPCWSTR lpszDefExt = NULL,
1282 const COMDLG_FILTERSPEC* arrFilterSpec = NULL,
1283 UINT uFilterSpecCount = 0U) : CShellFileSaveDialogImpl<CShellFileSaveDialog>(lpszFileName, dwOptions, lpszDefExt, arrFilterSpec, uFilterSpecCount)
1287 void _Advise(DWORD& )
1290 void _Unadvise(DWORD )
1294 #endif // (_WIN32_WINNT >= 0x0600) && !defined(_WIN32_WCE) 1307 LPCTSTR m_lpstrInitialFolder;
1308 LPCITEMIDLIST m_pidlInitialSelection;
1309 bool m_bExpandInitialSelection;
1310 TCHAR m_szFolderDisplayName[MAX_PATH];
1311 TCHAR m_szFolderPath[MAX_PATH];
1312 LPITEMIDLIST m_pidlSelected;
1316 CFolderDialogImpl(HWND hWndParent = NULL, LPCTSTR lpstrTitle = NULL, UINT uFlags = BIF_RETURNONLYFSDIRS) :
1317 m_lpstrInitialFolder(NULL), m_pidlInitialSelection(NULL), m_bExpandInitialSelection(
false), m_pidlSelected(NULL), m_hWnd(NULL)
1319 memset(&m_bi, 0,
sizeof(m_bi));
1321 m_bi.hwndOwner = hWndParent;
1322 m_bi.pidlRoot = NULL;
1323 m_bi.pszDisplayName = m_szFolderDisplayName;
1324 m_bi.lpszTitle = lpstrTitle;
1325 m_bi.ulFlags = uFlags;
1326 m_bi.lpfn = BrowseCallbackProc;
1327 m_bi.lParam = (LPARAM)static_cast<T*>(
this);
1329 m_szFolderPath[0] = 0;
1330 m_szFolderDisplayName[0] = 0;
1335 ::CoTaskMemFree(m_pidlSelected);
1339 INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow())
1341 if(m_bi.hwndOwner == NULL)
1342 m_bi.hwndOwner = hWndParent;
1345 m_szFolderPath[0] = 0;
1346 m_szFolderDisplayName[0] = 0;
1347 ::CoTaskMemFree(m_pidlSelected);
1349 INT_PTR nRet = IDCANCEL;
1350 m_pidlSelected = ::SHBrowseForFolder(&m_bi);
1352 if(m_pidlSelected != NULL)
1358 if((m_bi.ulFlags & BIF_RETURNONLYFSDIRS) != 0)
1360 if(::SHGetPathFromIDList(m_pidlSelected, m_szFolderPath) == FALSE)
1369 void SetInitialFolder(LPCTSTR lpstrInitialFolder,
bool bExpand =
true)
1372 m_lpstrInitialFolder = lpstrInitialFolder;
1373 m_bExpandInitialSelection = bExpand;
1376 void SetInitialSelection(LPCITEMIDLIST pidl,
bool bExpand =
true)
1378 m_pidlInitialSelection = pidl;
1379 m_bExpandInitialSelection = bExpand;
1383 LPITEMIDLIST GetSelectedItem(
bool bDetach =
false)
1385 LPITEMIDLIST pidl = m_pidlSelected;
1387 m_pidlSelected = NULL;
1392 LPCTSTR GetFolderPath()
const 1394 return m_szFolderPath;
1397 LPCTSTR GetFolderDisplayName()
const 1399 return m_szFolderDisplayName;
1402 int GetFolderImageIndex()
const 1408 static int CALLBACK BrowseCallbackProc(HWND hWnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
1410 #ifndef BFFM_VALIDATEFAILED 1412 const int BFFM_VALIDATEFAILED = 4;
1414 const int BFFM_VALIDATEFAILED = 3;
1416 #endif // !BFFM_VALIDATEFAILED 1417 #ifndef BFFM_IUNKNOWN 1418 const int BFFM_IUNKNOWN = 5;
1419 #endif // !BFFM_IUNKNOWN 1420 #ifndef BIF_NEWDIALOGSTYLE 1421 const UINT BIF_NEWDIALOGSTYLE = 0x0040;
1422 #endif // !BIF_NEWDIALOGSTYLE 1426 bool bClear =
false;
1427 if(pT->m_hWnd == NULL)
1434 ATLASSERT(pT->m_hWnd == hWnd);
1439 case BFFM_INITIALIZED:
1442 if(pT->m_pidlInitialSelection != NULL)
1443 pT->SetSelection(pT->m_pidlInitialSelection);
1444 else if(pT->m_lpstrInitialFolder != NULL)
1445 pT->SetSelection(pT->m_lpstrInitialFolder);
1448 if(pT->m_bExpandInitialSelection && ((pT->m_bi.ulFlags & BIF_NEWDIALOGSTYLE) != 0))
1450 if(pT->m_pidlInitialSelection != NULL)
1451 pT->SetExpanded(pT->m_pidlInitialSelection);
1452 else if(pT->m_lpstrInitialFolder != NULL)
1453 pT->SetExpanded(pT->m_lpstrInitialFolder);
1455 pT->OnInitialized();
1457 case BFFM_SELCHANGED:
1458 pT->OnSelChanged((LPITEMIDLIST)lParam);
1460 case BFFM_VALIDATEFAILED:
1461 nRet = pT->OnValidateFailed((LPCTSTR)lParam);
1464 pT->OnIUnknown((IUnknown*)lParam);
1467 ATLTRACE2(atlTraceUI, 0, _T(
"Unknown message received in CFolderDialogImpl::BrowseCallbackProc\n"));
1476 void OnInitialized()
1480 void OnSelChanged(LPITEMIDLIST )
1484 int OnValidateFailed(LPCTSTR )
1489 void OnIUnknown(IUnknown* )
1494 void EnableOK(BOOL bEnable)
1496 ATLASSERT(m_hWnd != NULL);
1497 ::SendMessage(m_hWnd, BFFM_ENABLEOK, 0, bEnable);
1500 void SetSelection(LPCITEMIDLIST pItemIDList)
1502 ATLASSERT(m_hWnd != NULL);
1503 ::SendMessage(m_hWnd, BFFM_SETSELECTION, FALSE, (LPARAM)pItemIDList);
1506 void SetSelection(LPCTSTR lpstrFolderPath)
1508 ATLASSERT(m_hWnd != NULL);
1509 ::SendMessage(m_hWnd, BFFM_SETSELECTION, TRUE, (LPARAM)lpstrFolderPath);
1512 void SetStatusText(LPCTSTR lpstrText)
1514 ATLASSERT(m_hWnd != NULL);
1515 ::SendMessage(m_hWnd, BFFM_SETSTATUSTEXT, 0, (LPARAM)lpstrText);
1518 void SetOKText(LPCTSTR lpstrOKText)
1520 #ifndef BFFM_SETOKTEXT 1521 const UINT BFFM_SETOKTEXT = WM_USER + 105;
1523 ATLASSERT(m_hWnd != NULL);
1525 LPCWSTR lpstr = T2CW(lpstrOKText);
1526 ::SendMessage(m_hWnd, BFFM_SETOKTEXT, 0, (LPARAM)lpstr);
1529 void SetExpanded(LPCITEMIDLIST pItemIDList)
1531 #ifndef BFFM_SETEXPANDED 1532 const UINT BFFM_SETEXPANDED = WM_USER + 106;
1534 ATLASSERT(m_hWnd != NULL);
1535 ::SendMessage(m_hWnd, BFFM_SETEXPANDED, FALSE, (LPARAM)pItemIDList);
1538 void SetExpanded(LPCTSTR lpstrFolderPath)
1540 #ifndef BFFM_SETEXPANDED 1541 const UINT BFFM_SETEXPANDED = WM_USER + 106;
1543 ATLASSERT(m_hWnd != NULL);
1545 LPCWSTR lpstr = T2CW(lpstrFolderPath);
1546 ::SendMessage(m_hWnd, BFFM_SETEXPANDED, TRUE, (LPARAM)lpstr);
1553 CFolderDialog(HWND hWndParent = NULL, LPCTSTR lpstrTitle = NULL, UINT uFlags = BIF_RETURNONLYFSDIRS)
1558 #endif // !_WIN32_WCE 1567 static UINT_PTR APIENTRY HookProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1569 if(uMsg != WM_INITDIALOG)
1572 ATLASSERT(pT != NULL);
1573 ATLASSERT(pT->m_hWnd == NULL);
1574 ATLASSERT(::IsWindow(hWnd));
1576 if(!pT->SubclassWindow(hWnd))
1578 ATLTRACE2(atlTraceUI, 0, _T(
"Subclassing a common dialog failed\n"));
1583 if(pT->ProcessWindowMessage(pT->m_hWnd, uMsg, wParam, lParam, lRes, 0) == FALSE)
1589 BOOL EndDialog(INT_PTR = 0)
1591 ATLASSERT(::IsWindow(m_hWnd));
1592 SendMessage(WM_COMMAND, MAKEWPARAM(IDABORT, 0));
1603 static LRESULT CALLBACK StartWindowProc(HWND , UINT , WPARAM , LPARAM )
1620 enum { _cchStyleName = 64 };
1623 TCHAR m_szStyleName[_cchStyleName];
1628 DWORD dwFlags = CF_EFFECTS | CF_SCREENFONTS,
1629 HDC hDCPrinter = NULL,
1630 HWND hWndParent = NULL)
1632 memset(&m_cf, 0,
sizeof(m_cf));
1633 memset(&m_lf, 0,
sizeof(m_lf));
1634 memset(&m_szStyleName, 0,
sizeof(m_szStyleName));
1636 m_cf.lStructSize =
sizeof(m_cf);
1637 m_cf.hwndOwner = hWndParent;
1638 m_cf.rgbColors = RGB(0, 0, 0);
1639 m_cf.lpszStyle = (LPTSTR)&m_szStyleName;
1640 m_cf.Flags = dwFlags | CF_ENABLEHOOK;
1641 m_cf.lpfnHook = (LPCFHOOKPROC)T::HookProc;
1643 if(lplfInitial != NULL)
1645 m_cf.lpLogFont = lplfInitial;
1646 m_cf.Flags |= CF_INITTOLOGFONTSTRUCT;
1647 m_lf = *lplfInitial;
1651 m_cf.lpLogFont = &m_lf;
1654 if(hDCPrinter != NULL)
1656 m_cf.hDC = hDCPrinter;
1657 m_cf.Flags |= CF_PRINTERFONTS;
1662 INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow())
1664 ATLASSERT((m_cf.Flags & CF_ENABLEHOOK) != 0);
1665 ATLASSERT(m_cf.lpfnHook != NULL);
1667 if(m_cf.hwndOwner == NULL)
1668 m_cf.hwndOwner = hWndParent;
1670 ATLASSERT(m_hWnd == NULL);
1673 BOOL bRet = ::ChooseFont(&m_cf);
1678 SecureHelper::memcpy_x(&m_lf,
sizeof(m_lf), m_cf.lpLogFont,
sizeof(m_lf));
1680 return bRet ? IDOK : IDCANCEL;
1684 void GetCurrentFont(LPLOGFONT lplf)
const 1686 ATLASSERT(lplf != NULL);
1689 ::SendMessage(m_hWnd, WM_CHOOSEFONT_GETLOGFONT, 0, (LPARAM)lplf);
1696 void SetLogFont(LPLOGFONT lplf)
1698 ATLASSERT(lplf != NULL);
1699 #ifndef WM_CHOOSEFONT_SETLOGFONT 1700 const UINT WM_CHOOSEFONT_SETLOGFONT = (WM_USER + 101);
1704 ::SendMessage(m_hWnd, WM_CHOOSEFONT_SETLOGFONT, 0, (LPARAM)lplf);
1709 m_cf.Flags |= CF_INITTOLOGFONTSTRUCT;
1713 void SetFlags(DWORD dwFlags)
1715 #ifndef WM_CHOOSEFONT_SETFLAGS 1716 const UINT WM_CHOOSEFONT_SETFLAGS = (WM_USER + 102);
1720 CHOOSEFONT cf = {
sizeof(CHOOSEFONT) };
1722 ::SendMessage(m_hWnd, WM_CHOOSEFONT_SETFLAGS, 0, (LPARAM)&cf);
1726 m_cf.Flags = dwFlags;
1729 #endif // !_WIN32_WCE 1732 LPCTSTR GetFaceName()
const 1734 return (LPCTSTR)m_cf.lpLogFont->lfFaceName;
1737 LPCTSTR GetStyleName()
const 1739 return m_cf.lpszStyle;
1744 return m_cf.iPointSize;
1747 COLORREF GetColor()
const 1749 return m_cf.rgbColors;
1752 int GetWeight()
const 1754 return (
int)m_cf.lpLogFont->lfWeight;
1757 BOOL IsStrikeOut()
const 1759 return (m_cf.lpLogFont->lfStrikeOut) ? TRUE : FALSE;
1762 BOOL IsUnderline()
const 1764 return (m_cf.lpLogFont->lfUnderline) ? TRUE : FALSE;
1769 return (m_cf.lpLogFont->lfWeight == FW_BOLD) ? TRUE : FALSE;
1772 BOOL IsItalic()
const 1774 return m_cf.lpLogFont->lfItalic ? TRUE : FALSE;
1782 DWORD dwFlags = CF_EFFECTS | CF_SCREENFONTS,
1783 HDC hDCPrinter = NULL,
1784 HWND hWndParent = NULL)
1788 DECLARE_EMPTY_MSG_MAP()
1791 #endif // _WIN32_WCE 1797 #if defined(_RICHEDIT_) && !defined(_WIN32_WCE) 1800 class ATL_NO_VTABLE CRichEditFontDialogImpl :
public CFontDialogImpl< T >
1803 CRichEditFontDialogImpl(
const CHARFORMAT& charformat,
1804 DWORD dwFlags = CF_SCREENFONTS,
1805 HDC hDCPrinter = NULL,
1806 HWND hWndParent = NULL)
1809 m_cf.Flags |= CF_INITTOLOGFONTSTRUCT;
1810 m_cf.Flags |= FillInLogFont(charformat);
1811 m_cf.lpLogFont = &m_lf;
1813 if((charformat.dwMask & CFM_COLOR) != 0)
1814 m_cf.rgbColors = charformat.crTextColor;
1817 void GetCharFormat(CHARFORMAT& cf)
const 1822 if((m_cf.Flags & CF_NOSTYLESEL) == 0)
1824 cf.dwMask |= CFM_BOLD | CFM_ITALIC;
1825 cf.dwEffects |= IsBold() ? CFE_BOLD : 0;
1826 cf.dwEffects |= IsItalic() ? CFE_ITALIC : 0;
1828 if((m_cf.Flags & CF_NOSIZESEL) == 0)
1830 cf.dwMask |= CFM_SIZE;
1832 cf.yHeight = GetSize() * 2;
1835 if((m_cf.Flags & CF_NOFACESEL) == 0)
1837 cf.dwMask |= CFM_FACE;
1838 cf.bPitchAndFamily = m_cf.lpLogFont->lfPitchAndFamily;
1839 #if (_RICHEDIT_VER >= 0x0200) 1840 SecureHelper::strcpy_x(cf.szFaceName, _countof(cf.szFaceName), GetFaceName());
1841 #else // !(_RICHEDIT_VER >= 0x0200) 1842 SecureHelper::strcpyA_x(cf.szFaceName, _countof(cf.szFaceName), T2A((LPTSTR)(LPCTSTR)GetFaceName()));
1843 #endif // !(_RICHEDIT_VER >= 0x0200) 1846 if((m_cf.Flags & CF_EFFECTS) != 0)
1848 cf.dwMask |= CFM_UNDERLINE | CFM_STRIKEOUT | CFM_COLOR;
1849 cf.dwEffects |= IsUnderline() ? CFE_UNDERLINE : 0;
1850 cf.dwEffects |= IsStrikeOut() ? CFE_STRIKEOUT : 0;
1851 cf.crTextColor = GetColor();
1853 if((m_cf.Flags & CF_NOSCRIPTSEL) == 0)
1855 cf.bCharSet = m_cf.lpLogFont->lfCharSet;
1856 cf.dwMask |= CFM_CHARSET;
1861 DWORD FillInLogFont(
const CHARFORMAT& cf)
1865 if((cf.dwMask & CFM_SIZE) != 0)
1867 HDC hDC = ::CreateDC(_T(
"DISPLAY"), NULL, NULL, NULL);
1868 LONG yPerInch = ::GetDeviceCaps(hDC, LOGPIXELSY);
1869 m_lf.lfHeight = -(int)((cf.yHeight * yPerInch) / 1440);
1875 m_lf.lfEscapement = 0;
1876 m_lf.lfOrientation = 0;
1878 if((cf.dwMask & (CFM_ITALIC | CFM_BOLD)) == (CFM_ITALIC | CFM_BOLD))
1880 m_lf.lfWeight = ((cf.dwEffects & CFE_BOLD) != 0) ? FW_BOLD : FW_NORMAL;
1881 m_lf.lfItalic = (BYTE)(((cf.dwEffects & CFE_ITALIC) != 0) ? TRUE : FALSE);
1885 dwFlags |= CF_NOSTYLESEL;
1886 m_lf.lfWeight = FW_DONTCARE;
1887 m_lf.lfItalic = FALSE;
1890 if((cf.dwMask & (CFM_UNDERLINE | CFM_STRIKEOUT | CFM_COLOR)) == (CFM_UNDERLINE|CFM_STRIKEOUT|CFM_COLOR))
1892 dwFlags |= CF_EFFECTS;
1893 m_lf.lfUnderline = (BYTE)(((cf.dwEffects & CFE_UNDERLINE) != 0) ? TRUE : FALSE);
1894 m_lf.lfStrikeOut = (BYTE)(((cf.dwEffects & CFE_STRIKEOUT) != 0) ? TRUE : FALSE);
1898 m_lf.lfUnderline = (BYTE)FALSE;
1899 m_lf.lfStrikeOut = (BYTE)FALSE;
1902 if((cf.dwMask & CFM_CHARSET) != 0)
1903 m_lf.lfCharSet = cf.bCharSet;
1905 dwFlags |= CF_NOSCRIPTSEL;
1906 m_lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
1907 m_lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
1908 m_lf.lfQuality = DEFAULT_QUALITY;
1909 if((cf.dwMask & CFM_FACE) != 0)
1911 m_lf.lfPitchAndFamily = cf.bPitchAndFamily;
1912 #if (_RICHEDIT_VER >= 0x0200) 1913 SecureHelper::strcpy_x(m_lf.lfFaceName, _countof(m_lf.lfFaceName), cf.szFaceName);
1914 #else // !(_RICHEDIT_VER >= 0x0200) 1915 SecureHelper::strcpy_x(m_lf.lfFaceName, _countof(m_lf.lfFaceName), A2T((LPSTR)cf.szFaceName));
1916 #endif // !(_RICHEDIT_VER >= 0x0200) 1920 m_lf.lfPitchAndFamily = DEFAULT_PITCH|FF_DONTCARE;
1921 m_lf.lfFaceName[0] = (TCHAR)0;
1927 class CRichEditFontDialog :
public CRichEditFontDialogImpl<CRichEditFontDialog>
1930 CRichEditFontDialog(
const CHARFORMAT& charformat,
1931 DWORD dwFlags = CF_SCREENFONTS,
1932 HDC hDCPrinter = NULL,
1933 HWND hWndParent = NULL)
1934 : CRichEditFontDialogImpl<CRichEditFontDialog>(charformat, dwFlags, hDCPrinter, hWndParent)
1937 DECLARE_EMPTY_MSG_MAP()
1940 #endif // defined(_RICHEDIT_) && !defined(_WIN32_WCE) 1946 #if !defined(_WIN32_WCE) || ((_WIN32_WCE > 420) && !(defined(WIN32_PLATFORM_WFSP) && (_WIN32_WCE > 0x0500))) 1949 #pragma comment(lib, "commdlg.lib") 1951 #ifndef SETRGBSTRING 1952 #define SETRGBSTRING _T("commdlg_SetRGBColor") 1955 #ifndef COLOROKSTRING 1956 #define COLOROKSTRING _T("commdlg_ColorOK") 1967 CColorDialogImpl(COLORREF clrInit = 0, DWORD dwFlags = 0, HWND hWndParent = NULL)
1969 memset(&m_cc, 0,
sizeof(m_cc));
1971 m_cc.lStructSize =
sizeof(m_cc);
1972 m_cc.lpCustColors = GetCustomColors();
1973 m_cc.hwndOwner = hWndParent;
1974 m_cc.Flags = dwFlags | CC_ENABLEHOOK;
1975 m_cc.lpfnHook = (LPCCHOOKPROC)T::HookProc;
1979 m_cc.rgbResult = clrInit;
1980 m_cc.Flags |= CC_RGBINIT;
1985 INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow())
1987 ATLASSERT((m_cc.Flags & CC_ENABLEHOOK) != 0);
1988 ATLASSERT(m_cc.lpfnHook != NULL);
1990 if(m_cc.hwndOwner == NULL)
1991 m_cc.hwndOwner = hWndParent;
1993 ATLASSERT(m_hWnd == NULL);
1996 BOOL bRet = ::ChooseColor(&m_cc);
2000 return bRet ? IDOK : IDCANCEL;
2004 void SetCurrentColor(COLORREF clr)
2006 ATLASSERT(::IsWindow(m_hWnd));
2007 SendMessage(_GetSetRGBMessage(), 0, (LPARAM)clr);
2011 COLORREF GetColor()
const 2013 return m_cc.rgbResult;
2017 static UINT_PTR APIENTRY HookProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
2019 if(uMsg != WM_INITDIALOG && uMsg != _GetColorOKMessage())
2022 LPCHOOSECOLOR lpCC = (LPCHOOSECOLOR)lParam;
2025 if(uMsg == WM_INITDIALOG)
2028 lpCC->lCustData = (LPARAM)pT;
2029 ATLASSERT(pT != NULL);
2030 ATLASSERT(pT->m_hWnd == NULL);
2031 ATLASSERT(::IsWindow(hWnd));
2033 if(!pT->SubclassWindow(hWnd))
2035 ATLTRACE2(atlTraceUI, 0, _T(
"Subclassing a Color common dialog failed\n"));
2039 else if(uMsg == _GetColorOKMessage())
2042 ATLASSERT(pT != NULL);
2043 ATLASSERT(::IsWindow(pT->m_hWnd));
2048 if(pT->ProcessWindowMessage(pT->m_hWnd, uMsg, wParam, lParam, lRes, 0) == FALSE)
2054 static COLORREF* GetCustomColors()
2056 static COLORREF rgbCustomColors[16] =
2058 RGB(255, 255, 255), RGB(255, 255, 255),
2059 RGB(255, 255, 255), RGB(255, 255, 255),
2060 RGB(255, 255, 255), RGB(255, 255, 255),
2061 RGB(255, 255, 255), RGB(255, 255, 255),
2062 RGB(255, 255, 255), RGB(255, 255, 255),
2063 RGB(255, 255, 255), RGB(255, 255, 255),
2064 RGB(255, 255, 255), RGB(255, 255, 255),
2065 RGB(255, 255, 255), RGB(255, 255, 255),
2068 return rgbCustomColors;
2071 static UINT _GetSetRGBMessage()
2073 static UINT uSetRGBMessage = 0;
2074 if(uSetRGBMessage == 0)
2077 if(FAILED(lock.Lock()))
2079 ATLTRACE2(atlTraceUI, 0, _T(
"ERROR : Unable to lock critical section in CColorDialogImpl::_GetSetRGBMessage.\n"));
2084 if(uSetRGBMessage == 0)
2085 uSetRGBMessage = ::RegisterWindowMessage(SETRGBSTRING);
2089 ATLASSERT(uSetRGBMessage != 0);
2090 return uSetRGBMessage;
2093 static UINT _GetColorOKMessage()
2095 static UINT uColorOKMessage = 0;
2096 if(uColorOKMessage == 0)
2099 if(FAILED(lock.Lock()))
2101 ATLTRACE2(atlTraceUI, 0, _T(
"ERROR : Unable to lock critical section in CColorDialogImpl::_GetColorOKMessage.\n"));
2106 if(uColorOKMessage == 0)
2107 uColorOKMessage = ::RegisterWindowMessage(COLOROKSTRING);
2111 ATLASSERT(uColorOKMessage != 0);
2112 return uColorOKMessage;
2117 MESSAGE_HANDLER(_GetColorOKMessage(), _OnColorOK)
2120 LRESULT _OnColorOK(UINT, WPARAM, LPARAM, BOOL&)
2122 T* pT =
static_cast<T*
>(
this);
2123 return pT->OnColorOK();
2136 CColorDialog(COLORREF clrInit = 0, DWORD dwFlags = 0, HWND hWndParent = NULL)
2141 DECLARE_EMPTY_MSG_MAP()
2144 #endif // !defined(_WIN32_WCE) || ((_WIN32_WCE > 420) && !(defined(WIN32_PLATFORM_WFSP) && (_WIN32_WCE > 0x0500))) 2153 static HDC _AtlCreateDC(HGLOBAL hDevNames, HGLOBAL hDevMode)
2155 if(hDevNames == NULL)
2158 LPDEVNAMES lpDevNames = (LPDEVNAMES)::GlobalLock(hDevNames);
2159 LPDEVMODE lpDevMode = (hDevMode != NULL) ? (LPDEVMODE)::GlobalLock(hDevMode) : NULL;
2161 if(lpDevNames == NULL)
2164 HDC hDC = ::CreateDC((LPCTSTR)lpDevNames + lpDevNames->wDriverOffset,
2165 (LPCTSTR)lpDevNames + lpDevNames->wDeviceOffset,
2166 (LPCTSTR)lpDevNames + lpDevNames->wOutputOffset,
2169 ::GlobalUnlock(hDevNames);
2170 if(hDevMode != NULL)
2171 ::GlobalUnlock(hDevMode);
2184 DWORD dwFlags = PD_ALLPAGES | PD_USEDEVMODECOPIES | PD_NOPAGENUMS | PD_NOSELECTION,
2185 HWND hWndParent = NULL)
2188 memset(&m_pdActual, 0,
sizeof(m_pdActual));
2190 m_pd.lStructSize =
sizeof(m_pdActual);
2191 m_pd.hwndOwner = hWndParent;
2192 m_pd.Flags = (dwFlags | PD_ENABLEPRINTHOOK | PD_ENABLESETUPHOOK);
2193 m_pd.lpfnPrintHook = (LPPRINTHOOKPROC)T::HookProc;
2194 m_pd.lpfnSetupHook = (LPSETUPHOOKPROC)T::HookProc;
2197 m_pd.Flags |= PD_PRINTSETUP;
2199 m_pd.Flags |= PD_RETURNDC;
2201 m_pd.Flags &= ~PD_RETURNIC;
2205 INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow())
2207 ATLASSERT((m_pd.Flags & PD_ENABLEPRINTHOOK) != 0);
2208 ATLASSERT((m_pd.Flags & PD_ENABLESETUPHOOK) != 0);
2209 ATLASSERT(m_pd.lpfnPrintHook != NULL);
2210 ATLASSERT(m_pd.lpfnSetupHook != NULL);
2211 ATLASSERT((m_pd.Flags & PD_RETURNDEFAULT) == 0);
2213 if(m_pd.hwndOwner == NULL)
2214 m_pd.hwndOwner = hWndParent;
2216 ATLASSERT(m_hWnd == NULL);
2219 BOOL bRet = ::PrintDlg(&m_pd);
2223 return bRet ? IDOK : IDCANCEL;
2229 m_pd.Flags |= PD_RETURNDEFAULT;
2230 ATLASSERT(m_pd.hDevMode == NULL);
2231 ATLASSERT(m_pd.hDevNames == NULL);
2233 return ::PrintDlg(&m_pd);
2237 int GetCopies()
const 2239 if((m_pd.Flags & PD_USEDEVMODECOPIES) != 0)
2241 LPDEVMODE lpDevMode = GetDevMode();
2242 return (lpDevMode != NULL) ? lpDevMode->dmCopies : -1;
2245 return m_pd.nCopies;
2248 BOOL PrintCollate()
const 2250 return ((m_pd.Flags & PD_COLLATE) != 0) ? TRUE : FALSE;
2253 BOOL PrintSelection()
const 2255 return ((m_pd.Flags & PD_SELECTION) != 0) ? TRUE : FALSE;
2258 BOOL PrintAll()
const 2260 return (!PrintRange() && !PrintSelection()) ? TRUE : FALSE;
2263 BOOL PrintRange()
const 2265 return ((m_pd.Flags & PD_PAGENUMS) != 0) ? TRUE : FALSE;
2268 BOOL PrintToFile()
const 2270 return ((m_pd.Flags & PD_PRINTTOFILE) != 0) ? TRUE : FALSE;
2273 int GetFromPage()
const 2275 return PrintRange() ? m_pd.nFromPage : -1;
2278 int GetToPage()
const 2280 return PrintRange() ? m_pd.nToPage : -1;
2283 LPDEVMODE GetDevMode()
const 2285 if(m_pd.hDevMode == NULL)
2288 return (LPDEVMODE)::GlobalLock(m_pd.hDevMode);
2291 LPCTSTR GetDriverName()
const 2293 if(m_pd.hDevNames == NULL)
2296 LPDEVNAMES lpDev = (LPDEVNAMES)::GlobalLock(m_pd.hDevNames);
2300 return (LPCTSTR)lpDev + lpDev->wDriverOffset;
2303 LPCTSTR GetDeviceName()
const 2305 if(m_pd.hDevNames == NULL)
2308 LPDEVNAMES lpDev = (LPDEVNAMES)::GlobalLock(m_pd.hDevNames);
2312 return (LPCTSTR)lpDev + lpDev->wDeviceOffset;
2315 LPCTSTR GetPortName()
const 2317 if(m_pd.hDevNames == NULL)
2320 LPDEVNAMES lpDev = (LPDEVNAMES)::GlobalLock(m_pd.hDevNames);
2324 return (LPCTSTR)lpDev + lpDev->wOutputOffset;
2327 HDC GetPrinterDC()
const 2329 ATLASSERT((m_pd.Flags & PD_RETURNDC) != 0);
2338 HDC CreatePrinterDC()
2340 m_pd.hDC = _AtlCreateDC(m_pd.hDevNames, m_pd.hDevMode);
2345 PRINTDLG m_pdActual;
2353 COMMAND_ID_HANDLER(psh1, OnPrintSetup)
2355 COMMAND_ID_HANDLER(0x0400, OnPrintSetup)
2359 LRESULT OnPrintSetup(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& )
2363 return DefWindowProc(WM_COMMAND, MAKEWPARAM(wID, wNotifyCode), (LPARAM)hWndCtl);
2371 DWORD dwFlags = PD_ALLPAGES | PD_USEDEVMODECOPIES | PD_NOPAGENUMS | PD_NOSELECTION,
2372 HWND hWndParent = NULL)
2380 #endif // _WIN32_WCE 2386 #if (WINVER >= 0x0500) && !defined(_WIN32_WCE) 2392 extern "C" const __declspec(selectany) IID IID_IPrintDialogCallback = {0x5852a2c3, 0x6530, 0x11d1, {0xb6, 0xa3, 0x0, 0x0, 0xf8, 0x75, 0x7b, 0xf9}};
2393 extern "C" const __declspec(selectany) IID IID_IPrintDialogServices = {0x509aaeda, 0x5639, 0x11d1, {0xb6, 0xa1, 0x0, 0x0, 0xf8, 0x75, 0x7b, 0xf9}};
2399 class ATL_NO_VTABLE CPrintDialogExImpl :
2400 public ATL::CWindow,
2401 public ATL::CMessageMap,
2402 public IPrintDialogCallback,
2403 public ATL::IObjectWithSiteImpl< T >
2409 CPrintDialogExImpl(DWORD dwFlags = PD_ALLPAGES | PD_USEDEVMODECOPIES | PD_NOPAGENUMS | PD_NOSELECTION | PD_NOCURRENTPAGE,
2410 HWND hWndParent = NULL)
2412 memset(&m_pdex, 0,
sizeof(m_pdex));
2414 m_pdex.lStructSize =
sizeof(PRINTDLGEX);
2415 m_pdex.hwndOwner = hWndParent;
2416 m_pdex.Flags = dwFlags;
2417 m_pdex.nStartPage = START_PAGE_GENERAL;
2420 m_pdex.Flags &= ~PD_RETURNIC;
2424 HRESULT DoModal(HWND hWndParent = ::GetActiveWindow())
2426 ATLASSERT(m_hWnd == NULL);
2427 ATLASSERT((m_pdex.Flags & PD_RETURNDEFAULT) == 0);
2429 if(m_pdex.hwndOwner == NULL)
2430 m_pdex.hwndOwner = hWndParent;
2432 T* pT =
static_cast<T*
>(
this);
2433 m_pdex.lpCallback = (IUnknown*)(IPrintDialogCallback*)pT;
2435 HRESULT hResult = ::PrintDlgEx(&m_pdex);
2442 BOOL EndDialog(INT_PTR = 0)
2444 ATLASSERT(::IsWindow(m_hWnd));
2445 SendMessage(WM_COMMAND, MAKEWPARAM(IDABORT, 0));
2450 HRESULT GetDefaults()
2452 m_pdex.Flags |= PD_RETURNDEFAULT;
2453 ATLASSERT(m_pdex.hDevMode == NULL);
2454 ATLASSERT(m_pdex.hDevNames == NULL);
2456 return ::PrintDlgEx(&m_pdex);
2460 int GetCopies()
const 2462 if((m_pdex.Flags & PD_USEDEVMODECOPIES) != 0)
2464 LPDEVMODE lpDevMode = GetDevMode();
2465 return (lpDevMode != NULL) ? lpDevMode->dmCopies : -1;
2468 return m_pdex.nCopies;
2471 BOOL PrintCollate()
const 2473 return ((m_pdex.Flags & PD_COLLATE) != 0) ? TRUE : FALSE;
2476 BOOL PrintSelection()
const 2478 return ((m_pdex.Flags & PD_SELECTION) != 0) ? TRUE : FALSE;
2481 BOOL PrintAll()
const 2483 return (!PrintRange() && !PrintSelection()) ? TRUE : FALSE;
2486 BOOL PrintRange()
const 2488 return ((m_pdex.Flags & PD_PAGENUMS) != 0) ? TRUE : FALSE;
2491 BOOL PrintToFile()
const 2493 return ((m_pdex.Flags & PD_PRINTTOFILE) != 0) ? TRUE : FALSE;
2496 LPDEVMODE GetDevMode()
const 2498 if(m_pdex.hDevMode == NULL)
2501 return (LPDEVMODE)::GlobalLock(m_pdex.hDevMode);
2504 LPCTSTR GetDriverName()
const 2506 if(m_pdex.hDevNames == NULL)
2509 LPDEVNAMES lpDev = (LPDEVNAMES)::GlobalLock(m_pdex.hDevNames);
2513 return (LPCTSTR)lpDev + lpDev->wDriverOffset;
2516 LPCTSTR GetDeviceName()
const 2518 if(m_pdex.hDevNames == NULL)
2521 LPDEVNAMES lpDev = (LPDEVNAMES)::GlobalLock(m_pdex.hDevNames);
2525 return (LPCTSTR)lpDev + lpDev->wDeviceOffset;
2528 LPCTSTR GetPortName()
const 2530 if(m_pdex.hDevNames == NULL)
2533 LPDEVNAMES lpDev = (LPDEVNAMES)::GlobalLock(m_pdex.hDevNames);
2537 return (LPCTSTR)lpDev + lpDev->wOutputOffset;
2540 HDC GetPrinterDC()
const 2542 ATLASSERT((m_pdex.Flags & PD_RETURNDC) != 0);
2551 HDC CreatePrinterDC()
2553 m_pdex.hDC = _AtlCreateDC(m_pdex.hDevNames, m_pdex.hDevMode);
2560 STDMETHOD(QueryInterface)(REFIID riid,
void** ppvObject)
2562 if(ppvObject == NULL)
2565 T* pT =
static_cast<T*
>(
this);
2566 if(IsEqualGUID(riid, IID_IUnknown) || IsEqualGUID(riid, IID_IPrintDialogCallback))
2568 *ppvObject = (IPrintDialogCallback*)pT;
2572 else if(IsEqualGUID(riid, IID_IObjectWithSite))
2574 *ppvObject = (IObjectWithSite*)pT;
2579 return E_NOINTERFACE;
2582 virtual ULONG STDMETHODCALLTYPE AddRef()
2587 virtual ULONG STDMETHODCALLTYPE Release()
2593 STDMETHOD(InitDone)()
2598 STDMETHOD(SelectionChange)()
2603 STDMETHOD(HandleMessage)(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT* plResult)
2610 HRESULT hRet = ProcessWindowMessage(hWnd, uMsg, wParam, lParam, *plResult, 0) ? S_OK : S_FALSE;
2611 if(hRet == S_OK && uMsg == WM_NOTIFY)
2612 ::SetWindowLongPtr(GetParent(), DWLP_MSGRESULT, (LONG_PTR)*plResult);
2614 if(uMsg == WM_INITDIALOG && hRet == S_OK && (BOOL)*plResult != FALSE)
2621 class CPrintDialogEx :
public CPrintDialogExImpl<CPrintDialogEx>
2625 DWORD dwFlags = PD_ALLPAGES | PD_USEDEVMODECOPIES | PD_NOPAGENUMS | PD_NOSELECTION | PD_NOCURRENTPAGE,
2626 HWND hWndParent = NULL)
2627 : CPrintDialogExImpl<CPrintDialogEx>(dwFlags, hWndParent)
2630 DECLARE_EMPTY_MSG_MAP()
2633 #endif // (WINVER >= 0x0500) && !defined(_WIN32_WCE) 2646 ATL::CWndProcThunk m_thunkPaint;
2649 CPageSetupDialogImpl(DWORD dwFlags = PSD_MARGINS | PSD_INWININIINTLMEASURE, HWND hWndParent = NULL)
2651 memset(&m_psd, 0,
sizeof(m_psd));
2653 m_psd.lStructSize =
sizeof(m_psd);
2654 m_psd.hwndOwner = hWndParent;
2655 m_psd.Flags = (dwFlags | PSD_ENABLEPAGESETUPHOOK | PSD_ENABLEPAGEPAINTHOOK);
2656 m_psd.lpfnPageSetupHook = (LPPAGESETUPHOOK)T::HookProc;
2657 m_thunkPaint.Init((WNDPROC)T::PaintHookProc,
this);
2658 #if (_ATL_VER >= 0x0700) 2659 m_psd.lpfnPagePaintHook = (LPPAGEPAINTHOOK)m_thunkPaint.GetWNDPROC();
2661 m_psd.lpfnPagePaintHook = (LPPAGEPAINTHOOK)&(m_thunkPaint.thunk);
2665 DECLARE_EMPTY_MSG_MAP()
2668 LPDEVMODE GetDevMode()
const 2670 if(m_psd.hDevMode == NULL)
2673 return (LPDEVMODE)::GlobalLock(m_psd.hDevMode);
2676 LPCTSTR GetDriverName()
const 2678 if(m_psd.hDevNames == NULL)
2681 LPDEVNAMES lpDev = (LPDEVNAMES)::GlobalLock(m_psd.hDevNames);
2682 return (LPCTSTR)lpDev + lpDev->wDriverOffset;
2685 LPCTSTR GetDeviceName()
const 2687 if(m_psd.hDevNames == NULL)
2690 LPDEVNAMES lpDev = (LPDEVNAMES)::GlobalLock(m_psd.hDevNames);
2691 return (LPCTSTR)lpDev + lpDev->wDeviceOffset;
2694 LPCTSTR GetPortName()
const 2696 if(m_psd.hDevNames == NULL)
2699 LPDEVNAMES lpDev = (LPDEVNAMES)::GlobalLock(m_psd.hDevNames);
2700 return (LPCTSTR)lpDev + lpDev->wOutputOffset;
2703 HDC CreatePrinterDC()
2705 return _AtlCreateDC(m_psd.hDevNames, m_psd.hDevMode);
2708 SIZE GetPaperSize()
const 2711 size.cx = m_psd.ptPaperSize.x;
2712 size.cy = m_psd.ptPaperSize.y;
2716 void GetMargins(LPRECT lpRectMargins, LPRECT lpRectMinMargins)
const 2718 if(lpRectMargins != NULL)
2719 *lpRectMargins = m_psd.rtMargin;
2720 if(lpRectMinMargins != NULL)
2721 *lpRectMinMargins = m_psd.rtMinMargin;
2725 INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow())
2727 ATLASSERT((m_psd.Flags & PSD_ENABLEPAGESETUPHOOK) != 0);
2728 ATLASSERT((m_psd.Flags & PSD_ENABLEPAGEPAINTHOOK) != 0);
2729 ATLASSERT(m_psd.lpfnPageSetupHook != NULL);
2730 ATLASSERT(m_psd.lpfnPagePaintHook != NULL);
2732 if(m_psd.hwndOwner == NULL)
2733 m_psd.hwndOwner = hWndParent;
2735 ATLASSERT(m_hWnd == NULL);
2738 BOOL bRet = ::PageSetupDlg(&m_psd);
2742 return bRet ? IDOK : IDCANCEL;
2746 static UINT_PTR CALLBACK PaintHookProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
2752 case WM_PSD_PAGESETUPDLG:
2753 uRet = pT->PreDrawPage(LOWORD(wParam), HIWORD(wParam), (LPPAGESETUPDLG)lParam);
2755 case WM_PSD_FULLPAGERECT:
2756 case WM_PSD_MINMARGINRECT:
2757 case WM_PSD_MARGINRECT:
2758 case WM_PSD_GREEKTEXTRECT:
2759 case WM_PSD_ENVSTAMPRECT:
2760 case WM_PSD_YAFULLPAGERECT:
2761 uRet = pT->OnDrawPage(uMsg, (HDC)wParam, (LPRECT)lParam);
2764 ATLTRACE2(atlTraceUI, 0, _T(
"CPageSetupDialogImpl::PaintHookProc - unknown message received\n"));
2771 UINT_PTR PreDrawPage(WORD , WORD , LPPAGESETUPDLG )
2777 UINT_PTR OnDrawPage(UINT , HDC , LPRECT )
2786 CPageSetupDialog(DWORD dwFlags = PSD_MARGINS | PSD_INWININIINTLMEASURE, HWND hWndParent = NULL)
2791 static UINT_PTR CALLBACK PaintHookProc(HWND, UINT, WPARAM, LPARAM)
2797 #endif // _WIN32_WCE 2809 enum { _cchFindReplaceBuffer = 128 };
2812 TCHAR m_szFindWhat[_cchFindReplaceBuffer];
2813 TCHAR m_szReplaceWith[_cchFindReplaceBuffer];
2818 memset(&m_fr, 0,
sizeof(m_fr));
2819 m_szFindWhat[0] = _T(
'\0');
2820 m_szReplaceWith[0] = _T(
'\0');
2822 m_fr.lStructSize =
sizeof(m_fr);
2823 m_fr.Flags = FR_ENABLEHOOK;
2824 m_fr.lpfnHook = (LPFRHOOKPROC)T::HookProc;
2825 m_fr.lpstrFindWhat = (LPTSTR)m_szFindWhat;
2826 m_fr.wFindWhatLen = _cchFindReplaceBuffer;
2827 m_fr.lpstrReplaceWith = (LPTSTR)m_szReplaceWith;
2828 m_fr.wReplaceWithLen = _cchFindReplaceBuffer;
2833 virtual void OnFinalMessage(HWND )
2838 HWND Create(BOOL bFindDialogOnly,
2839 LPCTSTR lpszFindWhat,
2840 LPCTSTR lpszReplaceWith = NULL,
2841 DWORD dwFlags = FR_DOWN,
2842 HWND hWndParent = NULL)
2844 ATLASSERT((m_fr.Flags & FR_ENABLEHOOK) != 0);
2845 ATLASSERT(m_fr.lpfnHook != NULL);
2847 m_fr.Flags |= dwFlags;
2849 if(hWndParent == NULL)
2850 m_fr.hwndOwner = ::GetActiveWindow();
2852 m_fr.hwndOwner = hWndParent;
2853 ATLASSERT(m_fr.hwndOwner != NULL);
2855 if(lpszFindWhat != NULL)
2856 SecureHelper::strncpy_x(m_szFindWhat, _countof(m_szFindWhat), lpszFindWhat, _TRUNCATE);
2858 if(lpszReplaceWith != NULL)
2859 SecureHelper::strncpy_x(m_szReplaceWith, _countof(m_szReplaceWith), lpszReplaceWith, _TRUNCATE);
2861 ATLASSERT(m_hWnd == NULL);
2866 hWnd = ::FindText(&m_fr);
2868 hWnd = ::ReplaceText(&m_fr);
2870 ATLASSERT(m_hWnd == hWnd);
2874 static const UINT GetFindReplaceMsg()
2876 static const UINT nMsgFindReplace = ::RegisterWindowMessage(FINDMSGSTRING);
2877 return nMsgFindReplace;
2881 static T* PASCAL GetNotifier(LPARAM lParam)
2883 ATLASSERT(lParam != NULL);
2884 T* pDlg = (T*)(lParam - offsetof(T, m_fr));
2890 LPCTSTR GetFindString()
const 2892 return (LPCTSTR)m_fr.lpstrFindWhat;
2895 LPCTSTR GetReplaceString()
const 2897 return (LPCTSTR)m_fr.lpstrReplaceWith;
2900 BOOL SearchDown()
const 2902 return ((m_fr.Flags & FR_DOWN) != 0) ? TRUE : FALSE;
2905 BOOL FindNext()
const 2907 return ((m_fr.Flags & FR_FINDNEXT) != 0) ? TRUE : FALSE;
2910 BOOL MatchCase()
const 2912 return ((m_fr.Flags & FR_MATCHCASE) != 0) ? TRUE : FALSE;
2915 BOOL MatchWholeWord()
const 2917 return ((m_fr.Flags & FR_WHOLEWORD) != 0) ? TRUE : FALSE;
2920 BOOL ReplaceCurrent()
const 2922 return ((m_fr. Flags & FR_REPLACE) != 0) ? TRUE : FALSE;
2925 BOOL ReplaceAll()
const 2927 return ((m_fr.Flags & FR_REPLACEALL) != 0) ? TRUE : FALSE;
2930 BOOL IsTerminating()
const 2932 return ((m_fr.Flags & FR_DIALOGTERM) != 0) ? TRUE : FALSE ;
2939 DECLARE_EMPTY_MSG_MAP()
2942 #endif // !_WIN32_WCE 2958 LONG nDlgBaseUnits = ::GetDialogBaseUnits();
2959 m_sizeUnits.cx = LOWORD(nDlgBaseUnits);
2960 m_sizeUnits.cy = HIWORD(nDlgBaseUnits);
2965 if(!InitDialogBaseUnits(hWnd)) {
2966 LONG nDlgBaseUnits = ::GetDialogBaseUnits();
2967 m_sizeUnits.cx = LOWORD(nDlgBaseUnits);
2968 m_sizeUnits.cy = HIWORD(nDlgBaseUnits);
2974 if(!InitDialogBaseUnits(hFont, hWnd)) {
2975 LONG nDlgBaseUnits = ::GetDialogBaseUnits();
2976 m_sizeUnits.cx = LOWORD(nDlgBaseUnits);
2977 m_sizeUnits.cy = HIWORD(nDlgBaseUnits);
2983 if(!InitDialogBaseUnits(lf, hWnd)) {
2984 LONG nDlgBaseUnits = ::GetDialogBaseUnits();
2985 m_sizeUnits.cx = LOWORD(nDlgBaseUnits);
2986 m_sizeUnits.cy = HIWORD(nDlgBaseUnits);
2991 BOOL InitDialogBaseUnits(HWND hWnd)
2993 ATLASSERT(::IsWindow(hWnd));
2994 RECT rc = { 0, 0, 4, 8 };
2995 if(!::MapDialogRect(hWnd, &rc))
return FALSE;
2996 m_sizeUnits.cx = rc.right;
2997 m_sizeUnits.cy = rc.bottom;
3001 BOOL InitDialogBaseUnits(LOGFONT lf, HWND hWnd = NULL)
3004 font.CreateFontIndirect(&lf);
3005 if(font.IsNull())
return FALSE;
3006 return InitDialogBaseUnits(font, hWnd);
3009 BOOL InitDialogBaseUnits(HFONT hFont, HWND hWnd = NULL)
3011 ATLASSERT(hFont != NULL);
3013 TEXTMETRIC tmText = { 0 };
3014 SIZE sizeText = { 0 };
3015 HFONT hFontOld = dc.SelectFont(hFont);
3016 dc.GetTextMetrics(&tmText);
3017 m_sizeUnits.cy = tmText.tmHeight + tmText.tmExternalLeading;
3018 dc.GetTextExtent(_T(
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"), 52, &sizeText);
3019 m_sizeUnits.cx = (sizeText.cx + 26) / 52;
3020 dc.SelectFont(hFontOld);
3024 SIZE GetDialogBaseUnits()
const 3029 INT MapDialogPixelsX(INT x)
const 3031 return ::MulDiv(x, 4, m_sizeUnits.cx);
3034 INT MapDialogPixelsY(INT y)
const 3036 return ::MulDiv(y, 8, m_sizeUnits.cy);
3039 POINT MapDialogPixels(POINT pt)
const 3041 POINT out = { MapDialogPixelsX(pt.x), MapDialogPixelsY(pt.y) };
3045 SIZE MapDialogPixels(SIZE input)
const 3047 SIZE out = { MapDialogPixelsX(input.cx), MapDialogPixelsY(input.cy) };
3051 RECT MapDialogPixels(RECT input)
const 3053 RECT out = { MapDialogPixelsX(input.left), MapDialogPixelsY(input.top), MapDialogPixelsX(input.right), MapDialogPixelsY(input.bottom) };
3057 INT MapDialogUnitsX(INT x)
const 3059 return ::MulDiv(x, m_sizeUnits.cx, 4);
3062 INT MapDialogUnitsY(INT y)
const 3064 return ::MulDiv(y, m_sizeUnits.cx, 8);
3067 POINT MapDialogUnits(POINT pt)
const 3069 POINT out = { MapDialogUnitsX(pt.x), MapDialogUnitsY(pt.y) };
3073 SIZE MapDialogUnits(SIZE input)
const 3075 SIZE out = { MapDialogUnitsX(input.cx), MapDialogUnitsY(input.cy) };
3079 RECT MapDialogUnits(RECT input)
const 3081 RECT out = { MapDialogUnitsX(input.left), MapDialogUnitsY(input.top), MapDialogUnitsX(input.right), MapDialogUnitsY(input.bottom) };
3090 #if (_ATL_VER >= 0x800) 3091 typedef ATL::_DialogSplitHelper::DLGTEMPLATEEX DLGTEMPLATEEX;
3093 #else // (_ATL_VER >= 0x800) 3094 typedef ATL::_DialogSizeHelper::_ATL_DLGTEMPLATEEX DLGTEMPLATEEX;
3095 #pragma pack(push, 4) 3096 struct DLGITEMTEMPLATEEX
3108 #endif // (_ATL_VER >= 0x800) 3116 CTRL_BUTTON = 0x0080,
3118 CTRL_STATIC = 0x0082,
3119 CTRL_LISTBOX = 0x0083,
3120 CTRL_SCROLLBAR = 0x0084,
3121 CTRL_COMBOBOX = 0x0085
3124 CMemDlgTemplate() : m_hData(NULL), m_pData(NULL), m_pPtr(NULL), m_cAllocated(0)
3132 bool IsValid()
const 3134 return (m_pData != NULL);
3137 bool IsTemplateEx()
const 3139 return (IsValid() && ((DLGTEMPLATEEX*)m_pData)->signature == 0xFFFF);
3142 LPDLGTEMPLATE GetTemplatePtr()
3144 return reinterpret_cast<LPDLGTEMPLATE
>(m_pData);
3147 DLGTEMPLATEEX* GetTemplateExPtr()
3149 return reinterpret_cast<DLGTEMPLATEEX*
>(m_pData);
3156 ::GlobalUnlock(m_pData);
3158 ATLVERIFY(::GlobalFree(m_hData) == NULL);
3167 void Create(
bool bDlgEx, LPCTSTR lpszCaption, RECT rc, DWORD dwStyle = 0, DWORD dwExStyle = 0,
3168 LPCTSTR lpstrFontName = NULL, WORD wFontSize = 0, WORD wWeight = 0, BYTE bItalic = 0, BYTE bCharset = 0, DWORD dwHelpID = 0,
3171 Create(bDlgEx, lpszCaption, (
short) rc.left, (
short) rc.top, (
short) (rc.right - rc.left), (
short) (rc.bottom - rc.top), dwStyle, dwExStyle,
3172 lpstrFontName, wFontSize, wWeight, bItalic, bCharset, dwHelpID, ClassName.m_lpstr, Menu.m_lpstr);
3175 void Create(
bool bDlgEx, LPCTSTR lpszCaption,
short nX,
short nY,
short nWidth,
short nHeight, DWORD dwStyle = 0, DWORD dwExStyle = 0,
3176 LPCTSTR lpstrFontName = NULL, WORD wFontSize = 0, WORD wWeight = 0, BYTE bItalic = 0, BYTE bCharset = 0, DWORD dwHelpID = 0,
3180 if (lpstrFontName != NULL)
3182 dwStyle |= DS_SETFONT;
3186 dwStyle &= ~DS_SETFONT;
3191 DLGTEMPLATEEX dlg = {1, 0xFFFF, dwHelpID, dwExStyle, dwStyle, 0, nX, nY, nWidth, nHeight};
3192 AddData(&dlg,
sizeof(dlg));
3196 DLGTEMPLATE dlg = {dwStyle, dwExStyle, 0, nX, nY, nWidth, nHeight};
3197 AddData(&dlg,
sizeof(dlg));
3201 if (Menu.m_lpstr == NULL)
3204 AddData(&menuData,
sizeof(WORD));
3206 else if (IS_INTRESOURCE(Menu.m_lpstr))
3208 WORD menuData[] = {0xFFFF, (WORD)Menu.m_lpstr};
3209 AddData(menuData,
sizeof(menuData));
3213 AddString(Menu.m_lpstr);
3217 ATLASSERT(Menu.m_lpstr == NULL);
3220 AddData(&menuData,
sizeof(WORD));
3221 #endif // _WIN32_WCE 3223 if (ClassName.m_lpstr == NULL)
3226 AddData(&classData,
sizeof(WORD));
3228 else if (IS_INTRESOURCE(ClassName.m_lpstr))
3230 WORD classData[] = {0xFFFF, (WORD)ClassName.m_lpstr};
3231 AddData(classData,
sizeof(classData));
3235 AddString(ClassName.m_lpstr);
3239 AddString(lpszCaption);
3241 if (lpstrFontName != NULL)
3243 AddData(&wFontSize,
sizeof(wFontSize));
3247 AddData(&wWeight,
sizeof(wWeight));
3248 AddData(&bItalic,
sizeof(bItalic));
3249 AddData(&bCharset,
sizeof(bCharset));
3252 AddString(lpstrFontName);
3256 void AddControl(
ATL::_U_STRINGorID ClassName, WORD wId, RECT rc, DWORD dwStyle, DWORD dwExStyle,
3257 ATL::_U_STRINGorID Text,
const WORD* pCreationData = NULL, WORD nCreationData = 0, DWORD dwHelpID = 0)
3259 AddControl(ClassName.m_lpstr, wId, (
short) rc.left, (
short) rc.top, (
short) (rc.right - rc.left), (
short) (rc.bottom - rc.top), dwStyle, dwExStyle,
3260 Text.m_lpstr, pCreationData, nCreationData, dwHelpID);
3263 void AddControl(
ATL::_U_STRINGorID ClassName, WORD wId,
short nX,
short nY,
short nWidth,
short nHeight, DWORD dwStyle, DWORD dwExStyle,
3264 ATL::_U_STRINGorID Text,
const WORD* pCreationData = NULL, WORD nCreationData = 0, DWORD dwHelpID = 0)
3266 ATLASSERT(IsValid());
3269 m_pPtr = (LPBYTE)(DWORD_PTR)((DWORD)(DWORD_PTR)(m_pPtr + 3) & (~3));
3273 DLGTEMPLATEEX* dlg = (DLGTEMPLATEEX*)m_pData;
3276 DLGITEMTEMPLATEEX item = {dwHelpID, ATL::CControlWinTraits::GetWndExStyle(0) | dwExStyle, ATL::CControlWinTraits::GetWndStyle(0) | dwStyle, nX, nY, nWidth, nHeight, wId};
3277 AddData(&item,
sizeof(item));
3281 LPDLGTEMPLATE dlg = (LPDLGTEMPLATE)m_pData;
3284 DLGITEMTEMPLATE item = {ATL::CControlWinTraits::GetWndStyle(0) | dwStyle, ATL::CControlWinTraits::GetWndExStyle(0) | dwExStyle, nX, nY, nWidth, nHeight, wId};
3285 AddData(&item,
sizeof(item));
3288 ATLASSERT(ClassName.m_lpstr != NULL);
3289 if (IS_INTRESOURCE(ClassName.m_lpstr))
3291 WORD wData[] = {0xFFFF, (WORD)ClassName.m_lpstr};
3292 AddData(wData,
sizeof(wData));
3296 AddString(ClassName.m_lpstr);
3299 if (Text.m_lpstr == NULL)
3302 AddData(&classData,
sizeof(WORD));
3304 else if (IS_INTRESOURCE(Text.m_lpstr))
3306 WORD wData[] = {0xFFFF, (WORD)Text.m_lpstr};
3307 AddData(wData,
sizeof(wData));
3311 AddString(Text.m_lpstr);
3314 AddData(&nCreationData,
sizeof(nCreationData));
3316 if ((nCreationData != 0))
3318 ATLASSERT(pCreationData != NULL);
3319 AddData(pCreationData, nCreationData *
sizeof(WORD));
3323 void AddStdControl(StdCtrlType CtrlType, WORD wId,
short nX,
short nY,
short nWidth,
short nHeight,
3324 DWORD dwStyle, DWORD dwExStyle,
ATL::_U_STRINGorID Text,
const WORD* pCreationData = NULL, WORD nCreationData = 0, DWORD dwHelpID = 0)
3326 AddControl(CtrlType, wId, nX, nY, nWidth, nHeight, dwStyle, dwExStyle, Text, pCreationData, nCreationData, dwHelpID);
3329 void AddData(LPCVOID pData,
size_t nData)
3331 ATLASSERT(pData != NULL);
3333 const SIZE_T ALLOCATION_INCREMENT = 1024;
3335 if (m_pData == NULL)
3337 m_cAllocated = ((nData / ALLOCATION_INCREMENT) + 1) * ALLOCATION_INCREMENT;
3338 m_hData = ::GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, m_cAllocated);
3339 ATLASSERT(m_hData != NULL);
3341 m_pPtr = m_pData =
static_cast<LPBYTE
>(::GlobalLock(m_hData));
3343 m_pPtr = m_pData =
static_cast<LPBYTE
>(m_hData);
3345 ATLASSERT(m_pData != NULL);
3347 else if (((m_pPtr - m_pData) + nData) > m_cAllocated)
3349 SIZE_T ptrPos = (m_pPtr - m_pData);
3350 m_cAllocated += ((nData / ALLOCATION_INCREMENT) + 1) * ALLOCATION_INCREMENT;
3352 ::GlobalUnlock(m_pData);
3354 m_hData = ::GlobalReAlloc(m_hData, m_cAllocated, GMEM_MOVEABLE | GMEM_ZEROINIT);
3355 ATLASSERT(m_hData != NULL);
3357 m_pData =
static_cast<LPBYTE
>(::GlobalLock(m_hData));
3359 m_pData =
static_cast<LPBYTE
>(m_hData);
3361 ATLASSERT(m_pData != NULL);
3362 m_pPtr = m_pData + ptrPos;
3365 SecureHelper::memcpy_x(m_pPtr, m_cAllocated - (m_pPtr - m_pData), pData, nData);
3370 void AddString(LPCTSTR lpszStr)
3372 if (lpszStr == NULL)
3375 AddData(&szEmpty,
sizeof(szEmpty));
3380 LPCWSTR lpstr = T2CW(lpszStr);
3381 int nSize = lstrlenW(lpstr) + 1;
3382 AddData(lpstr, nSize *
sizeof(WCHAR));
3389 SIZE_T m_cAllocated;
3397 #define BEGIN_DIALOG(x, y, width, height) \ 3398 void DoInitTemplate() \ 3400 bool bExTemplate = false; \ 3401 short nX = x, nY = y, nWidth = width, nHeight = height; \ 3402 LPCTSTR szCaption = NULL; \ 3403 DWORD dwStyle = WS_POPUP | WS_BORDER | WS_SYSMENU; \ 3404 DWORD dwExStyle = 0; \ 3405 LPCTSTR szFontName = NULL; \ 3406 WORD wFontSize = 0; \ 3409 BYTE bCharset = 0; \ 3410 DWORD dwHelpID = 0; \ 3411 ATL::_U_STRINGorID Menu = 0U; \ 3412 ATL::_U_STRINGorID ClassName = 0U; 3415 #define BEGIN_DIALOG_EX(x, y, width, height, helpID) \ 3416 void DoInitTemplate() \ 3418 bool bExTemplate = true; \ 3419 short nX = x, nY = y, nWidth = width, nHeight = height; \ 3420 LPCTSTR szCaption = NULL; \ 3421 DWORD dwStyle = WS_POPUP | WS_BORDER | WS_SYSMENU; \ 3422 DWORD dwExStyle = 0; \ 3423 LPCTSTR szFontName = NULL; \ 3424 WORD wFontSize = 0; \ 3427 BYTE bCharset = 0; \ 3428 DWORD dwHelpID = helpID; \ 3429 ATL::_U_STRINGorID Menu = 0U; \ 3430 ATL::_U_STRINGorID ClassName = 0U; 3432 #define END_DIALOG() \ 3433 m_Template.Create(bExTemplate, szCaption, nX, nY, nWidth, nHeight, dwStyle, dwExStyle, szFontName, wFontSize, wWeight, bItalic, bCharset, dwHelpID, ClassName, Menu); \ 3436 #define DIALOG_CAPTION(caption) \ 3437 szCaption = caption; 3438 #define DIALOG_STYLE(style) \ 3440 #define DIALOG_EXSTYLE(exStyle) \ 3441 dwExStyle = exStyle; 3442 #define DIALOG_FONT(pointSize, typeFace) \ 3443 wFontSize = pointSize; \ 3444 szFontName = typeFace; 3445 #define DIALOG_FONT_EX(pointsize, typeface, weight, italic, charset) \ 3446 ATLASSERT(bExTemplate); \ 3447 wFontSize = pointsize; \ 3448 szFontName = typeface; \ 3452 #define DIALOG_MENU(menuName) \ 3454 #define DIALOG_CLASS(className) \ 3455 ClassName = className; 3457 #define BEGIN_CONTROLS_MAP() \ 3458 void DoInitControls() \ 3461 #define END_CONTROLS_MAP() \ 3465 #define CONTROL_LTEXT(text, id, x, y, width, height, style, exStyle) \ 3466 m_Template.AddStdControl(WTL::CMemDlgTemplate::CTRL_STATIC, (WORD)id, x, y, width, height, style | SS_LEFT | WS_GROUP, exStyle, text, NULL, 0); 3467 #define CONTROL_CTEXT(text, id, x, y, width, height, style, exStyle) \ 3468 m_Template.AddStdControl(WTL::CMemDlgTemplate::CTRL_STATIC, (WORD)id, x, y, width, height, style | SS_CENTER | WS_GROUP, exStyle, text, NULL, 0); 3469 #define CONTROL_RTEXT(text, id, x, y, width, height, style, exStyle) \ 3470 m_Template.AddStdControl(WTL::CMemDlgTemplate::CTRL_STATIC, (WORD)id, x, y, width, height, style | SS_RIGHT | WS_GROUP, exStyle, text, NULL, 0); 3471 #define CONTROL_PUSHBUTTON(text, id, x, y, width, height, style, exStyle) \ 3472 m_Template.AddStdControl(WTL::CMemDlgTemplate::CTRL_BUTTON, (WORD)id, x, y, width, height, style | BS_PUSHBUTTON | WS_TABSTOP, exStyle, text, NULL, 0); 3473 #define CONTROL_DEFPUSHBUTTON(text, id, x, y, width, height, style, exStyle) \ 3474 m_Template.AddStdControl(WTL::CMemDlgTemplate::CTRL_BUTTON, (WORD)id, x, y, width, height, style | BS_DEFPUSHBUTTON | WS_TABSTOP, exStyle, text, NULL, 0); 3476 #define CONTROL_PUSHBOX(text, id, x, y, width, height, style, exStyle) \ 3477 m_Template.AddStdControl(WTL::CMemDlgTemplate::CTRL_BUTTON, (WORD)id, x, y, width, height, style | BS_PUSHBOX | WS_TABSTOP, exStyle, text, NULL, 0); 3478 #endif // !_WIN32_WCE 3479 #define CONTROL_STATE3(text, id, x, y, width, height, style, exStyle) \ 3480 m_Template.AddStdControl(WTL::CMemDlgTemplate::CTRL_BUTTON, (WORD)id, x, y, width, height, style | BS_3STATE | WS_TABSTOP, exStyle, text, NULL, 0); 3481 #define CONTROL_AUTO3STATE(text, id, x, y, width, height, style, exStyle) \ 3482 m_Template.AddStdControl(WTL::CMemDlgTemplate::CTRL_BUTTON, (WORD)id, x, y, width, height, style | BS_AUTO3STATE | WS_TABSTOP, exStyle, text, NULL, 0); 3483 #define CONTROL_CHECKBOX(text, id, x, y, width, height, style, exStyle) \ 3484 m_Template.AddStdControl(WTL::CMemDlgTemplate::CTRL_BUTTON, (WORD)id, x, y, width, height, style | BS_CHECKBOX | WS_TABSTOP, exStyle, text, NULL, 0); 3485 #define CONTROL_AUTOCHECKBOX(text, id, x, y, width, height, style, exStyle) \ 3486 m_Template.AddStdControl(WTL::CMemDlgTemplate::CTRL_BUTTON, (WORD)id, x, y, width, height, style | BS_AUTOCHECKBOX | WS_TABSTOP, exStyle, text, NULL, 0); 3487 #define CONTROL_RADIOBUTTON(text, id, x, y, width, height, style, exStyle) \ 3488 m_Template.AddStdControl(WTL::CMemDlgTemplate::CTRL_BUTTON, (WORD)id, x, y, width, height, style | BS_RADIOBUTTON | WS_TABSTOP, exStyle, text, NULL, 0); 3489 #define CONTROL_AUTORADIOBUTTON(text, id, x, y, width, height, style, exStyle) \ 3490 m_Template.AddStdControl(WTL::CMemDlgTemplate::CTRL_BUTTON, (WORD)id, x, y, width, height, style | BS_AUTORADIOBUTTON | WS_TABSTOP, exStyle, text, NULL, 0); 3491 #define CONTROL_COMBOBOX(id, x, y, width, height, style, exStyle) \ 3492 m_Template.AddStdControl(WTL::CMemDlgTemplate::CTRL_COMBOBOX, (WORD)id, x, y, width, height, style | CBS_DROPDOWN | WS_TABSTOP, exStyle, (LPCTSTR)NULL, NULL, 0); 3493 #define CONTROL_EDITTEXT(id, x, y, width, height, style, exStyle) \ 3494 m_Template.AddStdControl(WTL::CMemDlgTemplate::CTRL_EDIT, (WORD)id, x, y, width, height, style | ES_LEFT | WS_BORDER | WS_TABSTOP, exStyle, (LPCTSTR)NULL, NULL, 0); 3495 #define CONTROL_GROUPBOX(text, id, x, y, width, height, style, exStyle) \ 3496 m_Template.AddStdControl(WTL::CMemDlgTemplate::CTRL_BUTTON, (WORD)id, x, y, width, height, style | BS_GROUPBOX, exStyle, text, NULL, 0); 3497 #define CONTROL_LISTBOX(id, x, y, width, height, style, exStyle) \ 3498 m_Template.AddStdControl(WTL::CMemDlgTemplate::CTRL_LISTBOX, (WORD)id, x, y, width, height, style | LBS_NOTIFY | WS_BORDER, exStyle, (LPCTSTR)NULL, NULL, 0); 3499 #define CONTROL_SCROLLBAR(id, x, y, width, height, style, exStyle) \ 3500 m_Template.AddStdControl(WTL::CMemDlgTemplate::CTRL_SCROLLBAR, (WORD)id, x, y, width, height, style | SBS_HORZ, exStyle, (LPCTSTR)NULL, NULL, 0); 3501 #define CONTROL_ICON(text, id, x, y, width, height, style, exStyle) \ 3502 m_Template.AddStdControl(WTL::CMemDlgTemplate::CTRL_STATIC, (WORD)id, x, y, width, height, style | SS_ICON, exStyle, text, NULL, 0); 3503 #define CONTROL_CONTROL(text, id, className, style, x, y, width, height, exStyle) \ 3504 m_Template.AddControl(className, (WORD)id, x, y, width, height, style, exStyle, text, NULL, 0); 3510 template <
class T,
class TDlgTemplate = CMemDlgTemplate,
class TBase = ATL::CDialogImpl<T, ATL::CWindow> >
3516 TDlgTemplate m_Template;
3518 void CreateTemplate()
3520 T* pT =
static_cast<T*
>(
this);
3521 pT->DoInitTemplate();
3522 pT->DoInitControls();
3525 INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow(), LPARAM dwInitParam = NULL)
3527 T* pT =
static_cast<T*
>(
this);
3528 ATLASSERT(pT->m_hWnd == NULL);
3530 if (!m_Template.IsValid())
3533 #if (_ATL_VER >= 0x0800) 3535 BOOL result = m_thunk.Init(NULL, NULL);
3536 if (result == FALSE)
3538 SetLastError(ERROR_OUTOFMEMORY);
3541 #endif // (_ATL_VER >= 0x0800) 3543 ModuleHelper::AddCreateWndData(&m_thunk.cd, pT);
3549 return ::DialogBoxIndirectParam(ModuleHelper::GetResourceInstance(), m_Template.GetTemplatePtr(), hWndParent, (DLGPROC)T::StartDialogProc, dwInitParam);
3552 HWND Create(HWND hWndParent, LPARAM dwInitParam = NULL)
3554 T* pT =
static_cast<T*
>(
this);
3555 ATLASSERT(pT->m_hWnd == NULL);
3557 if (!m_Template.IsValid())
3560 #if (_ATL_VER >= 0x0800) 3562 BOOL result = m_thunk.Init(NULL, NULL);
3563 if (result == FALSE)
3565 SetLastError(ERROR_OUTOFMEMORY);
3568 #endif // (_ATL_VER >= 0x0800) 3570 ModuleHelper::AddCreateWndData(&m_thunk.cd, pT);
3576 HWND hWnd = ::CreateDialogIndirectParam(ModuleHelper::GetResourceInstance(), (LPCDLGTEMPLATE)m_Template.GetTemplatePtr(), hWndParent, (DLGPROC)T::StartDialogProc, dwInitParam);
3577 ATLASSERT(m_hWnd == hWnd);
3583 HWND Create(HWND hWndParent, RECT&, LPARAM dwInitParam = NULL)
3585 return Create(hWndParent, dwInitParam);
3588 void DoInitTemplate()
3593 void DoInitControls()
3616 int GetPageCount()
const 3618 ATLASSERT(::IsWindow(m_hWnd));
3619 HWND hWndTabCtrl = GetTabControl();
3620 ATLASSERT(hWndTabCtrl != NULL);
3621 return (
int)::SendMessage(hWndTabCtrl, TCM_GETITEMCOUNT, 0, 0L);
3624 HWND GetActivePage()
const 3626 ATLASSERT(::IsWindow(m_hWnd));
3627 return (HWND)::SendMessage(m_hWnd, PSM_GETCURRENTPAGEHWND, 0, 0L);
3630 int GetActiveIndex()
const 3632 ATLASSERT(::IsWindow(m_hWnd));
3633 HWND hWndTabCtrl = GetTabControl();
3634 ATLASSERT(hWndTabCtrl != NULL);
3635 return (
int)::SendMessage(hWndTabCtrl, TCM_GETCURSEL, 0, 0L);
3638 BOOL SetActivePage(
int nPageIndex)
3640 ATLASSERT(::IsWindow(m_hWnd));
3641 return (BOOL)::SendMessage(m_hWnd, PSM_SETCURSEL, nPageIndex, 0L);
3644 BOOL SetActivePage(HPROPSHEETPAGE hPage)
3646 ATLASSERT(::IsWindow(m_hWnd));
3647 ATLASSERT(hPage != NULL);
3648 return (BOOL)::SendMessage(m_hWnd, PSM_SETCURSEL, 0, (LPARAM)hPage);
3651 BOOL SetActivePageByID(
int nPageID)
3653 ATLASSERT(::IsWindow(m_hWnd));
3654 return (BOOL)::SendMessage(m_hWnd, PSM_SETCURSELID, 0, nPageID);
3657 void SetTitle(LPCTSTR lpszText, UINT nStyle = 0)
3659 ATLASSERT(::IsWindow(m_hWnd));
3660 ATLASSERT((nStyle & ~PSH_PROPTITLE) == 0);
3661 ATLASSERT(lpszText != NULL);
3662 ::SendMessage(m_hWnd, PSM_SETTITLE, nStyle, (LPARAM)lpszText);
3665 HWND GetTabControl()
const 3667 ATLASSERT(::IsWindow(m_hWnd));
3668 return (HWND)::SendMessage(m_hWnd, PSM_GETTABCONTROL, 0, 0L);
3671 void SetFinishText(LPCTSTR lpszText)
3673 ATLASSERT(::IsWindow(m_hWnd));
3674 ::SendMessage(m_hWnd, PSM_SETFINISHTEXT, 0, (LPARAM)lpszText);
3677 void SetWizardButtons(DWORD dwFlags)
3679 ATLASSERT(::IsWindow(m_hWnd));
3680 ::PostMessage(m_hWnd, PSM_SETWIZBUTTONS, 0, dwFlags);
3684 BOOL AddPage(HPROPSHEETPAGE hPage)
3686 ATLASSERT(::IsWindow(m_hWnd));
3687 ATLASSERT(hPage != NULL);
3688 return (BOOL)::SendMessage(m_hWnd, PSM_ADDPAGE, 0, (LPARAM)hPage);
3691 BOOL AddPage(LPCPROPSHEETPAGE pPage)
3693 ATLASSERT(::IsWindow(m_hWnd));
3694 ATLASSERT(pPage != NULL);
3695 HPROPSHEETPAGE hPage = ::CreatePropertySheetPage(pPage);
3698 return (BOOL)::SendMessage(m_hWnd, PSM_ADDPAGE, 0, (LPARAM)hPage);
3702 BOOL InsertPage(
int nNewPageIndex, HPROPSHEETPAGE hPage)
3704 ATLASSERT(::IsWindow(m_hWnd));
3705 ATLASSERT(hPage != NULL);
3706 return (BOOL)::SendMessage(m_hWnd, PSM_INSERTPAGE, nNewPageIndex, (LPARAM)hPage);
3709 BOOL InsertPage(
int nNewPageIndex, LPCPROPSHEETPAGE pPage)
3711 ATLASSERT(::IsWindow(m_hWnd));
3712 ATLASSERT(pPage != NULL);
3713 HPROPSHEETPAGE hPage = ::CreatePropertySheetPage(pPage);
3716 return (BOOL)::SendMessage(m_hWnd, PSM_INSERTPAGE, nNewPageIndex, (LPARAM)hPage);
3719 BOOL InsertPage(HPROPSHEETPAGE hPageInsertAfter, HPROPSHEETPAGE hPage)
3721 ATLASSERT(::IsWindow(m_hWnd));
3722 ATLASSERT(hPage != NULL);
3723 return (BOOL)::SendMessage(m_hWnd, PSM_INSERTPAGE, (WPARAM)hPageInsertAfter, (LPARAM)hPage);
3726 BOOL InsertPage(HPROPSHEETPAGE hPageInsertAfter, LPCPROPSHEETPAGE pPage)
3728 ATLASSERT(::IsWindow(m_hWnd));
3729 ATLASSERT(pPage != NULL);
3730 HPROPSHEETPAGE hPage = ::CreatePropertySheetPage(pPage);
3733 return (BOOL)::SendMessage(m_hWnd, PSM_INSERTPAGE, (WPARAM)hPageInsertAfter, (LPARAM)hPage);
3735 #endif // !_WIN32_WCE 3737 void RemovePage(
int nPageIndex)
3739 ATLASSERT(::IsWindow(m_hWnd));
3740 ::SendMessage(m_hWnd, PSM_REMOVEPAGE, nPageIndex, 0L);
3743 void RemovePage(HPROPSHEETPAGE hPage)
3745 ATLASSERT(::IsWindow(m_hWnd));
3746 ATLASSERT(hPage != NULL);
3747 ::SendMessage(m_hWnd, PSM_REMOVEPAGE, 0, (LPARAM)hPage);
3750 BOOL PressButton(
int nButton)
3752 ATLASSERT(::IsWindow(m_hWnd));
3753 return (BOOL)::SendMessage(m_hWnd, PSM_PRESSBUTTON, nButton, 0L);
3758 ATLASSERT(::IsWindow(m_hWnd));
3759 return (BOOL)::SendMessage(m_hWnd, PSM_APPLY, 0, 0L);
3762 void CancelToClose()
3764 ATLASSERT(::IsWindow(m_hWnd));
3765 ::SendMessage(m_hWnd, PSM_CANCELTOCLOSE, 0, 0L);
3768 void SetModified(HWND hWndPage, BOOL bChanged = TRUE)
3770 ATLASSERT(::IsWindow(m_hWnd));
3771 ATLASSERT(::IsWindow(hWndPage));
3772 UINT uMsg = bChanged ? PSM_CHANGED : PSM_UNCHANGED;
3773 ::SendMessage(m_hWnd, uMsg, (WPARAM)hWndPage, 0L);
3776 LRESULT QuerySiblings(WPARAM wParam, LPARAM lParam)
3778 ATLASSERT(::IsWindow(m_hWnd));
3779 return ::SendMessage(m_hWnd, PSM_QUERYSIBLINGS, wParam, lParam);
3784 ATLASSERT(::IsWindow(m_hWnd));
3785 ::SendMessage(m_hWnd, PSM_REBOOTSYSTEM, 0, 0L);
3788 void RestartWindows()
3790 ATLASSERT(::IsWindow(m_hWnd));
3791 ::SendMessage(m_hWnd, PSM_RESTARTWINDOWS, 0, 0L);
3794 BOOL IsDialogMessage(LPMSG lpMsg)
3796 ATLASSERT(::IsWindow(m_hWnd));
3797 return (BOOL)::SendMessage(m_hWnd, PSM_ISDIALOGMESSAGE, 0, (LPARAM)lpMsg);
3800 #if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) 3801 int HwndToIndex(HWND hWnd)
const 3803 ATLASSERT(::IsWindow(m_hWnd));
3804 return (
int)::SendMessage(m_hWnd, PSM_HWNDTOINDEX, (WPARAM)hWnd, 0L);
3807 HWND IndexToHwnd(
int nIndex)
const 3809 ATLASSERT(::IsWindow(m_hWnd));
3810 return (HWND)::SendMessage(m_hWnd, PSM_INDEXTOHWND, nIndex, 0L);
3813 int PageToIndex(HPROPSHEETPAGE hPage)
const 3815 ATLASSERT(::IsWindow(m_hWnd));
3816 return (
int)::SendMessage(m_hWnd, PSM_PAGETOINDEX, 0, (LPARAM)hPage);
3819 HPROPSHEETPAGE IndexToPage(
int nIndex)
const 3821 ATLASSERT(::IsWindow(m_hWnd));
3822 return (HPROPSHEETPAGE)::SendMessage(m_hWnd, PSM_INDEXTOPAGE, nIndex, 0L);
3825 int IdToIndex(
int nID)
const 3827 ATLASSERT(::IsWindow(m_hWnd));
3828 return (
int)::SendMessage(m_hWnd, PSM_IDTOINDEX, 0, nID);
3831 int IndexToId(
int nIndex)
const 3833 ATLASSERT(::IsWindow(m_hWnd));
3834 return (
int)::SendMessage(m_hWnd, PSM_INDEXTOID, nIndex, 0L);
3837 int GetResult()
const 3839 ATLASSERT(::IsWindow(m_hWnd));
3840 return (
int)::SendMessage(m_hWnd, PSM_GETRESULT, 0, 0L);
3843 BOOL RecalcPageSizes()
3845 ATLASSERT(::IsWindow(m_hWnd));
3846 return (BOOL)::SendMessage(m_hWnd, PSM_RECALCPAGESIZES, 0, 0L);
3849 void SetHeaderTitle(
int nIndex, LPCTSTR lpstrHeaderTitle)
3851 ATLASSERT(::IsWindow(m_hWnd));
3852 ::SendMessage(m_hWnd, PSM_SETHEADERTITLE, nIndex, (LPARAM)lpstrHeaderTitle);
3855 void SetHeaderSubTitle(
int nIndex, LPCTSTR lpstrHeaderSubTitle)
3857 ATLASSERT(::IsWindow(m_hWnd));
3858 ::SendMessage(m_hWnd, PSM_SETHEADERSUBTITLE, nIndex, (LPARAM)lpstrHeaderSubTitle);
3860 #endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) 3873 template <
class T,
class TBase = CPropertySheetWindow>
3877 PROPSHEETHEADER m_psh;
3878 ATL::CSimpleArray<HPROPSHEETPAGE> m_arrPages;
3880 #if defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) // PPC specific 3881 #ifndef PROPSHEET_LINK_SIZE 3882 #define PROPSHEET_LINK_SIZE 128 3883 #endif // PROPSHEET_LINK_SIZE 3884 TCHAR m_szLink[PROPSHEET_LINK_SIZE];
3885 static LPCTSTR m_pszTitle;
3886 static LPCTSTR m_pszLink;
3887 #endif // defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) 3892 memset(&m_psh, 0,
sizeof(PROPSHEETHEADER));
3893 m_psh.dwSize =
sizeof(PROPSHEETHEADER);
3894 m_psh.dwFlags = PSH_USECALLBACK;
3895 m_psh.hInstance = ModuleHelper::GetResourceInstance();
3896 m_psh.phpage = NULL;
3898 m_psh.pszCaption = title.m_lpstr;
3899 m_psh.nStartPage = uStartPage;
3900 m_psh.hwndParent = hWndParent;
3901 m_psh.pfnCallback = T::PropSheetCallback;
3903 #if defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) // PPC specific 3904 m_psh.dwFlags |= PSH_MAXIMIZE;
3906 #endif // defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) 3911 if(m_arrPages.GetSize() > 0)
3913 for(
int i = 0; i < m_arrPages.GetSize(); i++)
3914 ::DestroyPropertySheetPage((HPROPSHEETPAGE)m_arrPages[i]);
3919 static int CALLBACK PropSheetCallback(HWND hWnd, UINT uMsg, LPARAM lParam)
3924 if(uMsg == PSCB_INITIALIZED)
3926 ATLASSERT(hWnd != NULL);
3927 T* pT = (T*)ModuleHelper::ExtractCreateWndData();
3929 pT->SubclassWindow(hWnd);
3931 pT->_CleanUpPages();
3933 #if defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) // PPC specific 3934 m_pszTitle = pT->m_psh.pszCaption;
3935 if(*pT->m_szLink != 0)
3936 m_pszLink = pT->m_szLink;
3937 #endif // defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) // PPC specific 3939 pT->OnSheetInitialized();
3941 #if defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) // PPC specific uMsg 3946 case PSCB_GETVERSION :
3947 nRet = COMCTL32_VERSION;
3949 case PSCB_GETTITLE :
3950 if(m_pszTitle != NULL)
3952 lstrcpy((LPTSTR)lParam, m_pszTitle);
3956 case PSCB_GETLINKTEXT:
3957 if(m_pszLink != NULL)
3959 lstrcpy((LPTSTR)lParam, m_pszLink);
3967 #endif // defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) 3972 void OnSheetInitialized()
3977 HWND Create(HWND hWndParent = NULL)
3979 ATLASSERT(m_hWnd == NULL);
3981 m_psh.dwFlags |= PSH_MODELESS;
3982 if(m_psh.hwndParent == NULL)
3983 m_psh.hwndParent = hWndParent;
3984 m_psh.phpage = (HPROPSHEETPAGE*)m_arrPages.GetData();
3985 m_psh.nPages = m_arrPages.GetSize();
3987 T* pT =
static_cast<T*
>(
this);
3988 ModuleHelper::AddCreateWndData(&pT->m_thunk.cd, pT);
3990 HWND hWnd = (HWND)::PropertySheet(&m_psh);
3993 ATLASSERT(m_hWnd == hWnd);
3998 INT_PTR DoModal(HWND hWndParent = ::GetActiveWindow())
4000 ATLASSERT(m_hWnd == NULL);
4002 m_psh.dwFlags &= ~PSH_MODELESS;
4003 if(m_psh.hwndParent == NULL)
4004 m_psh.hwndParent = hWndParent;
4005 m_psh.phpage = (HPROPSHEETPAGE*)m_arrPages.GetData();
4006 m_psh.nPages = m_arrPages.GetSize();
4008 T* pT =
static_cast<T*
>(
this);
4009 ModuleHelper::AddCreateWndData(&pT->m_thunk.cd, pT);
4011 INT_PTR nRet = ::PropertySheet(&m_psh);
4018 void _CleanUpPages()
4021 m_psh.phpage = NULL;
4022 m_arrPages.RemoveAll();
4028 int GetPageCount()
const 4031 return m_arrPages.GetSize();
4032 return TBase::GetPageCount();
4035 int GetActiveIndex()
const 4038 return m_psh.nStartPage;
4039 return TBase::GetActiveIndex();
4042 HPROPSHEETPAGE GetPage(
int nPageIndex)
const 4044 ATLASSERT(m_hWnd == NULL);
4045 return (HPROPSHEETPAGE)m_arrPages[nPageIndex];
4048 int GetPageIndex(HPROPSHEETPAGE hPage)
const 4050 ATLASSERT(m_hWnd == NULL);
4051 return m_arrPages.Find((HPROPSHEETPAGE&)hPage);
4054 BOOL SetActivePage(
int nPageIndex)
4058 ATLASSERT(nPageIndex >= 0 && nPageIndex < m_arrPages.GetSize());
4059 m_psh.nStartPage = nPageIndex;
4062 return TBase::SetActivePage(nPageIndex);
4065 BOOL SetActivePage(HPROPSHEETPAGE hPage)
4067 ATLASSERT(hPage != NULL);
4070 int nPageIndex = GetPageIndex(hPage);
4071 if(nPageIndex == -1)
4074 return SetActivePage(nPageIndex);
4076 return TBase::SetActivePage(hPage);
4080 void SetTitle(LPCTSTR lpszText, UINT nStyle = 0)
4082 ATLASSERT((nStyle & ~PSH_PROPTITLE) == 0);
4083 ATLASSERT(lpszText != NULL);
4088 m_psh.pszCaption = lpszText;
4089 m_psh.dwFlags &= ~PSH_PROPTITLE;
4090 m_psh.dwFlags |= nStyle;
4095 TBase::SetTitle(lpszText, nStyle);
4099 #if defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) // PPC specific Link field 4100 void SetLinkText(LPCTSTR lpszText)
4102 ATLASSERT(lpszText != NULL);
4103 ATLASSERT(lstrlen(lpszText) < PROPSHEET_LINK_SIZE);
4104 lstrcpy(m_szLink, lpszText);
4106 #endif // defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) 4108 void SetWizardMode()
4110 m_psh.dwFlags |= PSH_WIZARD;
4115 m_psh.dwFlags |= PSH_HASHELP;
4119 BOOL AddPage(HPROPSHEETPAGE hPage)
4121 ATLASSERT(hPage != NULL);
4124 bRet = TBase::AddPage(hPage);
4126 bRet = m_arrPages.Add((HPROPSHEETPAGE&)hPage);
4130 BOOL AddPage(LPCPROPSHEETPAGE pPage)
4132 ATLASSERT(pPage != NULL);
4133 HPROPSHEETPAGE hPage = ::CreatePropertySheetPage(pPage);
4136 BOOL bRet = AddPage(hPage);
4138 ::DestroyPropertySheetPage(hPage);
4142 BOOL RemovePage(HPROPSHEETPAGE hPage)
4144 ATLASSERT(hPage != NULL);
4147 int nPage = GetPageIndex(hPage);
4150 return RemovePage(nPage);
4152 TBase::RemovePage(hPage);
4157 BOOL RemovePage(
int nPageIndex)
4161 TBase::RemovePage(nPageIndex);
4163 bRet = m_arrPages.RemoveAt(nPageIndex);
4167 #if (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) 4168 void SetHeader(LPCTSTR szbmHeader)
4170 ATLASSERT(m_hWnd == NULL);
4172 m_psh.dwFlags &= ~PSH_WIZARD;
4173 m_psh.dwFlags |= (PSH_HEADER | PSH_WIZARD97);
4174 m_psh.pszbmHeader = szbmHeader;
4177 void SetHeader(HBITMAP hbmHeader)
4179 ATLASSERT(m_hWnd == NULL);
4181 m_psh.dwFlags &= ~PSH_WIZARD;
4182 m_psh.dwFlags |= (PSH_HEADER | PSH_USEHBMHEADER | PSH_WIZARD97);
4183 m_psh.hbmHeader = hbmHeader;
4186 void SetWatermark(LPCTSTR szbmWatermark, HPALETTE hplWatermark = NULL)
4188 ATLASSERT(m_hWnd == NULL);
4190 m_psh.dwFlags &= ~PSH_WIZARD;
4191 m_psh.dwFlags |= PSH_WATERMARK | PSH_WIZARD97;
4192 m_psh.pszbmWatermark = szbmWatermark;
4194 if (hplWatermark != NULL)
4196 m_psh.dwFlags |= PSH_USEHPLWATERMARK;
4197 m_psh.hplWatermark = hplWatermark;
4201 void SetWatermark(HBITMAP hbmWatermark, HPALETTE hplWatermark = NULL)
4203 ATLASSERT(m_hWnd == NULL);
4205 m_psh.dwFlags &= ~PSH_WIZARD;
4206 m_psh.dwFlags |= (PSH_WATERMARK | PSH_USEHBMWATERMARK | PSH_WIZARD97);
4207 m_psh.hbmWatermark = hbmWatermark;
4209 if (hplWatermark != NULL)
4211 m_psh.dwFlags |= PSH_USEHPLWATERMARK;
4212 m_psh.hplWatermark = hplWatermark;
4216 void StretchWatermark(
bool bStretchWatermark)
4218 ATLASSERT(m_hWnd == NULL);
4219 if (bStretchWatermark)
4220 m_psh.dwFlags |= PSH_STRETCHWATERMARK;
4222 m_psh.dwFlags &= ~PSH_STRETCHWATERMARK;
4224 #endif // (_WIN32_IE >= 0x0400) && !defined(_WIN32_WCE) 4228 MESSAGE_HANDLER(WM_COMMAND, OnCommand)
4229 MESSAGE_HANDLER(WM_SYSCOMMAND, OnSysCommand)
4232 LRESULT OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& )
4234 LRESULT lRet = DefWindowProc(uMsg, wParam, lParam);
4235 if(HIWORD(wParam) == BN_CLICKED && (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) &&
4236 ((m_psh.dwFlags & PSH_MODELESS) != 0) && (GetActivePage() == NULL))
4241 LRESULT OnSysCommand(UINT , WPARAM wParam, LPARAM , BOOL& bHandled)
4243 if(((m_psh.dwFlags & PSH_MODELESS) == PSH_MODELESS) && ((wParam & 0xFFF0) == SC_CLOSE))
4244 SendMessage(WM_CLOSE);
4251 #if defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) // PPC static pointers 4252 template <
class T,
class TBase >
4254 template <
class T,
class TBase>
4256 #endif // defined(_AYGSHELL_H_) || defined(__AYGSHELL_H__) 4287 ATLASSERT(::IsWindow(m_hWnd));
4294 ATLASSERT(::IsWindow(m_hWnd));
4295 ATLASSERT(GetParent() != NULL);
4296 return GetPropertySheet().Apply();
4299 void CancelToClose()
4301 ATLASSERT(::IsWindow(m_hWnd));
4302 ATLASSERT(GetParent() != NULL);
4303 GetPropertySheet().CancelToClose();
4306 void SetModified(BOOL bChanged = TRUE)
4308 ATLASSERT(::IsWindow(m_hWnd));
4309 ATLASSERT(GetParent() != NULL);
4310 GetPropertySheet().SetModified(m_hWnd, bChanged);
4313 LRESULT QuerySiblings(WPARAM wParam, LPARAM lParam)
4315 ATLASSERT(::IsWindow(m_hWnd));
4316 ATLASSERT(GetParent() != NULL);
4317 return GetPropertySheet().QuerySiblings(wParam, lParam);
4322 ATLASSERT(::IsWindow(m_hWnd));
4323 ATLASSERT(GetParent() != NULL);
4324 GetPropertySheet().RebootSystem();
4327 void RestartWindows()
4329 ATLASSERT(::IsWindow(m_hWnd));
4330 ATLASSERT(GetParent() != NULL);
4331 GetPropertySheet().RestartWindows();
4334 void SetWizardButtons(DWORD dwFlags)
4336 ATLASSERT(::IsWindow(m_hWnd));
4337 ATLASSERT(GetParent() != NULL);
4338 GetPropertySheet().SetWizardButtons(dwFlags);
4352 template <
class T,
class TBase = CPropertyPageWindow>
4356 PROPSHEETPAGE m_psp;
4358 operator PROPSHEETPAGE*() {
return &m_psp; }
4364 memset(&m_psp, 0,
sizeof(PROPSHEETPAGE));
4365 m_psp.dwSize =
sizeof(PROPSHEETPAGE);
4366 m_psp.dwFlags = PSP_USECALLBACK;
4367 m_psp.hInstance = ModuleHelper::GetResourceInstance();
4368 T* pT =
static_cast<T*
>(
this);
4369 m_psp.pszTemplate = MAKEINTRESOURCE(pT->IDD);
4370 m_psp.pfnDlgProc = (DLGPROC)T::StartDialogProc;
4371 m_psp.pfnCallback = T::PropPageCallback;
4372 m_psp.lParam = (LPARAM)pT;
4374 if(title.m_lpstr != NULL)
4379 static UINT CALLBACK PropPageCallback(HWND hWnd, UINT uMsg, LPPROPSHEETPAGE ppsp)
4382 ATLASSERT(hWnd == NULL);
4383 T* pT = (T*)ppsp->lParam;
4390 ATL::CDialogImplBaseT< TBase >* pPage = (ATL::CDialogImplBaseT< TBase >*)pT;
4391 ModuleHelper::AddCreateWndData(&pPage->m_thunk.cd, pPage);
4392 uRet = pT->OnPageCreate() ? 1 : 0;
4395 #if (_WIN32_IE >= 0x0500) 4399 #endif // (_WIN32_IE >= 0x0500) 4401 pT->OnPageRelease();
4415 #if (_WIN32_IE >= 0x0500) 4419 #endif // (_WIN32_IE >= 0x0500) 4421 void OnPageRelease()
4426 HPROPSHEETPAGE Create()
4428 return ::CreatePropertySheetPage(&m_psp);
4434 m_psp.pszTitle = title.m_lpstr;
4435 m_psp.dwFlags |= PSP_USETITLE;
4438 #if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) 4439 void SetHeaderTitle(LPCTSTR lpstrHeaderTitle)
4441 ATLASSERT(m_hWnd == NULL);
4442 m_psp.dwFlags |= PSP_USEHEADERTITLE;
4443 m_psp.pszHeaderTitle = lpstrHeaderTitle;
4446 void SetHeaderSubTitle(LPCTSTR lpstrHeaderSubTitle)
4448 ATLASSERT(m_hWnd == NULL);
4449 m_psp.dwFlags |= PSP_USEHEADERSUBTITLE;
4450 m_psp.pszHeaderSubTitle = lpstrHeaderSubTitle;
4452 #endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) 4457 m_psp.dwFlags |= PSP_HASHELP;
4462 MESSAGE_HANDLER(WM_NOTIFY, OnNotify)
4467 LRESULT OnNotify(UINT , WPARAM , LPARAM lParam, BOOL& bHandled)
4471 ATLASSERT(::IsWindow(m_hWnd));
4473 NMHDR* pNMHDR = (NMHDR*)lParam;
4476 if(pNMHDR->hwndFrom != m_hWnd && pNMHDR->hwndFrom != ::GetParent(m_hWnd))
4482 ATLASSERT(::IsWindow(m_hWnd));
4485 T* pT =
static_cast<T*
>(
this);
4486 LRESULT lResult = 0;
4487 switch(pNMHDR->code)
4489 #ifdef _WTL_NEW_PAGE_NOTIFY_HANDLERS 4491 lResult = pT->OnSetActive();
4493 case PSN_KILLACTIVE:
4494 lResult = pT->OnKillActive();
4497 lResult = pT->OnApply();
4502 case PSN_QUERYCANCEL:
4503 lResult = pT->OnQueryCancel();
4506 lResult = pT->OnWizardNext();
4509 lResult = pT->OnWizardBack();
4512 lResult = pT->OnWizardFinish();
4518 #if (_WIN32_IE >= 0x0400) 4520 if(!pT->OnGetObject((LPNMOBJECTNOTIFY)lParam))
4523 #endif // (_WIN32_IE >= 0x0400) 4524 #if (_WIN32_IE >= 0x0500) 4525 case PSN_TRANSLATEACCELERATOR:
4527 LPPSHNOTIFY lpPSHNotify = (LPPSHNOTIFY)lParam;
4528 lResult = pT->OnTranslateAccelerator((LPMSG)lpPSHNotify->lParam);
4531 case PSN_QUERYINITIALFOCUS:
4533 LPPSHNOTIFY lpPSHNotify = (LPPSHNOTIFY)lParam;
4534 lResult = (LRESULT)pT->OnQueryInitialFocus((HWND)lpPSHNotify->lParam);
4537 #endif // (_WIN32_IE >= 0x0500) 4538 #endif // !_WIN32_WCE 4540 #else // !_WTL_NEW_PAGE_NOTIFY_HANDLERS 4542 lResult = pT->OnSetActive() ? 0 : -1;
4544 case PSN_KILLACTIVE:
4545 lResult = !pT->OnKillActive();
4548 lResult = pT->OnApply() ? PSNRET_NOERROR : PSNRET_INVALID_NOCHANGEPAGE;
4553 case PSN_QUERYCANCEL:
4554 lResult = !pT->OnQueryCancel();
4557 lResult = pT->OnWizardNext();
4560 lResult = pT->OnWizardBack();
4563 lResult = !pT->OnWizardFinish();
4569 #if (_WIN32_IE >= 0x0400) 4571 if(!pT->OnGetObject((LPNMOBJECTNOTIFY)lParam))
4574 #endif // (_WIN32_IE >= 0x0400) 4575 #if (_WIN32_IE >= 0x0500) 4576 case PSN_TRANSLATEACCELERATOR:
4578 LPPSHNOTIFY lpPSHNotify = (LPPSHNOTIFY)lParam;
4579 lResult = pT->OnTranslateAccelerator((LPMSG)lpPSHNotify->lParam) ? PSNRET_MESSAGEHANDLED : PSNRET_NOERROR;
4582 case PSN_QUERYINITIALFOCUS:
4584 LPPSHNOTIFY lpPSHNotify = (LPPSHNOTIFY)lParam;
4585 lResult = (LRESULT)pT->OnQueryInitialFocus((HWND)lpPSHNotify->lParam);
4588 #endif // (_WIN32_IE >= 0x0500) 4589 #endif // !_WIN32_WCE 4591 #endif // !_WTL_NEW_PAGE_NOTIFY_HANDLERS 4602 #ifdef _WTL_NEW_PAGE_NOTIFY_HANDLERS 4623 return PSNRET_NOERROR;
4630 BOOL OnQueryCancel()
4653 INT_PTR OnWizardFinish()
4666 #if (_WIN32_IE >= 0x0400) 4667 BOOL OnGetObject(LPNMOBJECTNOTIFY )
4671 #endif // (_WIN32_IE >= 0x0400) 4673 #if (_WIN32_IE >= 0x0500) 4674 int OnTranslateAccelerator(LPMSG )
4678 return PSNRET_NOERROR;
4681 HWND OnQueryInitialFocus(HWND )
4687 #endif // (_WIN32_IE >= 0x0500) 4688 #endif // !_WIN32_WCE 4690 #else // !_WTL_NEW_PAGE_NOTIFY_HANDLERS 4710 BOOL OnQueryCancel()
4731 BOOL OnWizardFinish()
4741 #if (_WIN32_IE >= 0x0400) 4742 BOOL OnGetObject(LPNMOBJECTNOTIFY )
4746 #endif // (_WIN32_IE >= 0x0400) 4748 #if (_WIN32_IE >= 0x0500) 4749 BOOL OnTranslateAccelerator(LPMSG )
4754 HWND OnQueryInitialFocus(HWND )
4758 #endif // (_WIN32_IE >= 0x0500) 4759 #endif // !_WIN32_WCE 4761 #endif // !_WTL_NEW_PAGE_NOTIFY_HANDLERS 4765 template <WORD t_wDlgTemplateID>
4769 enum { IDD = t_wDlgTemplateID };
4774 DECLARE_EMPTY_MSG_MAP()
4780 #ifndef _ATL_NO_HOSTING 4784 template <
class T,
class TBase = CPropertyPageWindow>
4789 HGLOBAL m_hInitData;
4791 HGLOBAL m_hDlgResSplit;
4796 m_hInitData(NULL), m_hDlgRes(NULL), m_hDlgResSplit(NULL)
4798 T* pT =
static_cast<T*
>(
this);
4802 ATL::AtlAxWinInit();
4804 HINSTANCE hInstance = ModuleHelper::GetResourceInstance();
4805 LPCTSTR lpTemplateName = MAKEINTRESOURCE(pT->IDD);
4806 HRSRC hDlg = ::FindResource(hInstance, lpTemplateName, (LPTSTR)RT_DIALOG);
4809 HRSRC hDlgInit = ::FindResource(hInstance, lpTemplateName, (LPTSTR)_ATL_RT_DLGINIT);
4811 BYTE* pInitData = NULL;
4812 if(hDlgInit != NULL)
4814 m_hInitData = ::LoadResource(hInstance, hDlgInit);
4815 pInitData = (BYTE*)::LockResource(m_hInitData);
4818 m_hDlgRes = ::LoadResource(hInstance, hDlg);
4819 DLGTEMPLATE* pDlg = (DLGTEMPLATE*)::LockResource(m_hDlgRes);
4820 LPCDLGTEMPLATE lpDialogTemplate = ATL::_DialogSplitHelper::SplitDialogTemplate(pDlg, pInitData);
4821 if(lpDialogTemplate != pDlg)
4822 m_hDlgResSplit = GlobalHandle(lpDialogTemplate);
4825 if(lpDialogTemplate != NULL)
4827 m_psp.dwFlags |= PSP_DLGINDIRECT;
4828 m_psp.pResource = lpDialogTemplate;
4832 ATLASSERT(FALSE && _T(
"CAxPropertyPageImpl - ActiveX initializtion failed!"));
4837 ATLASSERT(FALSE && _T(
"CAxPropertyPageImpl - Cannot find dialog template!"));
4843 if(m_hInitData != NULL)
4845 UnlockResource(m_hInitData);
4846 FreeResource(m_hInitData);
4848 if(m_hDlgRes != NULL)
4850 UnlockResource(m_hDlgRes);
4851 FreeResource(m_hDlgRes);
4853 if(m_hDlgResSplit != NULL)
4855 ::GlobalFree(m_hDlgResSplit);
4861 BOOL PreTranslateMessage(LPMSG pMsg)
4863 if ((pMsg->message < WM_KEYFIRST || pMsg->message > WM_KEYLAST) &&
4864 (pMsg->message < WM_MOUSEFIRST || pMsg->message > WM_MOUSELAST))
4867 HWND hWndCtl = ::GetFocus();
4868 if (IsChild(hWndCtl) && ::GetParent(hWndCtl) != m_hWnd)
4872 hWndCtl = ::GetParent(hWndCtl);
4874 while (::GetParent(hWndCtl) != m_hWnd);
4877 return (BOOL)::SendMessage(hWndCtl, WM_FORWARDMSG, 0, (LPARAM)pMsg);
4881 #if (_WIN32_IE >= 0x0500) 4883 #ifdef _WTL_NEW_PAGE_NOTIFY_HANDLERS 4884 int OnTranslateAccelerator(LPMSG lpMsg)
4886 T* pT =
static_cast<T*
>(
this);
4887 return (pT->PreTranslateMessage(lpMsg) != FALSE) ? PSNRET_MESSAGEHANDLED : PSNRET_NOERROR;
4889 #else // !_WTL_NEW_PAGE_NOTIFY_HANDLERS 4890 BOOL OnTranslateAccelerator(LPMSG lpMsg)
4892 T* pT =
static_cast<T*
>(
this);
4893 return pT->PreTranslateMessage(lpMsg);
4895 #endif // !_WTL_NEW_PAGE_NOTIFY_HANDLERS 4896 #endif // (_WIN32_IE >= 0x0500) 4899 #if (_ATL_VER >= 0x0700) 4902 return( static_cast<T*>(
this)->IDD );
4905 virtual DLGPROC GetDialogProc()
4910 static INT_PTR CALLBACK DialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
4913 if (uMsg == WM_INITDIALOG)
4916 if (FAILED(hr = pThis->CreateActiveXControls(pThis->GetIDD())))
4926 virtual HRESULT CreateActiveXControls(UINT nID)
4929 HRSRC hDlgInit = ::FindResource(ATL::_AtlBaseModule.GetResourceInstance(), MAKEINTRESOURCE(nID), (LPTSTR)_ATL_RT_DLGINIT);
4930 BYTE* pInitData = NULL;
4931 HGLOBAL hData = NULL;
4933 if (hDlgInit != NULL)
4935 hData = ::LoadResource(ATL::_AtlBaseModule.GetResourceInstance(), hDlgInit);
4937 pInitData = (BYTE*) ::LockResource(hData);
4940 HRSRC hDlg = ::FindResource(ATL::_AtlBaseModule.GetResourceInstance(), MAKEINTRESOURCE(nID), (LPTSTR)RT_DIALOG);
4943 HGLOBAL hResource = ::LoadResource(ATL::_AtlBaseModule.GetResourceInstance(), hDlg);
4944 DLGTEMPLATE* pDlg = NULL;
4945 if (hResource != NULL)
4947 pDlg = (DLGTEMPLATE*) ::LockResource(hResource);
4951 BOOL bDialogEx = ATL::_DialogSplitHelper::IsDialogEx(pDlg);
4952 WORD nItems = ATL::_DialogSplitHelper::DlgTemplateItemCount(pDlg);
4955 DLGITEMTEMPLATE* pItem = ATL::_DialogSplitHelper::FindFirstDlgItem(pDlg);
4956 HWND hWndPrev = GetWindow(GW_CHILD);
4959 for (WORD nItem = 0; nItem < nItems; nItem++)
4961 DWORD wID = bDialogEx ? ((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem)->id : pItem->id;
4962 if (ATL::_DialogSplitHelper::IsActiveXControl(pItem, bDialogEx))
4965 DWORD dwLen = ATL::_DialogSplitHelper::FindCreateData(wID, pInitData, &pData);
4966 ATL::CComPtr<IStream> spStream;
4969 HGLOBAL h = GlobalAlloc(GHND, dwLen);
4972 BYTE* pBytes = (BYTE*) GlobalLock(h);
4973 BYTE* pSource = pData;
4974 SecureHelper::memcpy_x(pBytes, dwLen, pSource, dwLen);
4976 CreateStreamOnHGlobal(h, TRUE, &spStream);
4985 ATL::CComBSTR bstrLicKey;
4986 hr = ATL::_DialogSplitHelper::ParseInitData(spStream, &bstrLicKey.m_str);
4989 ATL::CAxWindow2 wnd;
4991 LPWSTR pszClassName =
4993 (LPWSTR)(((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem) + 1) :
4994 (LPWSTR)(pItem + 1);
4999 ((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem)->x :
5003 ((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem)->y :
5005 rect.right = rect.left +
5007 ((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem)->cx :
5009 rect.bottom = rect.top +
5011 ((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem)->cy :
5015 MapDialogRect(&rect);
5022 ((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem)->style :
5023 pItem->style) | WS_TABSTOP,
5025 ((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem)->exStyle :
5028 ((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem)->id :
5036 if (bDialogEx && ((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem)->helpID != 0)
5037 wnd.SetWindowContextHelpId(((ATL::_DialogSplitHelper::DLGITEMTEMPLATEEX*)pItem)->helpID);
5038 #endif // !_WIN32_WCE 5040 hr = wnd.CreateControlLic(pszClassName, spStream, NULL, bstrLicKey);
5045 hWndPrev = HWND_TOP;
5046 wnd.SetWindowPos(hWndPrev, 0,0,0,0,SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
5051 hr = ATL::AtlHresultFromLastError();
5058 hWndPrev = ::GetWindow(hWndPrev, GW_HWNDNEXT);
5060 pItem = ATL::_DialogSplitHelper::FindNextDlgItem(pItem, bDialogEx);
5064 hr = ATL::AtlHresultFromLastError();
5067 hr = ATL::AtlHresultFromLastError();
5073 HRESULT AdviseSinkMap(
bool bAdvise)
5075 if(!bAdvise && m_hWnd == NULL)
5078 ATLTRACE2(atlTraceUI, 0, _T(
"CAxPropertyPageImpl::AdviseSinkMap called after the window was destroyed\n"));
5081 HRESULT hRet = E_NOTIMPL;
5082 __if_exists(T::_GetSinkMapFinder)
5084 T* pT =
static_cast<T*
>(
this);
5085 hRet = AtlAdviseSinkMap(pT, bAdvise);
5093 MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
5094 MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
5095 CHAIN_MSG_MAP(_baseClass)
5098 LRESULT OnInitDialog(UINT , WPARAM , LPARAM , BOOL& bHandled)
5101 ExecuteDlgInit(static_cast<T*>(
this)->IDD);
5102 AdviseSinkMap(
true);
5107 LRESULT OnDestroy(UINT , WPARAM , LPARAM , BOOL& bHandled)
5109 AdviseSinkMap(
false);
5113 #endif // (_ATL_VER >= 0x0700) 5117 template <WORD t_wDlgTemplateID>
5121 enum { IDD = t_wDlgTemplateID };
5126 #if (_WIN32_IE >= 0x0500) || (_ATL_VER >= 0x0700) 5131 #else // !((_WIN32_IE >= 0x0500) || (_ATL_VER >= 0x0700)) 5132 DECLARE_EMPTY_MSG_MAP()
5133 #endif // !((_WIN32_IE >= 0x0500) || (_ATL_VER >= 0x0700)) 5136 #endif // _ATL_NO_HOSTING 5142 #if (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) 5213 CWizard97SheetWindow& operator =(HWND hWnd)
5220 HFONT GetExteriorPageTitleFont(
void)
5222 ATLASSERT(::IsWindow(m_hWnd));
5223 return (HFONT)::SendMessage(m_hWnd, GetMessage_GetExteriorPageTitleFont(), 0, 0L);
5226 HFONT GetBulletFont(
void)
5228 ATLASSERT(::IsWindow(m_hWnd));
5229 return (HFONT)::SendMessage(m_hWnd, GetMessage_GetBulletFont(), 0, 0L);
5233 static UINT GetMessage_GetExteriorPageTitleFont()
5235 static UINT uGetExteriorPageTitleFont = 0;
5236 if(uGetExteriorPageTitleFont == 0)
5239 if(FAILED(lock.Lock()))
5241 ATLTRACE2(atlTraceUI, 0, _T(
"ERROR : Unable to lock critical section in CWizard97SheetWindow::GetMessage_GetExteriorPageTitleFont().\n"));
5246 if(uGetExteriorPageTitleFont == 0)
5247 uGetExteriorPageTitleFont = ::RegisterWindowMessage(_T(
"GetExteriorPageTitleFont_531AF056-B8BE-4c4c-B786-AC608DF0DF12"));
5251 ATLASSERT(uGetExteriorPageTitleFont != 0);
5252 return uGetExteriorPageTitleFont;
5255 static UINT GetMessage_GetBulletFont()
5257 static UINT uGetBulletFont = 0;
5258 if(uGetBulletFont == 0)
5261 if(FAILED(lock.Lock()))
5263 ATLTRACE2(atlTraceUI, 0, _T(
"ERROR : Unable to lock critical section in CWizard97SheetWindow::GetMessage_GetBulletFont().\n"));
5268 if(uGetBulletFont == 0)
5269 uGetBulletFont = ::RegisterWindowMessage(_T(
"GetBulletFont_AD347D08-8F65-45ef-982E-6352E8218AD5"));
5273 ATLASSERT(uGetBulletFont != 0);
5274 return uGetBulletFont;
5289 template <
class T,
class TBase = CWizard97SheetWindow>
5294 typedef CWizard97SheetImpl< T, TBase > thisClass;
5298 CFont m_fontExteriorPageTitle;
5300 bool m_bReceivedFirstSizeMessage;
5304 baseClass(title, uStartPage, hWndParent),
5305 m_bReceivedFirstSizeMessage(
false)
5307 m_psh.dwFlags &= ~(PSH_NOCONTEXTHELP);
5308 m_psh.dwFlags &= ~(PSH_WIZARD | PSH_WIZARD_LITE);
5310 m_psh.dwFlags |= (PSH_HASHELP | PSH_WIZARDCONTEXTHELP);
5311 m_psh.dwFlags |= PSH_WIZARD97;
5313 baseClass::SetHeader(headerBitmap.m_lpstr);
5314 baseClass::SetWatermark(watermarkBitmap.m_lpstr);
5318 void OnSheetInitialized()
5320 T* pT =
static_cast<T*
>(
this);
5321 pT->_InitializeFonts();
5328 void _InitializeFonts()
5337 LOGFONT titleLogFont = {0};
5338 LOGFONT bulletLogFont = {0};
5339 fontThisDialog.GetLogFont(&titleLogFont);
5340 fontThisDialog.GetLogFont(&bulletLogFont);
5344 titleLogFont.lfCharSet = DEFAULT_CHARSET;
5345 titleLogFont.lfWeight = FW_BOLD;
5346 SecureHelper::strcpy_x(titleLogFont.lfFaceName, _countof(titleLogFont.lfFaceName), _T(
"Verdana Bold"));
5347 INT titleFontPointSize = 12;
5348 titleLogFont.lfHeight = -::MulDiv(titleFontPointSize, dcScreen.GetDeviceCaps(LOGPIXELSY), 72);
5349 m_fontExteriorPageTitle.CreateFontIndirect(&titleLogFont);
5353 bulletLogFont.lfCharSet = DEFAULT_CHARSET;
5354 bulletLogFont.lfWeight = FW_NORMAL;
5355 SecureHelper::strcpy_x(bulletLogFont.lfFaceName, _countof(bulletLogFont.lfFaceName), _T(
"Marlett"));
5356 INT bulletFontSize = 8;
5357 bulletLogFont.lfHeight = -::MulDiv(bulletFontSize, dcScreen.GetDeviceCaps(LOGPIXELSY), 72);
5358 m_fontBullet.CreateFontIndirect(&bulletLogFont);
5362 BEGIN_MSG_MAP(thisClass)
5363 MESSAGE_HANDLER(CWizard97SheetWindow::GetMessage_GetExteriorPageTitleFont(), OnGetExteriorPageTitleFont)
5364 MESSAGE_HANDLER(CWizard97SheetWindow::GetMessage_GetBulletFont(), OnGetBulletFont)
5365 MESSAGE_HANDLER(WM_SIZE, OnSize)
5366 CHAIN_MSG_MAP(baseClass)
5369 LRESULT OnGetExteriorPageTitleFont(UINT , WPARAM , LPARAM , BOOL& )
5371 return (LRESULT)(HFONT)m_fontExteriorPageTitle;
5374 LRESULT OnGetBulletFont(UINT , WPARAM , LPARAM , BOOL& )
5376 return (LRESULT)(HFONT)m_fontBullet;
5379 LRESULT OnSize(UINT , WPARAM , LPARAM , BOOL& bHandled)
5381 if(!m_bReceivedFirstSizeMessage)
5383 m_bReceivedFirstSizeMessage =
true;
5384 this->CenterWindow();
5393 class CWizard97Sheet :
public CWizard97SheetImpl<CWizard97Sheet>
5397 typedef CWizard97Sheet thisClass;
5398 typedef CWizard97SheetImpl<CWizard97Sheet> baseClass;
5402 baseClass(title, headerBitmap, watermarkBitmap, uStartPage, hWndParent)
5405 BEGIN_MSG_MAP(thisClass)
5406 CHAIN_MSG_MAP(baseClass)
5414 #define WIZARD97_EXTERIOR_CXDLG 317 5415 #define WIZARD97_EXTERIOR_CYDLG 193 5417 #define WIZARD97_INTERIOR_CXDLG 317 5418 #define WIZARD97_INTERIOR_CYDLG 143 5427 CWizard97PageWindow& operator =(HWND hWnd)
5434 CWizard97SheetWindow GetPropertySheet()
const 5436 ATLASSERT(::IsWindow(m_hWnd));
5437 return CWizard97SheetWindow(GetParent());
5441 HFONT GetExteriorPageTitleFont(
void)
5443 ATLASSERT(::IsWindow(m_hWnd));
5444 return GetPropertySheet().GetExteriorPageTitleFont();
5447 HFONT GetBulletFont(
void)
5449 ATLASSERT(::IsWindow(m_hWnd));
5450 return GetPropertySheet().GetBulletFont();
5466 template <
class T,
class TBase = CWizard97PageWindow>
5471 typedef CWizard97PageImpl< T, TBase > thisClass;
5479 BEGIN_MSG_MAP(thisClass)
5480 CHAIN_MSG_MAP(baseClass)
5488 template <
class T,
class TBase = CWizard97PageWindow>
5489 class ATL_NO_VTABLE CWizard97ExteriorPageImpl :
public CPropertyPageImpl< T, TBase >
5493 typedef CWizard97ExteriorPageImpl< T, TBase > thisClass;
5498 CWizard97ExteriorPageImpl(
ATL::_U_STRINGorID title = (LPCTSTR)NULL) : baseClass(title)
5500 m_psp.dwFlags |= PSP_HASHELP;
5501 m_psp.dwFlags |= PSP_HIDEHEADER;
5505 BEGIN_MSG_MAP(thisClass)
5506 CHAIN_MSG_MAP(baseClass)
5514 template <
class T,
class TBase = CWizard97PageWindow>
5515 class ATL_NO_VTABLE CWizard97InteriorPageImpl :
public CPropertyPageImpl< T, TBase >
5519 typedef CWizard97InteriorPageImpl< T, TBase > thisClass;
5524 CWizard97InteriorPageImpl(
ATL::_U_STRINGorID title = (LPCTSTR)NULL) : baseClass(title)
5526 m_psp.dwFlags |= PSP_HASHELP;
5527 m_psp.dwFlags &= ~PSP_HIDEHEADER;
5528 m_psp.dwFlags |= PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
5532 baseClass::SetHeaderTitle(_T(
"Call SetHeaderTitle in Derived Class"));
5533 baseClass::SetHeaderSubTitle(_T(
"Call SetHeaderSubTitle in the constructor of the Derived Class."));
5537 BEGIN_MSG_MAP(thisClass)
5538 CHAIN_MSG_MAP(baseClass)
5542 #endif // (_WIN32_IE >= 0x0500) && !defined(_WIN32_WCE) 5548 #if (_WIN32_WINNT >= 0x0600) && !defined(_WIN32_WCE) 5560 CAeroWizardFrameWindow& operator =(HWND hWnd)
5567 void SetNextText(LPCWSTR lpszText)
5569 ATLASSERT(::IsWindow(m_hWnd));
5570 ::SendMessage(m_hWnd, PSM_SETNEXTTEXT, 0, (LPARAM)lpszText);
5573 void ShowWizardButtons(DWORD dwButtons, DWORD dwStates)
5575 ATLASSERT(::IsWindow(m_hWnd));
5576 ::PostMessage(m_hWnd, PSM_SHOWWIZBUTTONS, (WPARAM)dwStates, (LPARAM)dwButtons);
5579 void EnableWizardButtons(DWORD dwButtons, DWORD dwStates)
5581 ATLASSERT(::IsWindow(m_hWnd));
5582 ::PostMessage(m_hWnd, PSM_ENABLEWIZBUTTONS, (WPARAM)dwStates, (LPARAM)dwButtons);
5585 void SetButtonText(DWORD dwButton, LPCWSTR lpszText)
5587 ATLASSERT(::IsWindow(m_hWnd));
5588 ::SendMessage(m_hWnd, PSM_SETBUTTONTEXT, (WPARAM)dwButton, (LPARAM)lpszText);
5596 template <
class T,
class TBase = CAeroWizardFrameWindow>
5601 CAeroWizardFrameImpl(
ATL::_U_STRINGorID title = (LPCTSTR)NULL, UINT uStartPage = 0, HWND hWndParent = NULL) :
5604 m_psh.dwFlags |= PSH_WIZARD | PSH_AEROWIZARD;
5608 void EnableResizing()
5610 ATLASSERT(m_hWnd == NULL);
5611 m_psh.dwFlags |= PSH_RESIZABLE;
5614 void UseHeaderBitmap()
5616 ATLASSERT(m_hWnd == NULL);
5617 m_psh.dwFlags |= PSH_HEADERBITMAP;
5622 ATLASSERT(m_hWnd == NULL);
5623 m_psh.dwFlags |= PSH_NOMARGIN;
5627 HWND Create(HWND = NULL)
5638 class CAeroWizardFrame :
public CAeroWizardFrameImpl<CAeroWizardFrame>
5641 CAeroWizardFrame(
ATL::_U_STRINGorID title = (LPCTSTR)NULL, UINT uStartPage = 0, HWND hWndParent = NULL)
5642 : CAeroWizardFrameImpl<CAeroWizardFrame>(title, uStartPage, hWndParent)
5645 BEGIN_MSG_MAP(CAeroWizardFrame)
5646 MESSAGE_HANDLER(WM_COMMAND, CAeroWizardFrameImpl<CAeroWizardFrame>::OnCommand)
5661 CAeroWizardPageWindow& operator =(HWND hWnd)
5668 CAeroWizardFrameWindow GetAeroWizardFrame()
const 5670 ATLASSERT(::IsWindow(m_hWnd));
5672 return CAeroWizardFrameWindow(GetParent());
5676 void SetNextText(LPCWSTR lpszText)
5678 ATLASSERT(::IsWindow(m_hWnd));
5679 ATLASSERT(GetParent() != NULL);
5680 GetAeroWizardFrame().SetNextText(lpszText);
5683 void ShowWizardButtons(DWORD dwButtons, DWORD dwStates)
5685 ATLASSERT(::IsWindow(m_hWnd));
5686 ATLASSERT(GetParent() != NULL);
5687 GetAeroWizardFrame().ShowWizardButtons(dwButtons, dwStates);
5690 void EnableWizardButtons(DWORD dwButtons, DWORD dwStates)
5692 ATLASSERT(::IsWindow(m_hWnd));
5693 ATLASSERT(GetParent() != NULL);
5694 GetAeroWizardFrame().EnableWizardButtons(dwButtons, dwStates);
5697 void SetButtonText(DWORD dwButton, LPCWSTR lpszText)
5699 ATLASSERT(::IsWindow(m_hWnd));
5700 ATLASSERT(GetParent() != NULL);
5701 GetAeroWizardFrame().SetButtonText(dwButton, lpszText);
5709 template <
class T,
class TBase = CAeroWizardPageWindow>
5721 template <WORD t_wDlgTemplateID>
5722 class CAeroWizardPage :
public CAeroWizardPageImpl<CAeroWizardPage<t_wDlgTemplateID> >
5725 enum { IDD = t_wDlgTemplateID };
5727 CAeroWizardPage(
ATL::_U_STRINGorID title = (LPCTSTR)NULL) : CAeroWizardPageImpl<CAeroWizardPage>(title)
5730 DECLARE_EMPTY_MSG_MAP()
5734 #ifndef _ATL_NO_HOSTING 5741 template <
class T,
class TBase = CAeroWizardPageWindow>
5753 template <WORD t_wDlgTemplateID>
5754 class CAeroWizardAxPage :
public CAeroWizardAxPageImpl<CAeroWizardAxPage<t_wDlgTemplateID> >
5757 enum { IDD = t_wDlgTemplateID };
5759 CAeroWizardAxPage(
ATL::_U_STRINGorID title = (LPCTSTR)NULL) : CAeroWizardAxPageImpl<CAeroWizardAxPage>(title)
5762 #if (_WIN32_IE >= 0x0500) || (_ATL_VER >= 0x0700) 5764 BEGIN_MSG_MAP(CAeroWizardAxPage)
5765 CHAIN_MSG_MAP(CAeroWizardAxPageImpl<CAeroWizardAxPage<t_wDlgTemplateID> >)
5767 #else // !((_WIN32_IE >= 0x0500) || (_ATL_VER >= 0x0700)) 5768 DECLARE_EMPTY_MSG_MAP()
5769 #endif // !((_WIN32_IE >= 0x0500) || (_ATL_VER >= 0x0700)) 5772 #endif // _ATL_NO_HOSTING 5774 #endif // (_WIN32_WINNT >= 0x0600) && !defined(_WIN32_WCE) 5780 #if ((_WIN32_WINNT >= 0x0600) || defined(_WTL_TASKDIALOG)) && !defined(_WIN32_WCE) 5785 inline int AtlTaskDialog(HWND hWndParent,
5787 TASKDIALOG_COMMON_BUTTON_FLAGS dwCommonButtons = 0U,
ATL::_U_STRINGorID Icon = (LPCTSTR)NULL)
5791 #ifdef _WTL_TASKDIALOG_DIRECT 5793 HRESULT hRet = ::TaskDialog(hWndParent, ModuleHelper::GetResourceInstance(),
5794 IS_INTRESOURCE(WindowTitle.m_lpstr) ? (LPCWSTR) WindowTitle.m_lpstr : T2CW(WindowTitle.m_lpstr),
5795 IS_INTRESOURCE(MainInstructionText.m_lpstr) ? (LPCWSTR) MainInstructionText.m_lpstr : T2CW(MainInstructionText.m_lpstr),
5796 IS_INTRESOURCE(ContentText.m_lpstr) ? (LPCWSTR) ContentText.m_lpstr : T2CW(ContentText.m_lpstr),
5798 IS_INTRESOURCE(Icon.m_lpstr) ? (LPCWSTR) Icon.m_lpstr : T2CW(Icon.m_lpstr),
5800 ATLVERIFY(SUCCEEDED(hRet));
5803 typedef HRESULT (STDAPICALLTYPE *PFN_TaskDialog)(HWND hwndParent, HINSTANCE hInstance, PCWSTR pszWindowTitle, PCWSTR pszMainInstruction, PCWSTR pszContent, TASKDIALOG_COMMON_BUTTON_FLAGS dwCommonButtons, PCWSTR pszIcon,
int* pnButton);
5805 HMODULE m_hCommCtrlDLL = ::LoadLibrary(_T(
"comctl32.dll"));
5806 if(m_hCommCtrlDLL != NULL)
5808 PFN_TaskDialog pfnTaskDialog = (PFN_TaskDialog)::GetProcAddress(m_hCommCtrlDLL,
"TaskDialog");
5809 if(pfnTaskDialog != NULL)
5812 HRESULT hRet = pfnTaskDialog(hWndParent, ModuleHelper::GetResourceInstance(),
5813 IS_INTRESOURCE(WindowTitle.m_lpstr) ? (LPCWSTR) WindowTitle.m_lpstr : T2CW(WindowTitle.m_lpstr),
5814 IS_INTRESOURCE(MainInstructionText.m_lpstr) ? (LPCWSTR) MainInstructionText.m_lpstr : T2CW(MainInstructionText.m_lpstr),
5815 IS_INTRESOURCE(ContentText.m_lpstr) ? (LPCWSTR) ContentText.m_lpstr : T2CW(ContentText.m_lpstr),
5817 IS_INTRESOURCE(Icon.m_lpstr) ? (LPCWSTR) Icon.m_lpstr : T2CW(Icon.m_lpstr),
5819 ATLVERIFY(SUCCEEDED(hRet));
5822 ::FreeLibrary(m_hCommCtrlDLL);
5833 class CTaskDialogConfig :
public TASKDIALOGCONFIG
5844 memset(
this, 0,
sizeof(TASKDIALOGCONFIG));
5845 this->cbSize =
sizeof(TASKDIALOGCONFIG);
5846 this->hInstance = ModuleHelper::GetResourceInstance();
5851 void SetCommonButtons(TASKDIALOG_COMMON_BUTTON_FLAGS dwCommonButtons)
5853 this->dwCommonButtons = dwCommonButtons;
5857 void SetWindowTitle(UINT nID)
5859 this->pszWindowTitle = MAKEINTRESOURCEW(nID);
5862 void SetWindowTitle(LPCWSTR lpstrWindowTitle)
5864 this->pszWindowTitle = lpstrWindowTitle;
5868 void SetMainIcon(HICON hIcon)
5870 this->dwFlags |= TDF_USE_HICON_MAIN;
5871 this->hMainIcon = hIcon;
5874 void SetMainIcon(UINT nID)
5876 this->dwFlags &= ~TDF_USE_HICON_MAIN;
5877 this->pszMainIcon = MAKEINTRESOURCEW(nID);
5880 void SetMainIcon(LPCWSTR lpstrMainIcon)
5882 this->dwFlags &= ~TDF_USE_HICON_MAIN;
5883 this->pszMainIcon = lpstrMainIcon;
5887 void SetMainInstructionText(UINT nID)
5889 this->pszMainInstruction = MAKEINTRESOURCEW(nID);
5892 void SetMainInstructionText(LPCWSTR lpstrMainInstruction)
5894 this->pszMainInstruction = lpstrMainInstruction;
5898 void SetContentText(UINT nID)
5900 this->pszContent = MAKEINTRESOURCEW(nID);
5903 void SetContentText(LPCWSTR lpstrContent)
5905 this->pszContent = lpstrContent;
5909 void SetButtons(
const TASKDIALOG_BUTTON* pButtons, UINT cButtons,
int nDefaultButton = 0)
5911 this->pButtons = pButtons;
5912 this->cButtons = cButtons;
5913 if(nDefaultButton != 0)
5914 this->nDefaultButton = nDefaultButton;
5917 void SetDefaultButton(
int nDefaultButton)
5919 this->nDefaultButton = nDefaultButton;
5923 void SetRadioButtons(
const TASKDIALOG_BUTTON* pRadioButtons, UINT cRadioButtons,
int nDefaultRadioButton = 0)
5925 this->pRadioButtons = pRadioButtons;
5926 this->cRadioButtons = cRadioButtons;
5927 if(nDefaultRadioButton != 0)
5928 this->nDefaultRadioButton = nDefaultRadioButton;
5931 void SetDefaultRadioButton(
int nDefaultRadioButton)
5933 this->nDefaultRadioButton = nDefaultRadioButton;
5937 void SetVerificationText(UINT nID)
5939 this->pszVerificationText = MAKEINTRESOURCEW(nID);
5942 void SetVerificationText(LPCWSTR lpstrVerificationText)
5944 this->pszVerificationText = lpstrVerificationText;
5948 void SetExpandedInformationText(UINT nID)
5950 this->pszExpandedInformation = MAKEINTRESOURCEW(nID);
5953 void SetExpandedInformationText(LPCWSTR lpstrExpandedInformation)
5955 this->pszExpandedInformation = lpstrExpandedInformation;
5959 void SetExpandedControlText(UINT nID)
5961 this->pszExpandedControlText = MAKEINTRESOURCEW(nID);
5964 void SetExpandedControlText(LPCWSTR lpstrExpandedControlText)
5966 this->pszExpandedControlText = lpstrExpandedControlText;
5970 void SetCollapsedControlText(UINT nID)
5972 this->pszCollapsedControlText = MAKEINTRESOURCEW(nID);
5975 void SetCollapsedControlText(LPCWSTR lpstrCollapsedControlText)
5977 this->pszCollapsedControlText = lpstrCollapsedControlText;
5981 void SetFooterIcon(HICON hIcon)
5983 this->dwFlags |= TDF_USE_HICON_FOOTER;
5984 this->hFooterIcon = hIcon;
5987 void SetFooterIcon(UINT nID)
5989 this->dwFlags &= ~TDF_USE_HICON_FOOTER;
5990 this->pszFooterIcon = MAKEINTRESOURCEW(nID);
5993 void SetFooterIcon(LPCWSTR lpstrFooterIcon)
5995 this->dwFlags &= ~TDF_USE_HICON_FOOTER;
5996 this->pszFooterIcon = lpstrFooterIcon;
6000 void SetFooterText(UINT nID)
6002 this->pszFooter = MAKEINTRESOURCEW(nID);
6005 void SetFooterText(LPCWSTR lpstrFooterText)
6007 this->pszFooter = lpstrFooterText;
6011 void SetWidth(UINT cxWidth)
6013 this->cxWidth = cxWidth;
6017 void ModifyFlags(DWORD dwRemove, DWORD dwAdd)
6019 this->dwFlags = (this->dwFlags & ~dwRemove) | dwAdd;
6028 class ATL_NO_VTABLE CTaskDialogImpl
6031 CTaskDialogConfig m_tdc;
6035 CTaskDialogImpl(HWND hWndParent = NULL) : m_hWnd(NULL)
6037 m_tdc.hwndParent = hWndParent;
6038 m_tdc.pfCallback = T::TaskDialogCallback;
6039 m_tdc.lpCallbackData = (LONG_PTR)static_cast<T*>(
this);
6043 HRESULT DoModal(HWND hWndParent = ::GetActiveWindow(),
int* pnButton = NULL,
int* pnRadioButton = NULL, BOOL* pfVerificationFlagChecked = NULL)
6045 if(m_tdc.hwndParent == NULL)
6046 m_tdc.hwndParent = hWndParent;
6048 #ifdef _WTL_TASKDIALOG_DIRECT 6049 return ::TaskDialogIndirect(&m_tdc, pnButton, pnRadioButton, pfVerificationFlagChecked);
6053 typedef HRESULT (STDAPICALLTYPE *PFN_TaskDialogIndirect)(
const TASKDIALOGCONFIG* pTaskConfig,
int* pnButton,
int* pnRadioButton, BOOL* pfVerificationFlagChecked);
6055 HRESULT hRet = E_UNEXPECTED;
6056 HMODULE m_hCommCtrlDLL = ::LoadLibrary(_T(
"comctl32.dll"));
6057 if(m_hCommCtrlDLL != NULL)
6059 PFN_TaskDialogIndirect pfnTaskDialogIndirect = (PFN_TaskDialogIndirect)::GetProcAddress(m_hCommCtrlDLL,
"TaskDialogIndirect");
6060 if(pfnTaskDialogIndirect != NULL)
6061 hRet = pfnTaskDialogIndirect(&m_tdc, pnButton, pnRadioButton, pfVerificationFlagChecked);
6063 ::FreeLibrary(m_hCommCtrlDLL);
6072 void SetCommonButtons(TASKDIALOG_COMMON_BUTTON_FLAGS dwCommonButtons)
6073 { m_tdc.SetCommonButtons(dwCommonButtons); }
6075 void SetWindowTitle(UINT nID)
6076 { m_tdc.SetWindowTitle(nID); }
6077 void SetWindowTitle(LPCWSTR lpstrWindowTitle)
6078 { m_tdc.SetWindowTitle(lpstrWindowTitle); }
6080 void SetMainIcon(HICON hIcon)
6081 { m_tdc.SetMainIcon(hIcon); }
6082 void SetMainIcon(UINT nID)
6083 { m_tdc.SetMainIcon(nID); }
6084 void SetMainIcon(LPCWSTR lpstrMainIcon)
6085 { m_tdc.SetMainIcon(lpstrMainIcon); }
6087 void SetMainInstructionText(UINT nID)
6088 { m_tdc.SetMainInstructionText(nID); }
6089 void SetMainInstructionText(LPCWSTR lpstrMainInstruction)
6090 { m_tdc.SetMainInstructionText(lpstrMainInstruction); }
6092 void SetContentText(UINT nID)
6093 { m_tdc.SetContentText(nID); }
6094 void SetContentText(LPCWSTR lpstrContent)
6095 { m_tdc.SetContentText(lpstrContent); }
6097 void SetButtons(
const TASKDIALOG_BUTTON* pButtons, UINT cButtons,
int nDefaultButton = 0)
6098 { m_tdc.SetButtons(pButtons, cButtons, nDefaultButton); }
6099 void SetDefaultButton(
int nDefaultButton)
6100 { m_tdc.SetDefaultButton(nDefaultButton); }
6102 void SetRadioButtons(
const TASKDIALOG_BUTTON* pRadioButtons, UINT cRadioButtons,
int nDefaultRadioButton = 0)
6103 { m_tdc.SetRadioButtons(pRadioButtons, cRadioButtons, nDefaultRadioButton); }
6104 void SetDefaultRadioButton(
int nDefaultRadioButton)
6105 { m_tdc.SetDefaultRadioButton(nDefaultRadioButton); }
6107 void SetVerificationText(UINT nID)
6108 { m_tdc.SetVerificationText(nID); }
6109 void SetVerificationText(LPCWSTR lpstrVerificationText)
6110 { m_tdc.SetVerificationText(lpstrVerificationText); }
6112 void SetExpandedInformationText(UINT nID)
6113 { m_tdc.SetExpandedInformationText(nID); }
6114 void SetExpandedInformationText(LPCWSTR lpstrExpandedInformation)
6115 { m_tdc.SetExpandedInformationText(lpstrExpandedInformation); }
6117 void SetExpandedControlText(UINT nID)
6118 { m_tdc.SetExpandedControlText(nID); }
6119 void SetExpandedControlText(LPCWSTR lpstrExpandedControlText)
6120 { m_tdc.SetExpandedControlText(lpstrExpandedControlText); }
6122 void SetCollapsedControlText(UINT nID)
6123 { m_tdc.SetCollapsedControlText(nID); }
6124 void SetCollapsedControlText(LPCWSTR lpstrCollapsedControlText)
6125 { m_tdc.SetCollapsedControlText(lpstrCollapsedControlText); }
6127 void SetFooterIcon(HICON hIcon)
6128 { m_tdc.SetFooterIcon(hIcon); }
6129 void SetFooterIcon(UINT nID)
6130 { m_tdc.SetFooterIcon(nID); }
6131 void SetFooterIcon(LPCWSTR lpstrFooterIcon)
6132 { m_tdc.SetFooterIcon(lpstrFooterIcon); }
6134 void SetFooterText(UINT nID)
6135 { m_tdc.SetFooterText(nID); }
6136 void SetFooterText(LPCWSTR lpstrFooterText)
6137 { m_tdc.SetFooterText(lpstrFooterText); }
6139 void SetWidth(UINT cxWidth)
6140 { m_tdc.SetWidth(cxWidth); }
6142 void ModifyFlags(DWORD dwRemove, DWORD dwAdd)
6143 { m_tdc.ModifyFlags(dwRemove, dwAdd); }
6146 static HRESULT CALLBACK TaskDialogCallback(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LONG_PTR lpRefData)
6148 T* pT = (T*)lpRefData;
6149 ATLASSERT(pT->m_hWnd == NULL || pT->m_hWnd == hWnd);
6154 case TDN_DIALOG_CONSTRUCTED:
6156 pT->OnDialogConstructed();
6161 case TDN_BUTTON_CLICKED:
6162 bRet = pT->OnButtonClicked((
int)wParam);
6164 case TDN_RADIO_BUTTON_CLICKED:
6165 pT->OnRadioButtonClicked((
int)wParam);
6167 case TDN_HYPERLINK_CLICKED:
6168 pT->OnHyperlinkClicked((LPCWSTR)lParam);
6170 case TDN_EXPANDO_BUTTON_CLICKED:
6171 pT->OnExpandoButtonClicked((wParam != 0));
6173 case TDN_VERIFICATION_CLICKED:
6174 pT->OnVerificationClicked((wParam != 0));
6180 bRet = pT->OnTimer((DWORD)wParam);
6190 ATLTRACE2(atlTraceUI, 0, _T(
"Unknown notification received in CTaskDialogImpl::TaskDialogCallback\n"));
6194 return (HRESULT)bRet;
6198 void OnDialogConstructed()
6206 BOOL OnButtonClicked(
int )
6211 void OnRadioButtonClicked(
int )
6215 void OnHyperlinkClicked(LPCWSTR )
6219 void OnExpandoButtonClicked(
bool )
6223 void OnVerificationClicked(
bool )
6231 BOOL OnTimer(DWORD )
6245 void NavigatePage(TASKDIALOGCONFIG& tdc)
6247 ATLASSERT(m_hWnd != NULL);
6249 tdc.cbSize =
sizeof(TASKDIALOGCONFIG);
6250 if(tdc.hwndParent == NULL)
6251 tdc.hwndParent = m_tdc.hwndParent;
6252 tdc.pfCallback = m_tdc.pfCallback;
6253 tdc.lpCallbackData = m_tdc.lpCallbackData;
6254 (TASKDIALOGCONFIG)m_tdc = tdc;
6256 ::SendMessage(m_hWnd, TDM_NAVIGATE_PAGE, 0, (LPARAM)&tdc);
6262 ATLASSERT(m_hWnd != NULL);
6263 ::SendMessage(m_hWnd, TDM_NAVIGATE_PAGE, 0, (LPARAM)&m_tdc);
6266 void ClickButton(
int nButton)
6268 ATLASSERT(m_hWnd != NULL);
6269 ::SendMessage(m_hWnd, TDM_CLICK_BUTTON, nButton, 0L);
6272 void SetMarqueeProgressBar(BOOL bMarquee)
6274 ATLASSERT(m_hWnd != NULL);
6275 ::SendMessage(m_hWnd, TDM_SET_MARQUEE_PROGRESS_BAR, bMarquee, 0L);
6278 BOOL SetProgressBarState(
int nNewState)
6280 ATLASSERT(m_hWnd != NULL);
6281 return (BOOL)::SendMessage(m_hWnd, TDM_SET_PROGRESS_BAR_STATE, nNewState, 0L);
6284 DWORD SetProgressBarRange(
int nMinRange,
int nMaxRange)
6286 ATLASSERT(m_hWnd != NULL);
6287 return (DWORD)::SendMessage(m_hWnd, TDM_SET_PROGRESS_BAR_RANGE, 0, MAKELPARAM(nMinRange, nMaxRange));
6290 int SetProgressBarPos(
int nNewPos)
6292 ATLASSERT(m_hWnd != NULL);
6293 return (
int)::SendMessage(m_hWnd, TDM_SET_PROGRESS_BAR_POS, nNewPos, 0L);
6296 BOOL SetProgressBarMarquee(BOOL bMarquee, UINT uSpeed)
6298 ATLASSERT(m_hWnd != NULL);
6299 return (BOOL)::SendMessage(m_hWnd, TDM_SET_PROGRESS_BAR_MARQUEE, bMarquee, uSpeed);
6302 void SetElementText(TASKDIALOG_ELEMENTS element, LPCWSTR lpstrText)
6304 ATLASSERT(m_hWnd != NULL);
6305 ::SendMessage(m_hWnd, TDM_SET_ELEMENT_TEXT, element, (LPARAM)lpstrText);
6308 void ClickRadioButton(
int nRadioButton)
6310 ATLASSERT(m_hWnd != NULL);
6311 ::SendMessage(m_hWnd, TDM_CLICK_RADIO_BUTTON, nRadioButton, 0L);
6314 void EnableButton(
int nButton, BOOL bEnable)
6316 ATLASSERT(m_hWnd != NULL);
6317 ::SendMessage(m_hWnd, TDM_ENABLE_BUTTON, nButton, bEnable);
6320 void EnableRadioButton(
int nButton, BOOL bEnable)
6322 ATLASSERT(m_hWnd != NULL);
6323 ::SendMessage(m_hWnd, TDM_ENABLE_RADIO_BUTTON, nButton, bEnable);
6326 void ClickVerification(BOOL bCheck, BOOL bFocus)
6328 ATLASSERT(m_hWnd != NULL);
6329 ::SendMessage(m_hWnd, TDM_CLICK_VERIFICATION, bCheck, bFocus);
6332 void UpdateElementText(TASKDIALOG_ELEMENTS element, LPCWSTR lpstrText)
6334 ATLASSERT(m_hWnd != NULL);
6335 ::SendMessage(m_hWnd, TDM_UPDATE_ELEMENT_TEXT, element, (LPARAM)lpstrText);
6338 void SetButtonElevationRequiredState(
int nButton, BOOL bElevation)
6340 ATLASSERT(m_hWnd != NULL);
6341 ::SendMessage(m_hWnd, TDM_SET_BUTTON_ELEVATION_REQUIRED_STATE, nButton, bElevation);
6344 void UpdateIcon(TASKDIALOG_ICON_ELEMENTS element, HICON hIcon)
6346 ATLASSERT(m_hWnd != NULL);
6348 if(element == TDIE_ICON_MAIN)
6349 ATLASSERT((m_tdc.dwFlags & TDF_USE_HICON_MAIN) != 0);
6350 else if(element == TDIE_ICON_FOOTER)
6351 ATLASSERT((m_tdc.dwFlags & TDF_USE_HICON_FOOTER) != 0);
6353 ::SendMessage(m_hWnd, TDM_UPDATE_ICON, element, (LPARAM)hIcon);
6356 void UpdateIcon(TASKDIALOG_ICON_ELEMENTS element, LPCWSTR lpstrIcon)
6358 ATLASSERT(m_hWnd != NULL);
6360 if(element == TDIE_ICON_MAIN)
6361 ATLASSERT((m_tdc.dwFlags & TDF_USE_HICON_MAIN) == 0);
6362 else if(element == TDIE_ICON_FOOTER)
6363 ATLASSERT((m_tdc.dwFlags & TDF_USE_HICON_FOOTER) == 0);
6365 ::SendMessage(m_hWnd, TDM_UPDATE_ICON, element, (LPARAM)lpstrIcon);
6373 class CTaskDialog :
public CTaskDialogImpl<CTaskDialog>
6376 CTaskDialog(HWND hWndParent = NULL) : CTaskDialogImpl<CTaskDialog>(hWndParent)
6378 m_tdc.pfCallback = NULL;
6382 #endif // ((_WIN32_WINNT >= 0x0600) || defined(_WTL_TASKDIALOG)) && !defined(_WIN32_WCE) 6386 #endif // __ATLDLGS_H__ Definition: atlwinx.h:455
Definition: atldlgs.h:3874
Definition: atldlgs.h:1564
Definition: atldlgs.h:2133
Definition: atldlgs.h:3511
Definition: atldlgs.h:4259
Definition: atldlgs.h:1617
Definition: atldlgs.h:5118
Definition: atldlgs.h:4785
Definition: atlapp.h:1231
Definition: atldlgs.h:2642
Definition: atldlgs.h:2783
Definition: atlgdi.h:3388
Definition: atldlgs.h:2176
Definition: atldlgs.h:4271
Definition: atldlgs.h:853
Definition: atldlgs.h:1303
Definition: atldlgs.h:3096
Definition: atldlgs.h:408
Definition: atldlgs.h:2806
Definition: atldlgs.h:1961
Definition: atlapp.h:1317
Definition: atldlgs.h:2367
Definition: atldlgs.h:1778
Definition: atldlgs.h:2949
Definition: atlwinx.h:435
Definition: atlgdi.h:3409
Definition: atldlgs.h:3111
Definition: atldlgs.h:3602
Definition: atldlgs.h:464
Definition: atldlgs.h:1550
Definition: atldlgs.h:4766
Definition: atldlgs.h:126
Definition: atldlgs.h:2936
Definition: atldlgs.h:4353