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.

1054 lines
27 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997 - 2000.
  5. //
  6. // File: BaseDlg.cxx
  7. //
  8. // Contents: Implementation of class to drive the base object picker
  9. // dialog.
  10. //
  11. // Classes: CBaseDlg
  12. //
  13. // History: 05-02-2000 DavidMun Created
  14. //
  15. //---------------------------------------------------------------------------
  16. #include "headers.hxx"
  17. #pragma hdrstop
  18. static ULONG
  19. s_aulHelpIds[] =
  20. {
  21. IDC_OBJECT_TYPE_LBL, IDH_LOOK_FOR_EDIT,
  22. IDC_LOOK_FOR_PB, IDH_LOOK_FOR_PB,
  23. IDC_LOOK_FOR_EDIT, IDH_LOOK_FOR_EDIT,
  24. IDC_LOOK_IN_PB, IDH_LOOK_IN_PB,
  25. IDC_LOCATION_LBL, IDH_LOOK_IN_EDIT,
  26. IDC_LOOK_IN_EDIT, IDH_LOOK_IN_EDIT,
  27. IDC_NAME_LBL, IDH_NAME_LBL,
  28. IDC_RICHEDIT, IDH_RICHEDIT,
  29. IDC_CHECK_NAMES_PB, IDH_CHECK_NAMES_PB,
  30. IDC_ADVANCED_PB, IDH_ADVANCED_PB,
  31. 0,0
  32. };
  33. #define CY_SLE_IN_DLUS 6
  34. #define LINKWINDOW_CLASSW L"Link Window"
  35. //+--------------------------------------------------------------------------
  36. //
  37. // Member: CBaseDlg::CBaseDlg
  38. //
  39. // Synopsis: ctor
  40. //
  41. // Arguments: [rop] - reference to owning CObjectPicker instance
  42. //
  43. // History: 05-02-2000 DavidMun Created
  44. //
  45. //---------------------------------------------------------------------------
  46. CBaseDlg::CBaseDlg(
  47. const CObjectPicker &rop):
  48. m_rop(rop),
  49. m_AdvancedDlg(rop)
  50. {
  51. TRACE_CONSTRUCTOR(CBaseDlg);
  52. Clear();
  53. }
  54. //+--------------------------------------------------------------------------
  55. //
  56. // Member: CBaseDlg::Clear
  57. //
  58. // Synopsis: Reset all internal variables (used for both initialization
  59. // and shutdown).
  60. //
  61. // History: 06-22-2000 DavidMun Created
  62. //
  63. //---------------------------------------------------------------------------
  64. void
  65. CBaseDlg::Clear()
  66. {
  67. TRACE_METHOD(CBaseDlg, Clear);
  68. m_hpenUnderline = NULL;
  69. m_ppdoSelections = NULL;
  70. m_cxMin = 0;
  71. m_cyMin = 0;
  72. m_cxSeparation = 0;
  73. m_cySeparation = 0;
  74. m_cxFrameLast = 0;
  75. m_cyFrameLast = 0;
  76. m_cxFour = 0;
  77. m_fMultiSelect = FALSE;
  78. m_rpRichEditOle = NULL;
  79. }
  80. //+--------------------------------------------------------------------------
  81. //
  82. // Member: CBaseDlg::DoModal
  83. //
  84. // Synopsis: Create the modal base dialog.
  85. //
  86. // Arguments: [ppdoSelections] - filled with resulting selections if
  87. // return value is S_OK.
  88. //
  89. // Returns: S_OK - user made selections and hit OK, *[ppdoSelections]
  90. // is valid and caller must Release() it.
  91. // S_FALSE - user hit Cancel button, *[ppdoSelections] is NULL.
  92. // E_* - error occurred, *[ppdoSelections] is NULL.
  93. //
  94. // History: 05-02-2000 DavidMun Created
  95. //
  96. //---------------------------------------------------------------------------
  97. HRESULT
  98. CBaseDlg::DoModal(
  99. IDataObject **ppdoSelections) const
  100. {
  101. TRACE_METHOD(CBaseDlg, DoModal);
  102. m_ppdoSelections = ppdoSelections;
  103. INT_PTR pi = _DoModalDlg(m_rop.GetParentHwnd(), IDD_STANDALONE_TEXT);
  104. m_ppdoSelections = NULL;
  105. return static_cast<HRESULT>(pi);
  106. }
  107. //+--------------------------------------------------------------------------
  108. //
  109. // Member: CBaseDlg::_OnInit
  110. //
  111. // Synopsis: Handle WM_INITDIALOG.
  112. //
  113. // Arguments: [pfSetFocus] - set to FALSE if focus changed.
  114. //
  115. // Returns: S_OK
  116. //
  117. // History: 05-02-2000 DavidMun Created
  118. //
  119. //---------------------------------------------------------------------------
  120. HRESULT
  121. CBaseDlg::_OnInit(
  122. BOOL *pfSetFocus)
  123. {
  124. TRACE_METHOD(CBaseDlg, _OnInit);
  125. //
  126. // Make prefix shut up
  127. //
  128. if (!_hCtrl(IDC_RICHEDIT) ||
  129. !_hCtrl(IDC_CHECK_NAMES_PB) ||
  130. !_hCtrl(IDOK) ||
  131. !_hCtrl(IDC_SIZEGRIP))
  132. {
  133. return E_FAIL;
  134. }
  135. if (m_rop.GetInitInfoOptions() & DSOP_FLAG_MULTISELECT)
  136. {
  137. m_fMultiSelect = TRUE;
  138. }
  139. else
  140. {
  141. m_fMultiSelect = FALSE;
  142. }
  143. //
  144. // Init data needed for sizing.
  145. //
  146. // First translate the separation distance between controls from
  147. // dialog units to pixels.
  148. //
  149. RECT rc;
  150. rc.left = rc.top = 1;
  151. rc.right = DIALOG_SEPARATION_X;
  152. rc.bottom = DIALOG_SEPARATION_Y;
  153. VERIFY(MapDialogRect(m_hwnd, &rc));
  154. m_cxSeparation = rc.right;
  155. m_cySeparation = rc.bottom;
  156. rc.left = rc.top = 1;
  157. rc.right = 4;
  158. rc.bottom = 4;
  159. VERIFY(MapDialogRect(m_hwnd, &rc));
  160. m_cxFour = rc.right;
  161. //
  162. // Next shrink the dialog if we're in single select mode; the rich
  163. // edit should be the height of an SLE (14 DLUs).
  164. //
  165. if (!m_fMultiSelect)
  166. {
  167. //
  168. // Replace multiselect instruction text with single-select instruction
  169. // text.
  170. //
  171. String strText(String::load(IDS_SINGLE_SELECT_INSTRUCTIONS));
  172. if (!strText.empty())
  173. {
  174. Static_SetText(_hCtrl(IDC_NAME_LBL), strText.c_str());
  175. }
  176. }
  177. GetClientRect(m_hwnd, &rc);
  178. //
  179. // Now save the starting size; _OnMinMaxInfo will prevent the dialog
  180. // from being sized smaller than this.
  181. //
  182. m_cxFrameLast = rc.right;
  183. m_cyFrameLast = rc.bottom;
  184. GetWindowRect(m_hwnd, &rc);
  185. m_cxMin = rc.right - rc.left + 1;
  186. m_cyMin = rc.bottom - rc.top + 1;
  187. //
  188. // Get rich edit's ole interface, give it our callback
  189. //
  190. HWND hRichEdit = _hCtrl(IDC_RICHEDIT);
  191. if(!hRichEdit) return E_FAIL;
  192. ASSERT(!m_rpRichEditOle.get());
  193. LRESULT lResult = SendMessage(hRichEdit,
  194. EM_GETOLEINTERFACE,
  195. 0,
  196. (LPARAM) &m_rpRichEditOle);
  197. if (!lResult)
  198. {
  199. DBG_OUT_LASTERROR;
  200. return HRESULT_FROM_LASTERROR;
  201. }
  202. ASSERT(m_rpRichEditOle.get());
  203. SendMessage( hRichEdit,EM_LIMITTEXT,0x7FFFFFFE,0);
  204. CRichEditOleCallback *pRichEditOleCallback =
  205. new CRichEditOleCallback(hRichEdit);
  206. SendMessage(hRichEdit,
  207. EM_SETOLECALLBACK,
  208. 0,
  209. (LPARAM) pRichEditOleCallback);
  210. pRichEditOleCallback->Release();
  211. SendMessage(hRichEdit,
  212. EM_SETEVENTMASK,
  213. 0,
  214. (LPARAM) ENM_CHANGE);
  215. //
  216. // Subclass the rich edit control for keystroke notification and
  217. // Enter key forwarding.
  218. //
  219. SetWindowLongPtr(hRichEdit, GWLP_USERDATA, (LONG_PTR) this);
  220. m_OriginalRichEditWndProc = (WNDPROC) SetWindowLongPtr(hRichEdit,
  221. GWLP_WNDPROC,
  222. (LONG_PTR)_EditWndProc);
  223. //
  224. // Init Look For readonly edit control, Look In readonly edit control,
  225. // and window caption.
  226. //
  227. UpdateLookForInText(m_hwnd, m_rop);
  228. #if (DBG == 1)
  229. const CFilterManager &rfm = m_rop.GetFilterManager();
  230. Dbg(DEB_TRACE,
  231. "UA: initial Look For setting '%ws'\n",
  232. rfm.GetFilterDescription(m_hwnd, FOR_LOOK_FOR).c_str());
  233. const CScopeManager &rsm = m_rop.GetScopeManager();
  234. Dbg(DEB_TRACE,
  235. "UA: initial Look In setting '%ws'\n",
  236. rsm.GetCurScope().GetDisplayName().c_str());
  237. #endif // (DBG == 1)
  238. m_hpenUnderline = CreatePen(PS_SOLID, 0, GetSysColor(COLOR_WINDOWTEXT));
  239. // these are disabled till user types something
  240. SafeEnableWindow(_hCtrl(IDC_CHECK_NAMES_PB), FALSE);
  241. SafeEnableWindow(_hCtrl(IDOK), FALSE);
  242. //
  243. // Set the focus to the rich edit control
  244. //
  245. #if (DBG == 1)
  246. HWND hwndPrev =
  247. #endif
  248. SetFocus(hRichEdit);
  249. #if (DBG == 1)
  250. if (!hwndPrev)
  251. {
  252. DBG_OUT_LASTERROR;
  253. }
  254. #endif
  255. *pfSetFocus = FALSE;
  256. return S_OK;
  257. }
  258. //+--------------------------------------------------------------------------
  259. //
  260. // Member: CBaseDlg::_OnSysColorChange
  261. //
  262. // Synopsis: Update the pen used for drawing objects in the rich edit
  263. // control.
  264. //
  265. // History: 06-22-2000 DavidMun Created
  266. //
  267. //---------------------------------------------------------------------------
  268. void
  269. CBaseDlg::_OnSysColorChange()
  270. {
  271. TRACE_METHOD(CBaseDlg, _OnSysColorChange);
  272. if (m_hpenUnderline)
  273. {
  274. VERIFY(DeleteObject(m_hpenUnderline));
  275. }
  276. m_hpenUnderline = CreatePen(PS_SOLID, 0, GetSysColor(COLOR_WINDOWTEXT));
  277. }
  278. //+--------------------------------------------------------------------------
  279. //
  280. // Member: CBaseDlg::_OnDestroy
  281. //
  282. // Synopsis: Free resources on dialog destruction
  283. //
  284. // History: 06-22-2000 DavidMun Created
  285. //
  286. //---------------------------------------------------------------------------
  287. void
  288. CBaseDlg::_OnDestroy()
  289. {
  290. TRACE_METHOD(CBaseDlg, _OnDestroy);
  291. if (m_hpenUnderline)
  292. {
  293. VERIFY(DeleteObject(m_hpenUnderline));
  294. }
  295. Clear();
  296. }
  297. //+--------------------------------------------------------------------------
  298. //
  299. // Member: CBaseDlg::_OnCommand
  300. //
  301. // Synopsis: Handle WM_COMMAND messages
  302. //
  303. // Arguments: [wParam] - standard windows
  304. // [lParam] - standard windows
  305. //
  306. // Returns: standard windows
  307. //
  308. // History: 06-22-2000 DavidMun Created
  309. //
  310. //---------------------------------------------------------------------------
  311. BOOL
  312. CBaseDlg::_OnCommand(
  313. WPARAM wParam,
  314. LPARAM lParam)
  315. {
  316. BOOL fHandled = TRUE;
  317. switch (LOWORD(wParam))
  318. {
  319. case IDC_LOOK_IN_PB:
  320. Dbg(DEB_TRACE, "UA: (BaseDlg) hit Look In button\n");
  321. m_rop.GetScopeManager().DoLookInDialog(m_hwnd);
  322. m_rop.GetFilterManager().HandleScopeChange(m_hwnd);
  323. UpdateLookForInText(m_hwnd, m_rop);
  324. SetFocus(_hCtrl(IDC_RICHEDIT));
  325. break;
  326. case IDC_LOOK_FOR_PB:
  327. {
  328. Dbg(DEB_TRACE, "UA: (BaseDlg) hit Look For button\n");
  329. const CFilterManager &rfm = m_rop.GetFilterManager();
  330. rfm.DoLookForDialog(m_hwnd);
  331. Edit_SetText(_hCtrl(IDC_LOOK_FOR_EDIT),
  332. rfm.GetFilterDescription(m_hwnd, FOR_LOOK_FOR).c_str());
  333. SetFocus(_hCtrl(IDC_RICHEDIT));
  334. break;
  335. }
  336. case IDC_CHECK_NAMES_PB:
  337. Dbg(DEB_TRACE, "UA: (BaseDlg) hit Check Names button\n");
  338. m_rop.ProcessNames(_hCtrl(IDC_RICHEDIT), this);
  339. UpdateLookForInText(m_hwnd, m_rop);
  340. SetFocus(_hCtrl(IDC_RICHEDIT));
  341. break;
  342. case IDC_ADVANCED_PB:
  343. {
  344. Dbg(DEB_TRACE, "UA: (BaseDlg) hit Advanced button\n");
  345. vector<CDsObject> vSelectedObjects;
  346. m_AdvancedDlg.DoModalDlg(m_hwnd, &vSelectedObjects);
  347. UpdateLookForInText(m_hwnd, m_rop);
  348. //
  349. // Add all selected objects to richedit
  350. //
  351. HWND hwndRichEdit = _hCtrl(IDC_RICHEDIT);
  352. IRichEditOle *pRichEditOle = NULL;
  353. LRESULT lResult = SendMessage(hwndRichEdit,
  354. EM_GETOLEINTERFACE,
  355. 0,
  356. (LPARAM) &pRichEditOle);
  357. if (!lResult)
  358. {
  359. DBG_OUT_LASTERROR;
  360. break;
  361. }
  362. CRichEditHelper re(m_rop, hwndRichEdit, this, pRichEditOle, FALSE);
  363. LONG cpEnd;
  364. CHARRANGE chrg;
  365. bool fNeedDelim = FALSE;
  366. if (m_fMultiSelect)
  367. {
  368. // append the new objects.
  369. LRESULT cchInEdit = SendMessage(hwndRichEdit,
  370. WM_GETTEXTLENGTH,
  371. 0,
  372. 0);
  373. SendMessage(hwndRichEdit, EM_SETSEL, cchInEdit, cchInEdit);
  374. fNeedDelim = (cchInEdit != 0);
  375. }
  376. else
  377. {
  378. // replace the old objects with the new ones
  379. // NTRAID#NTBUG9-191537-2000/11/13-sburns
  380. if (vSelectedObjects.size())
  381. {
  382. re.Erase(re.begin(), re.end());
  383. }
  384. }
  385. SendMessage(hwndRichEdit,
  386. EM_EXGETSEL,
  387. 0,
  388. reinterpret_cast<LPARAM>(&chrg));
  389. cpEnd = chrg.cpMax;
  390. for (size_t i = 0; i < vSelectedObjects.size(); i++)
  391. {
  392. if (!re.AlreadyInRichEdit(vSelectedObjects[i]))
  393. {
  394. if (fNeedDelim)
  395. {
  396. re.Insert(cpEnd, L"; ");
  397. cpEnd += 2;
  398. }
  399. re.InsertObject(cpEnd++, vSelectedObjects[i]);
  400. fNeedDelim = TRUE;
  401. }
  402. }
  403. SAFE_RELEASE(pRichEditOle);
  404. SetFocus(_hCtrl(IDC_RICHEDIT));
  405. break;
  406. }
  407. case IDC_RICHEDIT:
  408. if (HIWORD(wParam) == EN_CHANGE)
  409. {
  410. BOOL fNonEmpty = Edit_GetTextLength(_hCtrl(IDC_RICHEDIT));
  411. SafeEnableWindow(_hCtrl(IDOK), fNonEmpty);
  412. // if the check names button has the focus, put it in
  413. // the richedit before disabling the button
  414. if (GetFocus() == _hCtrl(IDC_CHECK_NAMES_PB))
  415. {
  416. SetFocus(_hCtrl(IDC_RICHEDIT));
  417. }
  418. SafeEnableWindow(_hCtrl(IDC_CHECK_NAMES_PB), fNonEmpty);
  419. }
  420. break;
  421. case IDM_CUT:
  422. Dbg(DEB_TRACE, "UA: (BaseDlg) selected rich edit cmenu CUT\n");
  423. SendMessage(_hCtrl(IDC_RICHEDIT), WM_CUT, 0, 0);
  424. break;
  425. case IDM_COPY:
  426. Dbg(DEB_TRACE, "UA: (BaseDlg) selected rich edit cmenu COPY\n");
  427. SendMessage(_hCtrl(IDC_RICHEDIT), WM_COPY, 0, 0);
  428. break;
  429. case IDM_PASTE:
  430. Dbg(DEB_TRACE, "UA: (BaseDlg) selected rich edit cmenu PASTE\n");
  431. SendMessage(_hCtrl(IDC_RICHEDIT), WM_PASTE, 0, 0);
  432. break;
  433. case IDOK:
  434. Dbg(DEB_TRACE, "UA: (BaseDlg) hit OK\n");
  435. if (m_rop.ProcessNames(_hCtrl(IDC_RICHEDIT), this))
  436. {
  437. //
  438. //Only one object can be returned in case of single select
  439. //
  440. if(m_rpRichEditOle->GetObjectCount() > 1 && !m_fMultiSelect)
  441. {
  442. PopupMessage(m_hwnd,IDS_SINGLE_SEL_MSG);
  443. }
  444. else
  445. {
  446. HRESULT hr = _CreateDataObjectFromSelections();
  447. BREAK_ON_FAIL_HRESULT(hr);
  448. EndDialog(GetHwnd(), hr);
  449. }
  450. }
  451. else
  452. {
  453. UpdateLookForInText(m_hwnd, m_rop);
  454. SetFocus(_hCtrl(IDC_RICHEDIT));
  455. }
  456. break;
  457. case IDCANCEL:
  458. Dbg(DEB_TRACE, "UA: (BaseDlg) hit Cancel\n");
  459. EndDialog(GetHwnd(), S_FALSE);
  460. break;
  461. default:
  462. fHandled = FALSE;
  463. Dbg(DEB_WARN,
  464. "CBaseDlg WM_COMMAND code=%#x, id=%#x, hwnd=%#x\n",
  465. HIWORD(wParam),
  466. LOWORD(wParam),
  467. lParam);
  468. break;
  469. }
  470. return fHandled;
  471. }
  472. BOOL
  473. CBaseDlg::_OnNotify(WPARAM wParam, LPARAM lParam)
  474. {
  475. if(wParam == IDC_NAME_LBL)
  476. {
  477. switch (((NMHDR FAR*)lParam)->code)
  478. {
  479. //
  480. //Show the help popup for Examples
  481. //
  482. case NM_CLICK:
  483. case NM_RETURN:
  484. {
  485. WinHelp(_hCtrl((ULONG)wParam),
  486. c_wzHelpFilename,
  487. HELP_WM_HELP,
  488. (DWORD_PTR) s_aulHelpIds);
  489. return TRUE;
  490. }
  491. break;
  492. }
  493. }
  494. return FALSE;
  495. }
  496. //+--------------------------------------------------------------------------
  497. //
  498. // Member: CBaseDlg::_CreateDataObjectFromSelections
  499. //
  500. // Synopsis: Create a data object, which caller can use, containing
  501. // entries for all objects the user has selected.
  502. //
  503. // Returns: HRESULT
  504. //
  505. // History: 06-22-2000 DavidMun Created
  506. //
  507. //---------------------------------------------------------------------------
  508. HRESULT
  509. CBaseDlg::_CreateDataObjectFromSelections()
  510. {
  511. TRACE_METHOD(CBaseDlg, _CreateDataObjectFromSelections);
  512. LONG cObjects = m_rpRichEditOle->GetObjectCount();
  513. CDsObjectList dsol;
  514. LONG i;
  515. ASSERT(cObjects > 0);
  516. *m_ppdoSelections = NULL;
  517. for (i = 0; i < cObjects; i++)
  518. {
  519. REOBJECT reobj;
  520. HRESULT hr;
  521. ZeroMemory(&reobj, sizeof reobj);
  522. reobj.cbStruct = sizeof(reobj);
  523. hr = m_rpRichEditOle->GetObject(i, &reobj, REO_GETOBJ_POLEOBJ);
  524. if (FAILED(hr))
  525. {
  526. DBG_OUT_HRESULT(hr);
  527. continue;
  528. }
  529. ASSERT(reobj.poleobj);
  530. CDsObject *pdso = (CDsObject *)(CEmbeddedDsObject*)reobj.poleobj;
  531. dsol.push_back(*pdso);
  532. reobj.poleobj->Release();
  533. }
  534. CDsObjectList okObjects;
  535. AddSidOkSelection
  536. (
  537. dsol,
  538. m_rop.GetTargetComputer().c_str(),
  539. okObjects,
  540. m_hwnd
  541. );
  542. if(okObjects.size()==0) return S_FALSE;
  543. CObjectPicker *pop = const_cast<CObjectPicker *>(&m_rop);
  544. *m_ppdoSelections = new CDataObject(pop, okObjects);
  545. return S_OK;
  546. }
  547. //+--------------------------------------------------------------------------
  548. //
  549. // Member: CBaseDlg::_OnSize
  550. //
  551. // Synopsis: Handle window resizing
  552. //
  553. // Arguments: [wParam] - standard windows
  554. // [lParam] - standard windows
  555. //
  556. // Returns: standard windows
  557. //
  558. // History: 06-22-2000 DavidMun Created
  559. //
  560. //---------------------------------------------------------------------------
  561. BOOL
  562. CBaseDlg::_OnSize(
  563. WPARAM wParam,
  564. LPARAM lParam)
  565. {
  566. WORD nWidth = LOWORD(lParam); // width of client area
  567. WORD nHeight = HIWORD(lParam); // height of client area
  568. //
  569. // Move the OK/Cancel buttons so they're always at lower right
  570. // corner of dialog.
  571. //
  572. RECT rcDlg;
  573. GetClientRect(m_hwnd, &rcDlg);
  574. if (!m_cxFrameLast || !m_cyFrameLast)
  575. {
  576. m_cxFrameLast = rcDlg.right;
  577. m_cyFrameLast = rcDlg.bottom;
  578. return TRUE;
  579. }
  580. RECT rcCancel;
  581. GetWindowRect(_hCtrl(IDCANCEL), &rcCancel);
  582. SetWindowPos(_hCtrl(IDCANCEL),
  583. NULL,
  584. rcDlg.right - WindowRectWidth(rcCancel) - m_cxSeparation,
  585. rcDlg.bottom - WindowRectHeight(rcCancel) - m_cySeparation,
  586. 0,
  587. 0,
  588. SWP_NOSIZE
  589. | SWP_NOOWNERZORDER
  590. | SWP_NOCOPYBITS
  591. | SWP_NOZORDER);
  592. RECT rcOKWR;
  593. GetWindowRect(_hCtrl(IDOK), &rcOKWR);
  594. _GetChildWindowRect(_hCtrl(IDCANCEL), &rcCancel);
  595. SetWindowPos(_hCtrl(IDOK),
  596. NULL,
  597. rcCancel.left - WindowRectWidth(rcOKWR) - m_cxFour,
  598. rcDlg.bottom - WindowRectHeight(rcOKWR) - m_cySeparation,
  599. 0,
  600. 0,
  601. SWP_NOSIZE
  602. | SWP_NOCOPYBITS
  603. | SWP_NOZORDER);
  604. //
  605. // Advanced buttons so they its always at lower left
  606. // corner of dialog.
  607. //
  608. RECT rcAdvanced;
  609. _GetChildWindowRect(_hCtrl(IDC_ADVANCED_PB), &rcAdvanced);
  610. SetWindowPos(_hCtrl(IDC_ADVANCED_PB),
  611. NULL,
  612. rcAdvanced.left,
  613. rcDlg.bottom - WindowRectHeight(rcOKWR) - m_cySeparation,
  614. 0,
  615. 0,
  616. SWP_NOSIZE
  617. | SWP_NOCOPYBITS
  618. | SWP_NOZORDER);
  619. //
  620. // Move the check names, object types and Locations
  621. // buttons so their right edge stays aligned with right edge of Cancel
  622. // button.
  623. //
  624. //
  625. //check names button
  626. //
  627. RECT rcCheckNames;
  628. _GetChildWindowRect(_hCtrl(IDC_CHECK_NAMES_PB), &rcCheckNames);
  629. RECT rcCheckNamesWR;
  630. GetWindowRect(_hCtrl(IDC_CHECK_NAMES_PB), &rcCheckNamesWR);
  631. SetWindowPos(_hCtrl(IDC_CHECK_NAMES_PB),
  632. NULL,
  633. rcCancel.right - WindowRectWidth(rcCheckNamesWR),
  634. rcCheckNames.top,
  635. 0,
  636. 0,
  637. SWP_NOSIZE
  638. | SWP_NOCOPYBITS
  639. | SWP_NOZORDER);
  640. //
  641. //object types button
  642. //
  643. RECT rcObjectType;
  644. _GetChildWindowRect(_hCtrl(IDC_LOOK_FOR_PB), &rcObjectType);
  645. RECT rcObjectTypeWR;
  646. GetWindowRect(_hCtrl(IDC_LOOK_FOR_PB), &rcObjectTypeWR);
  647. SetWindowPos(_hCtrl(IDC_LOOK_FOR_PB),
  648. NULL,
  649. rcCancel.right - WindowRectWidth(rcObjectTypeWR),
  650. rcObjectType.top,
  651. 0,
  652. 0,
  653. SWP_NOSIZE
  654. | SWP_NOCOPYBITS
  655. | SWP_NOZORDER);
  656. //
  657. //Locations button
  658. //
  659. RECT rcLocations;
  660. _GetChildWindowRect(_hCtrl(IDC_LOOK_IN_PB), &rcLocations);
  661. RECT rcLocationsWR;
  662. GetWindowRect(_hCtrl(IDC_LOOK_IN_PB), &rcLocationsWR);
  663. SetWindowPos(_hCtrl(IDC_LOOK_IN_PB),
  664. NULL,
  665. rcCancel.right - WindowRectWidth(rcLocationsWR),
  666. rcLocations.top,
  667. 0,
  668. 0,
  669. SWP_NOSIZE
  670. | SWP_NOCOPYBITS
  671. | SWP_NOZORDER);
  672. //
  673. // resize look in and look for edit so its right edge is aligned with
  674. // left edge of checkname - minimum x separation
  675. //
  676. _GetChildWindowRect(_hCtrl(IDC_CHECK_NAMES_PB), &rcCheckNames);
  677. RECT rcLookInEdit;
  678. _GetChildWindowRect(_hCtrl(IDC_LOOK_IN_EDIT), &rcLookInEdit);
  679. SetWindowPos(_hCtrl(IDC_LOOK_IN_EDIT),
  680. NULL,
  681. 0,
  682. 0,
  683. rcCheckNames.left - rcLookInEdit.left - m_cxFour,
  684. rcLookInEdit.bottom - rcLookInEdit.top,
  685. SWP_NOMOVE
  686. | SWP_NOCOPYBITS
  687. | SWP_NOZORDER);
  688. RECT rcLookForEdit;
  689. _GetChildWindowRect(_hCtrl(IDC_LOOK_FOR_EDIT), &rcLookForEdit);
  690. SetWindowPos(_hCtrl(IDC_LOOK_FOR_EDIT),
  691. NULL,
  692. 0,
  693. 0,
  694. rcCheckNames.left - rcLookForEdit.left - m_cxFour,
  695. rcLookForEdit.bottom - rcLookForEdit.top,
  696. SWP_NOMOVE
  697. | SWP_NOCOPYBITS
  698. | SWP_NOZORDER);
  699. //
  700. // resize rich edit so its bottom edge is just above top of OK
  701. //
  702. RECT rcRichEdit;
  703. RECT rcOK;
  704. _GetChildWindowRect(_hCtrl(IDC_RICHEDIT), &rcRichEdit);
  705. _GetChildWindowRect(_hCtrl(IDOK), &rcOK);
  706. SetWindowPos(_hCtrl(IDC_RICHEDIT),
  707. NULL,
  708. 0,
  709. 0,
  710. rcCheckNames.left - rcRichEdit.left - m_cxFour,
  711. rcOK.top - rcRichEdit.top - m_cySeparation,
  712. SWP_NOMOVE
  713. | SWP_NOCOPYBITS
  714. | SWP_NOZORDER);
  715. //
  716. // Size gripper goes in bottom right corner
  717. //
  718. RECT rc;
  719. _GetChildWindowRect(_hCtrl(IDC_SIZEGRIP), &rc);
  720. SetWindowPos(_hCtrl(IDC_SIZEGRIP),
  721. NULL,
  722. nWidth - (rc.right - rc.left),
  723. nHeight - (rc.bottom - rc.top),
  724. 0,
  725. 0,
  726. SWP_NOSIZE
  727. | SWP_NOOWNERZORDER
  728. | SWP_NOZORDER);
  729. m_cxFrameLast = rcDlg.right;
  730. m_cyFrameLast = rcDlg.bottom;
  731. return FALSE;
  732. }
  733. //+--------------------------------------------------------------------------
  734. //
  735. // Member: CBaseDlg::_OnMinMaxInfo
  736. //
  737. // Synopsis: Enforce minimum window size
  738. //
  739. // Arguments: [lpmmi] - from WM_SIZE message
  740. //
  741. // Returns: FALSE if dialog has valid size constraints to return.
  742. //
  743. // History: 06-22-2000 DavidMun Created
  744. //
  745. //---------------------------------------------------------------------------
  746. BOOL
  747. CBaseDlg::_OnMinMaxInfo(
  748. LPMINMAXINFO lpmmi)
  749. {
  750. //
  751. // If we haven't gotten WM_INITDIALOG and set m_cxMin yet, we don't
  752. // know what the min size will be, so return nonzero to indicate we
  753. // didn't process this message.
  754. if (!m_cxMin)
  755. {
  756. return TRUE;
  757. }
  758. lpmmi->ptMinTrackSize.x = m_cxMin;
  759. lpmmi->ptMinTrackSize.y = m_cyMin;
  760. return FALSE;
  761. }
  762. //+--------------------------------------------------------------------------
  763. //
  764. // Member: CBaseDlg::_EditWndProc
  765. //
  766. // Synopsis: Subclassing window proc for rich edit control.
  767. //
  768. // Arguments: Standard Windows.
  769. //
  770. // Returns: Standard Windows.
  771. //
  772. // History: 4-20-1999 DavidMun Created
  773. //
  774. // Notes: If the user hits the Enter key and the OK button is enabled,
  775. // posts a press of that button to the main window.
  776. //
  777. // Forwards everything except VK_RETURN keys to rich edit
  778. // window proc.
  779. //
  780. //---------------------------------------------------------------------------
  781. LRESULT CALLBACK
  782. CBaseDlg::_EditWndProc(
  783. HWND hwnd,
  784. UINT msg,
  785. WPARAM wParam,
  786. LPARAM lParam)
  787. {
  788. LRESULT lResult = 0;
  789. BOOL fCallWinProc = TRUE;
  790. CBaseDlg *pThis =
  791. reinterpret_cast<CBaseDlg *>(GetWindowLongPtr(hwnd, GWLP_USERDATA));
  792. switch (msg)
  793. {
  794. case WM_KEYDOWN:
  795. if (wParam == VK_RETURN)
  796. {
  797. fCallWinProc = FALSE;
  798. }
  799. break;
  800. case WM_CHAR:
  801. if (wParam == VK_RETURN)
  802. {
  803. HWND hwndFrame = GetParent(hwnd);
  804. HWND hwndOK = GetDlgItem(hwndFrame, IDOK);
  805. if (IsWindowEnabled(hwndOK))
  806. {
  807. Dbg(DEB_TRACE, "CDsSelectDlg::_EditWndProc: Forwarding Return key\n");
  808. PostMessage(hwndFrame,
  809. WM_COMMAND,
  810. MAKEWPARAM(IDOK, BN_CLICKED),
  811. (LPARAM) hwndOK);
  812. }
  813. }
  814. break;
  815. }
  816. if (fCallWinProc)
  817. {
  818. lResult = CallWindowProc(pThis->m_OriginalRichEditWndProc,
  819. hwnd,
  820. msg,
  821. wParam,
  822. lParam);
  823. //
  824. // Prevent dialog manager from telling the edit control to select
  825. // all of its contents when the focus has moved into it. This is
  826. // necessary because otherwise tabbing into and out of the rich edit
  827. // makes it too easy to accidentally replace its contents with the
  828. // next addition.
  829. //
  830. if (msg == WM_GETDLGCODE)
  831. {
  832. lResult &= ~DLGC_HASSETSEL;
  833. }
  834. }
  835. return lResult;
  836. }
  837. //+--------------------------------------------------------------------------
  838. //
  839. // Member: CBaseDlg::_OnHelp
  840. //
  841. // Synopsis: Display context sensitive help for requested item
  842. //
  843. // Arguments: [message] -
  844. // [wParam] -
  845. // [lParam] -
  846. //
  847. // History: 10-15-1997 DavidMun Created
  848. //
  849. //---------------------------------------------------------------------------
  850. void
  851. CBaseDlg::_OnHelp(
  852. UINT message,
  853. WPARAM wParam,
  854. LPARAM lParam)
  855. {
  856. TRACE_METHOD(CBaseDlg, _OnHelp);
  857. InvokeWinHelp(message, wParam, lParam, c_wzHelpFilename, s_aulHelpIds);
  858. }