Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

845 lines
21 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997 - 1999
  6. //
  7. // File: uiutil.h
  8. //
  9. //--------------------------------------------------------------------------
  10. /////////////////////////////////////////////////////////////////////
  11. // UIUtil.h
  12. //
  13. // HISTORY
  14. // 08-Nov-99 JeffJon Creation.
  15. /////////////////////////////////////////////////////////////////////
  16. #ifndef __UIUTIL_H_
  17. #define __UIUTIL_H_
  18. #include "resource.h"
  19. #include <htmlhelp.h>
  20. /////////////////////////////////////////////////////////////////////
  21. // Forward Declarations
  22. //
  23. class CDSComponentData;
  24. /////////////////////////////////////////////////////////////////////////////
  25. // CHelpDialog
  26. class CHelpDialog : public CDialog
  27. {
  28. // Construction
  29. public:
  30. CHelpDialog(UINT uIDD, CWnd* pParentWnd);
  31. CHelpDialog(UINT uIDD);
  32. ~CHelpDialog();
  33. protected:
  34. virtual void OnContextMenu(CWnd* pWnd, CPoint point);
  35. DECLARE_MESSAGE_MAP()
  36. virtual void DoContextHelp (HWND hWndControl);
  37. afx_msg void OnWhatsThis();
  38. afx_msg BOOL OnHelp(WPARAM wParam, LPARAM lParam);
  39. HWND m_hWndWhatsThis;
  40. };
  41. /////////////////////////////////////////////////////////////////////////////
  42. // CHelpPropertyPage
  43. class CHelpPropertyPage : public CPropertyPage
  44. {
  45. // Construction
  46. public:
  47. CHelpPropertyPage(UINT uIDD);
  48. ~CHelpPropertyPage();
  49. protected:
  50. afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
  51. DECLARE_MESSAGE_MAP()
  52. virtual void DoContextHelp (HWND hWndControl);
  53. afx_msg void OnWhatsThis();
  54. afx_msg BOOL OnHelp(WPARAM wParam, LPARAM lParam);
  55. private:
  56. HWND m_hWndWhatsThis;
  57. };
  58. /////////////////////////////////////////////////////////////////////
  59. // CDialogEx
  60. //
  61. class CDialogEx : public CDialog
  62. {
  63. public:
  64. CDialogEx(UINT nIDTemplate, CWnd * pParentWnd = NULL);
  65. HWND HGetDlgItem(INT nIdDlgItem);
  66. void SetDlgItemFocus(INT nIdDlgItem);
  67. void EnableDlgItem(INT nIdDlgItem, BOOL fEnable = TRUE);
  68. void HideDlgItem(INT nIdDlgItem, BOOL fHideItem = TRUE);
  69. };
  70. /////////////////////////////////////////////////////////////////////
  71. // CPropertyPageEx_Mine
  72. //
  73. class CPropertyPageEx_Mine : public CPropertyPage
  74. {
  75. public:
  76. CPropertyPageEx_Mine(UINT nIDTemplate);
  77. HWND HGetDlgItem(INT nIdDlgItem);
  78. void SetDlgItemFocus(INT nIdDlgItem);
  79. void EnableDlgItem(INT nIdDlgItem, BOOL fEnable = TRUE);
  80. void HideDlgItem(INT nIdDlgItem, BOOL fHideItem = TRUE);
  81. };
  82. ////////////////////////////////////////////////////////////////////////////////////
  83. // Error reporting helpers
  84. //
  85. void ReportError(HRESULT hr, int nStr, HWND hWnd);
  86. //
  87. // The message specified in dwMessageId must be in the DSADMIN module. It may
  88. // contain FormatMessage-style insertion strings. If lpArguments is specified,
  89. // then %1 and up are the arguments specified by lpArguments.
  90. // Return value and fuStyle are the same as for MessageBox.
  91. //
  92. int ReportMessageEx(HWND hWnd,
  93. DWORD dwMessageId,
  94. UINT fuStyle = MB_OK | MB_ICONINFORMATION,
  95. PVOID* lpArguments = NULL,
  96. int nArguments = 0,
  97. DWORD dwTitleId = 0,
  98. LPCTSTR pszHelpTopic = NULL,
  99. MSGBOXCALLBACK lpfnMsgBoxCallback = NULL );
  100. //
  101. // This is like ReportMessageEx except that %1 is the code for the HRESULT, and
  102. // %2 and up are the arguments specified by lpArguments (if any).
  103. //
  104. int ReportErrorEx(HWND hWnd,
  105. DWORD dwMessageId,
  106. HRESULT hr,
  107. UINT fuStyle = MB_OK | MB_ICONINFORMATION,
  108. PVOID* lpArguments = NULL,
  109. int nArguments = 0,
  110. DWORD dwTitleId = 0,
  111. BOOL TryADsIErrors = TRUE);
  112. const INT S_MB_YES_TO_ALL = 0x928L;
  113. int SpecialMessageBox (HWND hwnd,
  114. LPWSTR pwszMessage,
  115. LPWSTR pwszTitle,
  116. DWORD fuStyle = S_MB_YES_TO_ALL);
  117. ////////////////////////////////////////////////////////////////////////////
  118. // CMultiselectErrorDialog
  119. //
  120. class CMultiselectErrorDialog : public CDialog
  121. {
  122. public:
  123. CMultiselectErrorDialog(CDSComponentData* pComponentData)
  124. : m_pComponentData(pComponentData),
  125. m_pErrorArray(NULL),
  126. m_pPathArray(NULL),
  127. m_ppNodeList(NULL),
  128. m_nErrorCount(0),
  129. m_hImageList(NULL),
  130. CDialog(IDD_MULTISELECT_ERROR_DIALOG) {}
  131. ~CMultiselectErrorDialog() {}
  132. HRESULT Initialize(CUINode** ppNodeList,
  133. PWSTR* pErrorArray,
  134. UINT nErrorCount,
  135. PCWSTR pszTitle,
  136. PCWSTR pszCaption,
  137. PCWSTR pszHeader);
  138. HRESULT Initialize(PWSTR* pPathArray,
  139. PWSTR* pClassArray,
  140. PWSTR* pErrorArray,
  141. UINT nErrorCount,
  142. PCWSTR pszTitle,
  143. PCWSTR pszCaption,
  144. PCWSTR pszHeader);
  145. private:
  146. CMultiselectErrorDialog(const CMultiselectErrorDialog&) {}
  147. CMultiselectErrorDialog& operator=(const CMultiselectErrorDialog&) {}
  148. protected:
  149. void UpdateListboxHorizontalExtent();
  150. public:
  151. virtual BOOL OnInitDialog();
  152. DECLARE_MESSAGE_MAP()
  153. private:
  154. CDSComponentData* m_pComponentData;
  155. CUINode** m_ppNodeList;
  156. PWSTR* m_pPathArray;
  157. PWSTR* m_pClassArray;
  158. PWSTR* m_pErrorArray;
  159. UINT m_nErrorCount;
  160. CString m_szTitle;
  161. CString m_szCaption;
  162. CString m_szColumnHeader;
  163. HIMAGELIST m_hImageList;
  164. };
  165. /////////////////////////////////////////////////////////////////////////////
  166. // CProgressDialogBase
  167. //
  168. class CProgressDialogBase : public CDialog
  169. {
  170. public:
  171. static UINT s_nNextStepMessage;
  172. CProgressDialogBase(HWND hParentWnd);
  173. BOOL Aborted() { return !m_bDone; }
  174. void SetStepCount(UINT n)
  175. {
  176. ASSERT(n > 0);
  177. m_nSteps = n;
  178. }
  179. UINT GetStepCount() { return m_nSteps; }
  180. // Implementation
  181. protected:
  182. UINT m_nTitleStringID;
  183. // overrides
  184. virtual void OnStart()=0;
  185. virtual BOOL OnStep(UINT i)=0;
  186. virtual void OnEnd()=0;
  187. // message handlers
  188. virtual BOOL OnInitDialog();
  189. afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
  190. afx_msg void OnClose();
  191. afx_msg LONG OnNextStepMessage( WPARAM wParam, LPARAM lParam);
  192. private:
  193. CProgressCtrl m_progressCtrl;
  194. CString m_szProgressFormat;
  195. UINT m_nSteps; // number of steps to perform
  196. UINT m_nCurrStep; // current step, in range m_nSteps, 0
  197. BOOL m_bDone; // TRUE= reached completion
  198. void _SetProgressText();
  199. DECLARE_MESSAGE_MAP()
  200. };
  201. ////////////////////////////////////////////////////////////////////////
  202. // CMultipleDeletionConfirmationUI
  203. //
  204. class CMultipleDeletionConfirmationUI
  205. {
  206. public:
  207. CMultipleDeletionConfirmationUI()
  208. {
  209. m_hwnd = NULL;
  210. m_answerall = IDNO;
  211. m_answer = IDNO;
  212. }
  213. void SetWindow(HWND hwnd)
  214. {
  215. ASSERT(hwnd != NULL);
  216. m_hwnd = hwnd;
  217. }
  218. BOOL IsYesToAll() { return (m_answer == IDC_BUTTON_YESTOALL);}
  219. BOOL CanDeleteSubtree(HRESULT hr, LPCWSTR lpszName, BOOL* pbContinue)
  220. {
  221. *pbContinue = TRUE;
  222. if (m_answerall != IDC_BUTTON_YESTOALL)
  223. {
  224. PVOID apv[1] = {(LPWSTR)lpszName};
  225. m_answer = ReportErrorEx (m_hwnd,IDS_12_MULTI_OBJECT_HAS_CHILDREN,hr,
  226. S_MB_YES_TO_ALL | MB_ICONWARNING, apv, 1);
  227. if (m_answer == IDC_BUTTON_YESTOALL)
  228. {
  229. m_answerall = m_answer;
  230. m_answer = IDYES;
  231. }
  232. else if (m_answer == IDCANCEL)
  233. {
  234. m_answer = IDNO;
  235. *pbContinue = FALSE;
  236. }
  237. }
  238. else
  239. {
  240. m_answer = IDYES;
  241. }
  242. return m_answer == IDYES;
  243. }
  244. BOOL ErrorOnSubtreeDeletion(HRESULT hr, LPCWSTR lpszName)
  245. {
  246. if (m_answerall == IDC_BUTTON_YESTOALL)
  247. {
  248. return TRUE; // can continue, no need for asking
  249. }
  250. PVOID apv[1] = {(LPWSTR)lpszName};
  251. m_answer = ReportErrorEx (m_hwnd,IDS_12_SUBTREE_DELETE_FAILED,hr,
  252. MB_YESNO | MB_ICONINFORMATION, apv, 1);
  253. if (m_answer == IDNO)
  254. {
  255. return FALSE; // stop deletion process
  256. }
  257. return TRUE; // can continue
  258. }
  259. BOOL ErrorOnDeletion(HRESULT hr, LPCWSTR lpszName)
  260. {
  261. PVOID apv[1] = {(LPWSTR)lpszName};
  262. ReportErrorEx (m_hwnd,IDS_12_DELETE_FAILED,hr,
  263. MB_OK | MB_ICONERROR, apv, 1);
  264. if (m_answer == IDNO)
  265. {
  266. return FALSE; // stop deletion process
  267. }
  268. else
  269. {
  270. if (m_answer == IDC_BUTTON_YESTOALL)
  271. {
  272. m_answerall = m_answer;
  273. }
  274. }
  275. return TRUE; // can continue
  276. }
  277. private:
  278. HWND m_hwnd;
  279. UINT m_answerall;
  280. UINT m_answer;
  281. };
  282. ////////////////////////////////////////////////////////////////////////////
  283. // CMultipleProgressDialogBase
  284. //
  285. class CMultipleProgressDialogBase : public CProgressDialogBase
  286. {
  287. public:
  288. CMultipleProgressDialogBase(HWND hParentWnd, CDSComponentData* pComponentData)
  289. : m_pErrorArray(NULL),
  290. m_pPathArray(NULL),
  291. m_pClassArray(NULL),
  292. m_nErrorCount(0),
  293. m_pComponentData(pComponentData),
  294. CProgressDialogBase(hParentWnd)
  295. {
  296. }
  297. virtual ~CMultipleProgressDialogBase();
  298. HRESULT AddError(PCWSTR pszError,
  299. PCWSTR pszPath,
  300. PCWSTR pszClass);
  301. virtual void GetCaptionString(CString& szCaption) = 0;
  302. protected:
  303. virtual void OnEnd();
  304. CDSComponentData* m_pComponentData;
  305. CStringList m_szObjPathList;
  306. private:
  307. //
  308. // Error reporting structures
  309. //
  310. PWSTR* m_pErrorArray;
  311. PWSTR* m_pPathArray;
  312. PWSTR* m_pClassArray;
  313. UINT m_nErrorCount;
  314. };
  315. ////////////////////////////////////////////////////////////////////////////
  316. // CMultipleDeleteProgressDialog
  317. //
  318. class CMultipleDeleteHandlerBase;
  319. class CMultipleDeleteProgressDialog : public CMultipleProgressDialogBase
  320. {
  321. public:
  322. CMultipleDeleteProgressDialog(HWND hParentWnd,
  323. CDSComponentData* pComponentData,
  324. CMultipleDeleteHandlerBase* pDeleteHandler)
  325. : CMultipleProgressDialogBase(hParentWnd, pComponentData)
  326. {
  327. m_pDeleteHandler = pDeleteHandler;
  328. m_hWndOld = NULL;
  329. m_nTitleStringID = IDS_PROGRESS_DEL;
  330. }
  331. virtual void GetCaptionString(CString& szCaption)
  332. {
  333. VERIFY(szCaption.LoadString(IDS_MULTI_DELETE_ERROR_CAPTION));
  334. }
  335. protected:
  336. // overrides
  337. virtual void OnStart();
  338. virtual BOOL OnStep(UINT i);
  339. virtual void OnEnd();
  340. private:
  341. CMultipleDeleteHandlerBase* m_pDeleteHandler;
  342. HWND m_hWndOld;
  343. };
  344. /////////////////////////////////////////////////////////////////////////////
  345. // CMultipleMoveProgressDialog
  346. //
  347. class CMoveHandlerBase;
  348. class CMultipleMoveProgressDialog : public CMultipleProgressDialogBase
  349. {
  350. public:
  351. CMultipleMoveProgressDialog(HWND hParentWnd,
  352. CDSComponentData* pComponentData,
  353. CMoveHandlerBase* pMoveHandler)
  354. : CMultipleProgressDialogBase(hParentWnd, pComponentData)
  355. {
  356. m_pMoveHandler = pMoveHandler;
  357. m_hWndOld = NULL;
  358. m_nTitleStringID = IDS_PROGRESS_MOV;
  359. }
  360. virtual void GetCaptionString(CString& szCaption)
  361. {
  362. VERIFY(szCaption.LoadString(IDS_MULTI_MOVE_ERROR_CAPTION));
  363. }
  364. protected:
  365. // overrides
  366. virtual void OnStart();
  367. virtual BOOL OnStep(UINT i);
  368. virtual void OnEnd();
  369. private:
  370. CMoveHandlerBase* m_pMoveHandler;
  371. HWND m_hWndOld;
  372. };
  373. //////////////////////////////////////////////////////////////////
  374. // CMoreInfoMessageBox
  375. //
  376. class CMoreInfoMessageBox : public CDialog
  377. {
  378. public:
  379. // NOTE: Cannot have bCancelBtn == false and bUseYesNo == true
  380. CMoreInfoMessageBox(HWND hWndParent, IDisplayHelp* pIDisplayHelp, BOOL bCancelBtn, bool bUseYesNo = false)
  381. : m_bUseYesNo(bUseYesNo),
  382. m_bCancel(bCancelBtn),
  383. CDialog(bCancelBtn ? (bUseYesNo ? IDD_MSGBOX_YESNO_MOREINFO : IDD_MSGBOX_OKCANCEL_MOREINFO) : IDD_MSGBOX_OK_MOREINFO,
  384. CWnd::FromHandle(hWndParent)),
  385. m_spIDisplayHelp(pIDisplayHelp)
  386. {
  387. }
  388. void SetURL(LPCWSTR lpszURL) { m_szURL = lpszURL;}
  389. void SetMessage(LPCWSTR lpsz)
  390. {
  391. m_szMessage = lpsz;
  392. }
  393. // message handlers and MFC overrides
  394. virtual BOOL OnInitDialog()
  395. {
  396. SetDlgItemText(IDC_STATIC_MESSAGE, m_szMessage);
  397. if (m_bCancel)
  398. {
  399. SendMessage(
  400. DM_SETDEFID,
  401. (WPARAM)(m_bUseYesNo) ? IDNO : IDCANCEL,
  402. 0);
  403. SendDlgItemMessage(
  404. (m_bUseYesNo) ? IDNO : IDCANCEL,
  405. BM_SETSTYLE,
  406. (WPARAM)BS_DEFPUSHBUTTON,
  407. MAKELPARAM(TRUE, 0));
  408. SendDlgItemMessage(
  409. (m_bUseYesNo) ? IDYES : IDOK,
  410. BM_SETSTYLE,
  411. (WPARAM)BS_PUSHBUTTON,
  412. MAKELPARAM(TRUE, 0));
  413. }
  414. return TRUE;
  415. }
  416. afx_msg void OnMoreInfo()
  417. {
  418. TRACE(L"ShowTopic(%s)\n", (LPCWSTR)m_szURL);
  419. HRESULT hr = m_spIDisplayHelp->ShowTopic((LPWSTR)(LPCWSTR)m_szURL);
  420. if( hr != S_OK )
  421. {
  422. HtmlHelp( NULL,
  423. (LPCWSTR)m_szURL,
  424. HH_DISPLAY_TOPIC,
  425. NULL );
  426. }
  427. }
  428. DECLARE_MESSAGE_MAP()
  429. private:
  430. CComPtr<IDisplayHelp> m_spIDisplayHelp;
  431. CString m_szMessage;
  432. CString m_szURL;
  433. bool m_bUseYesNo;
  434. BOOL m_bCancel;
  435. };
  436. /////////////////////////////////////////////////////////////////////////////
  437. // CMoveServerDialog
  438. //
  439. class CMoveServerDialog : public CDialog
  440. {
  441. public:
  442. CMoveServerDialog(LPCTSTR lpcszBrowseRootPath, HICON hIcon, CWnd* pParent = NULL);
  443. // Dialog Data
  444. //{{AFX_DATA(CMoveServerDialog)
  445. enum { IDD = IDD_MOVE_SERVER };
  446. CString m_strServer;
  447. //}}AFX_DATA
  448. CString m_strTargetContainer;
  449. CString m_strBrowseRootPath;
  450. // Implementation
  451. protected:
  452. // message handlers
  453. virtual BOOL OnInitDialog();
  454. virtual void OnOK();
  455. void OnDblclkListview(NMHDR* pNMHDR, LRESULT* pResult) ;
  456. // CWnd overrides
  457. afx_msg
  458. void
  459. OnDestroy();
  460. private:
  461. HICON m_hIcon;
  462. HWND listview;
  463. HIMAGELIST listview_imagelist;
  464. DECLARE_MESSAGE_MAP()
  465. };
  466. /////////////////////////////////////////////////////////////////////////////
  467. // CConfirmOperationDialog
  468. //
  469. class CDSNotifyHandlerTransaction;
  470. class CConfirmOperationDialog : public CDialog
  471. {
  472. public:
  473. CConfirmOperationDialog(HWND hParentWnd, CDSNotifyHandlerTransaction* pTransaction);
  474. void SetStrings(LPCWSTR lpszOperation, LPCWSTR lpszAssocData)
  475. {
  476. m_lpszOperation = lpszOperation;
  477. m_lpszAssocData = lpszAssocData;
  478. }
  479. // Implementation
  480. protected:
  481. // overrides
  482. // message handlers
  483. virtual BOOL OnInitDialog();
  484. void UpdateListBoxHorizontalExtent();
  485. virtual void OnCancel()
  486. {
  487. EndDialog(IDNO);
  488. }
  489. afx_msg void OnYes();
  490. afx_msg void OnNo()
  491. {
  492. EndDialog(IDNO);
  493. }
  494. private:
  495. UINT m_nTitleStringID;
  496. LPCWSTR m_lpszOperation;
  497. LPCWSTR m_lpszAssocData;
  498. CDSNotifyHandlerTransaction* m_pTransaction;
  499. CCheckListBox m_extensionsList;
  500. DECLARE_MESSAGE_MAP()
  501. };
  502. ///////////////////////////////////////////////////////////////////////////
  503. // Name Formating classes
  504. //
  505. // CNameFormatterBase
  506. class CNameFormatterBase
  507. {
  508. private:
  509. class CToken
  510. {
  511. public:
  512. CToken()
  513. {
  514. m_bIsParam = FALSE;
  515. m_nIndex = -1;
  516. }
  517. BOOL m_bIsParam;
  518. INT m_nIndex;
  519. };
  520. public:
  521. CNameFormatterBase()
  522. {
  523. _Init();
  524. }
  525. virtual ~CNameFormatterBase()
  526. {
  527. _Clear();
  528. }
  529. HRESULT Initialize(IN MyBasePathsInfo* pBasePathInfo,
  530. IN LPCWSTR lpszClassName,
  531. IN UINT nStringID);
  532. BOOL Initialize(IN LPCWSTR lpszFormattingString);
  533. void SetMapping(IN LPCWSTR* lpszArgMapping, IN int nArgCount);
  534. void Format(OUT CString& szBuffer, IN LPCWSTR* lpszArgArr);
  535. private:
  536. static HRESULT _ReadFromDS(IN MyBasePathsInfo* pBasePathInfo,
  537. IN LPCWSTR lpszClassName,
  538. OUT CString& szFormatString);
  539. void _Init()
  540. {
  541. m_lpszFormattingString = NULL;
  542. m_tokenArray = NULL;
  543. m_lpszConstArr = NULL;
  544. m_lpszParamArr = NULL;
  545. m_mapArr = NULL;
  546. m_tokenArrCount = 0;
  547. m_constArrCount = 0;
  548. m_paramArrCount = 0;
  549. }
  550. void _Clear()
  551. {
  552. if (m_lpszFormattingString != NULL)
  553. {
  554. delete[] m_lpszFormattingString;
  555. m_lpszFormattingString = 0;
  556. }
  557. if (m_tokenArray != NULL)
  558. {
  559. delete[] m_tokenArray;
  560. m_tokenArray = 0;
  561. m_tokenArrCount = 0;
  562. }
  563. if (m_constArrCount != 0 && m_lpszConstArr)
  564. {
  565. delete[] m_lpszConstArr;
  566. m_lpszConstArr = 0;
  567. m_constArrCount = 0;
  568. }
  569. if (m_paramArrCount != 0 && m_lpszParamArr)
  570. {
  571. delete[] m_lpszParamArr;
  572. m_lpszParamArr = 0;
  573. m_paramArrCount = 0;
  574. }
  575. if (m_mapArr != NULL)
  576. {
  577. delete[] m_mapArr;
  578. m_mapArr = 0;
  579. }
  580. }
  581. void _AllocateMemory(LPCWSTR lpszFormattingString);
  582. LPWSTR m_lpszFormattingString;
  583. CToken* m_tokenArray;
  584. LPCWSTR* m_lpszConstArr;
  585. LPCWSTR* m_lpszParamArr;
  586. int* m_mapArr;
  587. int m_tokenArrCount;
  588. int m_constArrCount;
  589. int m_paramArrCount;
  590. };
  591. class CUserNameFormatter : public CNameFormatterBase
  592. {
  593. public:
  594. HRESULT Initialize(IN MyBasePathsInfo* pBasePathInfo,
  595. IN LPCWSTR lpszClassName)
  596. {
  597. static LPCWSTR lpszMapping[] = {L"givenName", L"initials", L"sn"};
  598. static const int nArgs = 3;
  599. HRESULT hr = CNameFormatterBase::Initialize(pBasePathInfo,
  600. lpszClassName,
  601. IDS_FORMAT_USER_NAME);
  602. if (FAILED(hr))
  603. {
  604. return hr;
  605. }
  606. SetMapping(lpszMapping, nArgs);
  607. return S_OK;
  608. }
  609. void FormatName(OUT CString& szBuffer,
  610. IN LPCWSTR lpszFirstName,
  611. IN LPCWSTR lpszInitials,
  612. IN LPCWSTR lpszLastName)
  613. {
  614. LPCWSTR lpszArgs[3];
  615. lpszArgs[0] = lpszFirstName;
  616. lpszArgs[1] = lpszInitials;
  617. lpszArgs[2] = lpszLastName;
  618. CNameFormatterBase::Format(szBuffer, lpszArgs);
  619. }
  620. };
  621. /////////////////////////////////////////////////////////////////////
  622. // List View utilities
  623. //
  624. struct TColumnHeaderItem
  625. {
  626. UINT uStringId; // Resource Id of the string
  627. INT nColWidth; // % of total width of the column (0 = autowidth, -1 = fill rest of space)
  628. };
  629. void ListView_AddColumnHeaders(HWND hwndListview,
  630. const TColumnHeaderItem rgzColumnHeader[]);
  631. int ListView_AddString(HWND hwndListview,
  632. const LPCTSTR psz,
  633. LPARAM lParam = 0);
  634. int ListView_AddStrings(HWND hwndListview,
  635. const LPCTSTR rgzpsz[],
  636. LPARAM lParam = 0);
  637. void ListView_SelectItem(HWND hwndListview, int iItem);
  638. int ListView_GetSelectedItem(HWND hwndListview);
  639. int ListView_FindString(HWND hwndListview, LPCTSTR szTextSearch);
  640. void ListView_SetItemString(HWND hwndListview,
  641. int iItem,
  642. int iSubItem,
  643. IN const CString& rstrText);
  644. int ListView_GetItemString(HWND hwndListview,
  645. int iItem,
  646. int iSubItem,
  647. OUT CString& rstrText);
  648. LPARAM ListView_GetItemLParam(HWND hwndListview,
  649. int iItem,
  650. OUT int * piItem = NULL);
  651. int ListView_FindLParam(HWND hwndListview,
  652. LPARAM lParam);
  653. int ListView_SelectLParam(HWND hwndListview,
  654. LPARAM lParam);
  655. /////////////////////////////////////////////////////////////////////
  656. // Dialog Utilities
  657. //
  658. HWND HGetDlgItem(HWND hdlg, INT nIdDlgItem);
  659. void SetDlgItemFocus(HWND hdlg, INT nIdDlgItem);
  660. void EnableDlgItem(HWND hdlg, INT nIdDlgItem, BOOL fEnable = TRUE);
  661. void HideDlgItem(HWND hdlg, INT nIdDlgItem, BOOL fHideItem = TRUE);
  662. void EnableDlgItemGroup(HWND hdlg,
  663. const UINT rgzidCtl[],
  664. BOOL fEnableAll = TRUE);
  665. void HideDlgItemGroup(HWND hdlg,
  666. const UINT rgzidCtl[],
  667. BOOL fHideAll = TRUE);
  668. //////////////////////////////////////////////////////////////////////
  669. // Combo box Utilities
  670. //
  671. int ComboBox_AddString(HWND hwndCombobox, UINT uStringId);
  672. void ComboBox_AddStrings(HWND hwndCombobox, const UINT rgzuStringId[]);
  673. int ComboBox_FindItemByLParam(HWND hwndComboBox, LPARAM lParam);
  674. int ComboBox_SelectItemByLParam(HWND hwndComboBox, LPARAM lParam);
  675. LPARAM ComboBox_GetSelectedItemLParam(HWND hwndComboBox);
  676. ////////////////////////////////////////////////////////////////////////////////////
  677. // Theme support
  678. class CThemeContextActivator
  679. {
  680. public:
  681. CThemeContextActivator() : m_ulActivationCookie(0)
  682. { SHActivateContext (&m_ulActivationCookie); }
  683. ~CThemeContextActivator()
  684. { SHDeactivateContext (m_ulActivationCookie); }
  685. private:
  686. ULONG_PTR m_ulActivationCookie;
  687. };
  688. #ifdef UNICODE
  689. #define PROPSHEETPAGE_V3 PROPSHEETPAGEW_V3
  690. #else
  691. #define PROPSHEETPAGE_V3 PROPSHEETPAGEA_V3
  692. #endif
  693. HPROPSHEETPAGE MyCreatePropertySheetPage(AFX_OLDPROPSHEETPAGE* psp);
  694. #endif // __UIUTIL_H_