Source code of Windows XP (NT5)
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.

906 lines
26 KiB

  1. //+---------------------------------------------------------------------
  2. //
  3. // File: sinpl.cxx
  4. //
  5. // Contents: Implementation of the SrvrInPlace class
  6. //
  7. //------------------------------------------------------------------------
  8. #include "headers.hxx"
  9. #pragma hdrstop
  10. //+---------------------------------------------------------------
  11. //
  12. // Member: SrvrInPlace::SrvrInPlace, public
  13. //
  14. // Synopsis: Constructor for SrvrInPlace object
  15. //
  16. // Notes: To create a properly initialized object you must
  17. // call the Init method immediately after construction.
  18. //
  19. //---------------------------------------------------------------
  20. SrvrInPlace::SrvrInPlace(void)
  21. {
  22. DOUT(TEXT("SrvrInPlace: Constructing\r\n"));
  23. _hwnd = NULL;
  24. _pInPlaceSite = NULL;
  25. _frameInfo.cb = sizeof(OLEINPLACEFRAMEINFO);
  26. _pFrame = NULL;
  27. _pDoc = NULL;
  28. _hmenu = NULL;
  29. _hOleMenu = NULL;
  30. _hmenuShared = NULL;
  31. _fCSHelpMode = FALSE;
  32. _fChildActivating = FALSE;
  33. _fDeactivating = FALSE;
  34. _rcFrame.top = 0; _rcFrame.left = 0;
  35. _rcFrame.bottom = 0; _rcFrame.right = 0;
  36. _fClientResize = FALSE;
  37. _fUIDown = TRUE;
  38. }
  39. //+---------------------------------------------------------------
  40. //
  41. // Member: SrvrInPlace::Init, public
  42. //
  43. // Synopsis: Fully initializes a SrvrInPlace object
  44. //
  45. // Arguments: [pClass] -- The initialized class descriptor for the server
  46. // [pCtrl] -- The control subobject of the server we are a part of.
  47. //
  48. // Returns: NOERROR if successful
  49. //
  50. // Notes: The class descriptor pointer is saved in the protected _pClass
  51. // member variable where it is accessible during the lifetime
  52. // of the object.
  53. //
  54. //---------------------------------------------------------------
  55. HRESULT
  56. SrvrInPlace::Init(LPCLASSDESCRIPTOR pClass, LPSRVRCTRL pCtrl)
  57. {
  58. _pClass = pClass;
  59. _pCtrl = pCtrl;
  60. return NOERROR;
  61. }
  62. //+---------------------------------------------------------------
  63. //
  64. // Member: SrvrInPlace::~SrvrInPlace, protected
  65. //
  66. // Synopsis: Destructor for the SrvrCtrl object
  67. //
  68. // Notes: The destructor is called as a result of the servers
  69. // reference count going to 0. It releases all held
  70. // resources.
  71. //
  72. //---------------------------------------------------------------
  73. SrvrInPlace::~SrvrInPlace(void)
  74. {
  75. DOUT(TEXT("SrvrInPlace: Destructed\r\n"));
  76. }
  77. //+---------------------------------------------------------------
  78. //
  79. // Member: SrvrInPlace::ActivateInPlace, public
  80. //
  81. // Synopsis: In-place activates the object
  82. //
  83. // Arguments: [pClientSite] -- The site on our container
  84. //
  85. // Returns: Success if we in-place activated properly
  86. //
  87. // Notes: This method implements the standard in-place activation
  88. // protocol and creates the in-place window. It creates
  89. // all U.I. elements using CreateUI but does not
  90. // activate the U.I., for that is reserved for
  91. // the ActivateUI and InstallUI methods.
  92. //
  93. //---------------------------------------------------------------
  94. HRESULT
  95. SrvrInPlace::ActivateInPlace(LPOLECLIENTSITE pClientSite)
  96. {
  97. DOUT(TEXT("SrvrInPlace::ActivateInPlace\r\n"));
  98. if (pClientSite == NULL)
  99. {
  100. DOUT(TEXT("SrvrInPlace::ActivateInPlace E_INVALIDARG\r\n"));
  101. return E_INVALIDARG;
  102. }
  103. HWND hwndSite;
  104. RECT rect, rectVis;
  105. HRESULT hr;
  106. //
  107. // see if the client site supports in-place, and is willing to do so...
  108. //
  109. if (OK(hr = pClientSite->QueryInterface(IID_IOleInPlaceSite,
  110. (LPVOID FAR *)&_pInPlaceSite)))
  111. {
  112. if (OK(hr = _pInPlaceSite->CanInPlaceActivate()))
  113. {
  114. if (OK(hr = _pInPlaceSite->GetWindow(&hwndSite))
  115. && OK(hr = _pInPlaceSite->GetWindowContext(&_pFrame,
  116. &_pDoc,
  117. &rect,
  118. &rectVis,
  119. &_frameInfo)))
  120. {
  121. if ((_hwnd = AttachWin(hwndSite)) == NULL)
  122. {
  123. DOUT(TEXT("SrvrInPlace::ActivateInPlace failed at AttachWin\r\n"));
  124. hr = E_UNEXPECTED;
  125. }
  126. else
  127. {
  128. if (OK(hr = _pInPlaceSite->OnInPlaceActivate()))
  129. {
  130. if(_pCtrl->IsIPBEnabled())
  131. {
  132. _IPB.Bind(_pInPlaceSite, _hwnd, FALSE);
  133. }
  134. // create any U.I. elements
  135. CreateUI();
  136. // position and show the window
  137. SetObjectRects(&rect, &rectVis);
  138. ShowWindow(_hwnd, SW_SHOW);
  139. return NOERROR;
  140. //
  141. //The rest of this code cleans up after errors...
  142. //
  143. }
  144. DetachWin();
  145. }
  146. if (_pFrame != NULL)
  147. _pFrame->Release();
  148. if (_pDoc != NULL)
  149. _pDoc->Release();
  150. }
  151. }
  152. _pInPlaceSite->Release();
  153. }
  154. return hr;
  155. }
  156. //+---------------------------------------------------------------
  157. //
  158. // Member: SrvrInPlace::DeactivateInPlace, public
  159. //
  160. // Synopsis: In-place deactivates the object
  161. //
  162. // Returns: Success except for catastophic circumstances
  163. //
  164. // Notes: This method "undoes" everything done in ActivateInPlace
  165. // including destroying U.I. elements via DestroyUI, and
  166. // destroying the inplace active window.
  167. //
  168. //---------------------------------------------------------------
  169. HRESULT
  170. SrvrInPlace::DeactivateInPlace(void)
  171. {
  172. DOUT(TEXT("SrvrInPlace::DeactivateInPlace\r\n"));
  173. //
  174. // The following prevents some nasty recursion cases, in which the call
  175. // bellow to OnInPlaceDeactivate get's us back in to the same transition we
  176. // are in now...
  177. //
  178. _pCtrl->SetState(OS_RUNNING);
  179. // undo everything we did in InPlaceActivate
  180. if(_pCtrl->IsIPBEnabled())
  181. {
  182. _IPB.Detach();
  183. }
  184. DestroyUI();
  185. DetachWin();
  186. _pInPlaceSite->OnInPlaceDeactivate();
  187. if (_pFrame != NULL)
  188. _pFrame->Release();
  189. if (_pDoc != NULL)
  190. _pDoc->Release();
  191. // release the in-place site we were holding on to.
  192. _pInPlaceSite->Release();
  193. _pInPlaceSite = NULL;
  194. return NOERROR; // we never fail this function
  195. }
  196. //+---------------------------------------------------------------
  197. //
  198. // Member: SrvrInPlace::ActivateUI, public
  199. //
  200. // Synopsis: Notifies container of U.I. activation and installs our
  201. // U.I. elements.
  202. //
  203. // Returns: Success if our container granted permission to U.I. activate.
  204. //
  205. // Notes: Installing our U.I. (border toolbars, floating palettes,
  206. // adornments) is accomplished via a virtual call to InstallUI.
  207. //
  208. //---------------------------------------------------------------
  209. HRESULT
  210. SrvrInPlace::ActivateUI(void)
  211. {
  212. DOUT(TEXT("SrvrInPlace::ActivateUI\r\n"));
  213. HRESULT hr;
  214. if (OK(hr = _pInPlaceSite->OnUIActivate()))
  215. {
  216. InstallUI();
  217. if(!GetChildActivating() && !IsDeactivating())
  218. ReflectState(TRUE);
  219. }
  220. return hr;
  221. }
  222. //+---------------------------------------------------------------
  223. //
  224. // Member: SrvrInPlace::DeactivateUI, public
  225. //
  226. // Synopsis: Removes any U.I. we have installed and notifies our container
  227. // that we are no longer U.I. active
  228. //
  229. // Returns: Success except for catastrophic circumstances
  230. //
  231. // Notes: This method "undoes" everything done in ActivateUI.
  232. // U.I. elements are removed via a virtual call to RemoveUI
  233. //
  234. //---------------------------------------------------------------
  235. HRESULT
  236. SrvrInPlace::DeactivateUI(void)
  237. {
  238. DOUT(TEXT("SrvrInPlace::DeactivateUI\r\n"));
  239. //
  240. // The following prevents some nasty recursion cases, in which the call
  241. // bellow to OnUIDeactivate get's us back in to the same transition we
  242. // are in now...
  243. //
  244. _pCtrl->SetState(OS_INPLACE);
  245. // remove any UI that is up and notify our container that we have deactivated
  246. RemoveUI();
  247. _pInPlaceSite->OnUIDeactivate(FALSE);
  248. ReflectState(FALSE);
  249. //REVIEW: we should return TRUE if we add Undo capability.
  250. return NOERROR;
  251. }
  252. //+---------------------------------------------------------------
  253. //
  254. // Member: SrvrInPlace::InstallUI, public
  255. //
  256. // Synopsis: Installs previously created U.I. so it is displayed to
  257. // the user.
  258. //
  259. // Notes: This method will call the InstallFrameUI and InstallDocUI
  260. // methods to install those U.I. elements, respectively.
  261. //
  262. //---------------------------------------------------------------
  263. void
  264. SrvrInPlace::InstallUI(void)
  265. {
  266. DOUT(TEXT("SrvrInPlace::InstallUI\r\n"));
  267. if(!_fChildActivating && !_fDeactivating)
  268. {
  269. _pFrame->SetActiveObject((LPOLEINPLACEACTIVEOBJECT)this,
  270. _pClass->_szUserClassType[USERCLASSTYPE_SHORT]);
  271. InstallFrameUI();
  272. InstallDocUI();
  273. _fUIDown = FALSE;
  274. }
  275. }
  276. //+---------------------------------------------------------------
  277. //
  278. // Member: SrvrInPlace::RemoveUI, public
  279. //
  280. // Synopsis: Removes previously installed U.I. so it is hidden from the
  281. // the user.
  282. //
  283. // Notes: This method "undoes" everything done in InstallUI. It calls
  284. // the RemoveFrameUI and RemoveDocUI methods.
  285. //
  286. //---------------------------------------------------------------
  287. void
  288. SrvrInPlace::RemoveUI(void)
  289. {
  290. DOUT(TEXT("SrvrInPlace::RemoveUI\r\n"));
  291. if(!_fUIDown)
  292. {
  293. _fUIDown = TRUE;
  294. ClearSelection();
  295. RemoveDocUI();
  296. RemoveFrameUI();
  297. _pFrame->SetActiveObject(NULL, NULL);
  298. }
  299. }
  300. #ifdef DOCGEN // documentation for pure virtual function
  301. //+---------------------------------------------------------------
  302. //
  303. // Member: SrvrInPlace::AttachWin, public
  304. //
  305. // Synopsis: Attaches the child in-place window
  306. // to the given parent.
  307. //
  308. // Arguments: [hwndParent] -- parent window for child
  309. //
  310. // Returns: HWND of attached window
  311. //
  312. // Notes: All servers must override this method.
  313. //
  314. //---------------------------------------------------------------
  315. HWND SrvrInPlace::AttachWin(HWND hwndParent) {}
  316. #endif //DOCGEN
  317. //+--------------------------------------------------------------
  318. //
  319. // Member: SrvrInPlace::DetachWin, public
  320. //
  321. // Synopsis: Detaches the child's in-place
  322. // window from the current parent.
  323. //
  324. // Arguments: [hwndParent] -- parent window for child
  325. //
  326. // Notes: This destroys the _hwnd of the server.
  327. // If the derived class does anything
  328. // other than create a Window on AttachWin,
  329. // it must over-ride this function.
  330. // If the derived class destroys the window
  331. // on detach, it must set _hwnd = NULL
  332. //
  333. //---------------------------------------------------------------
  334. void
  335. SrvrInPlace::DetachWin()
  336. {
  337. DOUT(TEXT("SrvrInPlace::DetachWin\r\n"));
  338. Assert(_hwnd != NULL && IsWindow(_hwnd));
  339. DestroyWindow(_hwnd);
  340. _hwnd = NULL;
  341. }
  342. //+---------------------------------------------------------------
  343. //
  344. // Member: SrvrInPlace::CreateUI, protected
  345. //
  346. // Synopsis: Creates all U.I. elements
  347. //
  348. // Notes: This method uses information in the class descriptor
  349. // to create a merged menu and OLE menu descriptor.
  350. // Servers that have additional U.I. should override
  351. // this method, but can call the base class to do the
  352. // standard menu processing.
  353. //
  354. // IMPORTANT: The derived class is responsible for having
  355. // settup the _hmenu member prior to calling
  356. // this code.
  357. //
  358. //---------------------------------------------------------------
  359. void
  360. SrvrInPlace::CreateUI(void)
  361. {
  362. DOUT(TEXT("SrvrInPlace::CreateUI\r\n"));
  363. Assert(_hmenuShared == NULL);
  364. _fUIDown = TRUE;
  365. if (_hmenu != NULL)
  366. {
  367. // create an empty menu and ask application to insert its menus
  368. if ((_hmenuShared = CreateMenu()) != NULL)
  369. {
  370. // get a copy of our menu-group widths and perform the merge
  371. _mgw = _pClass->_mgw;
  372. if (OK(_pFrame->InsertMenus(_hmenuShared, &_mgw)))
  373. {
  374. // insert our own menus and create a descriptor for
  375. // the whole mess
  376. if (OK(InsertServerMenus(_hmenuShared, _hmenu, &_mgw)))
  377. _hOleMenu = OleCreateMenuDescriptor(_hmenuShared, &_mgw);
  378. }
  379. }
  380. }
  381. }
  382. //+---------------------------------------------------------------
  383. //
  384. // Member: SrvrInPlace::DestroyUI, protected
  385. //
  386. // Synopsis: Destroys U.I. elements
  387. //
  388. // Notes: This method "undoes" everything that was done in
  389. // CreateUI -- destroys the shared menu and OLE menu
  390. // descriptor. If a server overrides CreateUI then it
  391. // should also override this method.
  392. //
  393. //---------------------------------------------------------------
  394. void
  395. SrvrInPlace::DestroyUI(void)
  396. {
  397. DOUT(TEXT("SrvrInPlace::DestroyUI\r\n"));
  398. if (_hmenuShared != NULL)
  399. {
  400. OleDestroyMenuDescriptor(_hOleMenu);
  401. RemoveServerMenus(_hmenuShared, &_mgw);
  402. _pFrame->RemoveMenus(_hmenuShared);
  403. DestroyMenu(_hmenuShared);
  404. _hmenuShared = NULL;
  405. }
  406. }
  407. //+---------------------------------------------------------------
  408. //
  409. // Member: SrvrInPlace::InstallFrameUI, protected
  410. //
  411. // Synopsis: Installs the U.I. elements on the frame window
  412. //
  413. // Notes: This method uses IOleInPlaceFrame::SetMenu to install
  414. // the shared menu constructed in CreateUI. It also notifies
  415. // the frame that we are the active object.
  416. // Servers that have additional frame adornments should
  417. // override this method.
  418. // This method is called by the InstallUI method and
  419. // on document window activation for when we are in a MDI
  420. // an application.
  421. //
  422. //---------------------------------------------------------------
  423. void
  424. SrvrInPlace::InstallFrameUI(void)
  425. {
  426. DOUT(TEXT("SrvrInPlace::InstallFrameUI\r\n"));
  427. _pFrame->SetMenu(_hmenuShared, _hOleMenu, _hwnd);
  428. }
  429. //+---------------------------------------------------------------
  430. //
  431. // Member: SrvrInPlace::RemoveFrameUI, protected
  432. //
  433. // Synopsis: Removes the U.I. elements on the frame window
  434. //
  435. // Notes: This method "undoes" everything that was done in
  436. // InstallFrameUI -- it removes the shared menu from
  437. // the frame.
  438. // Servers that override the InstallFrameUI method will
  439. // also want to override this method.
  440. // This method is call by the RemoveUI method and on
  441. // document window deactivation for MDI-application purposes.
  442. //
  443. //---------------------------------------------------------------
  444. void
  445. SrvrInPlace::RemoveFrameUI(void)
  446. {
  447. DOUT(TEXT("SrvrInPlace::RemoveFrameUI\r\n"));
  448. _pFrame->SetMenu(NULL, NULL, _hwnd);
  449. }
  450. //+---------------------------------------------------------------
  451. //
  452. // Member: SrvrInPlace::InstallDocUI, protected
  453. //
  454. // Synopsis: Installs the U.I. elements on the document window
  455. //
  456. // Notes: This method notifies the document window that we are
  457. // the active object. Otherwise, there are no standard U.I. elements
  458. // installed on the document window.
  459. // Servers that have document window tools should override this
  460. // method.
  461. //
  462. //---------------------------------------------------------------
  463. void
  464. SrvrInPlace::InstallDocUI(void)
  465. {
  466. DOUT(TEXT("SrvrInPlace::InstallDocUI\r\n"));
  467. if (_pDoc != NULL)
  468. {
  469. DOUT(TEXT("SrvrInPlace::InstallDocUI (_pDoc != NULL)\r\n"));
  470. _pDoc->SetActiveObject((LPOLEINPLACEACTIVEOBJECT)this,
  471. _pClass->_szUserClassType[USERCLASSTYPE_SHORT]);
  472. }
  473. }
  474. //+---------------------------------------------------------------
  475. //
  476. // Member: SrvrInPlace::RemoveDocUI, protected
  477. //
  478. // Synopsis: Removes the U.I. elements from the document window.
  479. //
  480. // Notes: This method "undoes" everything done in the InstallDocUI
  481. // method.
  482. // Servers that override the InstallDocUI method should
  483. // also override this method.
  484. //
  485. //---------------------------------------------------------------
  486. void
  487. SrvrInPlace::RemoveDocUI(void)
  488. {
  489. DOUT(TEXT("SrvrInPlace::RemoveDocUI\r\n"));
  490. if (_pDoc != NULL)
  491. {
  492. _pDoc->SetActiveObject(NULL, NULL);
  493. }
  494. }
  495. //+---------------------------------------------------------------
  496. //
  497. // Member: SrvrInPlace::ClearSelection
  498. //
  499. // Synopsis: Removes any selection because we have lost ownership of the U.I.
  500. //
  501. // Notes: When our container or an embedding steals the right to put
  502. // up the U.I. then we should remove any selection to avoid
  503. // confusing the user.
  504. //
  505. //---------------------------------------------------------------
  506. void
  507. SrvrInPlace::ClearSelection(void)
  508. {
  509. DOUT(TEXT("SrvrInPlace::ClearSelection\r\n"));
  510. }
  511. //+---------------------------------------------------------------
  512. //
  513. // Member: SrvrInPlace::SetFocus, public
  514. //
  515. // Synopsis: Overide in derived if focus-window != _hwnd
  516. //
  517. //---------------------------------------------------------------
  518. void
  519. SrvrInPlace::SetFocus(HWND hwnd)
  520. {
  521. ::SetFocus(hwnd);
  522. }
  523. //+---------------------------------------------------------------
  524. //
  525. // Member: SrvrInPlace::GetWindow, public
  526. //
  527. // Synopsis: Method of IOleWindow interface
  528. //
  529. //---------------------------------------------------------------
  530. STDMETHODIMP
  531. SrvrInPlace::GetWindow(HWND FAR* lphwnd)
  532. {
  533. if (lphwnd == NULL)
  534. {
  535. DOUT(TEXT("SrvrInPlace::GetWindow E_INVALIDARG\r\n"));
  536. return E_INVALIDARG;
  537. }
  538. *lphwnd = _hwnd;
  539. return NOERROR;
  540. }
  541. //+---------------------------------------------------------------
  542. //
  543. // Member: SrvrInPlace::ContextSensitiveHelp, public
  544. //
  545. // Synopsis: Method of IOleWindow interface
  546. //
  547. // Notes: This method sets or clears the _fCSHelpMode
  548. // member flag. The window procedure needs to pay
  549. // attention to the value of this flag in implementing
  550. // context-sensitive help.
  551. //
  552. // We never fail!
  553. //
  554. //---------------------------------------------------------------
  555. STDMETHODIMP
  556. SrvrInPlace::ContextSensitiveHelp(BOOL fEnterMode)
  557. {
  558. DOUT(TEXT("SrvrInPlace::ContextSensitiveHelp\r\n"));
  559. _fCSHelpMode = fEnterMode;
  560. return NOERROR;
  561. }
  562. //+---------------------------------------------------------------
  563. //
  564. // Member: SrvrInPlace::InPlaceDeactivate, public
  565. //
  566. // Synopsis: Method of IOleInPlaceObject interface
  567. //
  568. // Notes: This method transitions the object to the loaded state
  569. // if the object is in the InPlace or U.I. active state.
  570. //
  571. // We never fail!
  572. //
  573. //---------------------------------------------------------------
  574. STDMETHODIMP
  575. SrvrInPlace::InPlaceDeactivate(void)
  576. {
  577. DOUT(TEXT("SrvrInPlace::InPlaceDeactivate\r\n"));
  578. if (_pCtrl->State() == OS_INPLACE || _pCtrl->State() == OS_UIACTIVE)
  579. {
  580. _pCtrl->TransitionTo(OS_LOADED);
  581. }
  582. return NOERROR;
  583. }
  584. //+---------------------------------------------------------------
  585. //
  586. // Member: SrvrInPlace::UIDeactivate, public
  587. //
  588. // Synopsis: Method of IOleInPlaceObject interface
  589. //
  590. // Notes: The method transitions the object to the in-place state
  591. // if the object is in U.I. active state.
  592. //
  593. // We never fail!
  594. //
  595. //---------------------------------------------------------------
  596. STDMETHODIMP
  597. SrvrInPlace::UIDeactivate(void)
  598. {
  599. DOUT(TEXT("SrvrInPlace::UIDeactivate\r\n"));
  600. if (_pCtrl->State() == OS_UIACTIVE)
  601. {
  602. _fDeactivating = TRUE;
  603. _pCtrl->TransitionTo(OS_INPLACE);
  604. _fDeactivating = FALSE;
  605. }
  606. return NOERROR;
  607. }
  608. //+---------------------------------------------------------------
  609. //
  610. // Member: SrvrInPlace::SetObjectRects, public
  611. //
  612. // Synopsis: Method of IOleInPlaceObject interface
  613. //
  614. // Notes: This method does a Move window on the child
  615. // window to put it in its new position.
  616. //
  617. //---------------------------------------------------------------
  618. STDMETHODIMP
  619. SrvrInPlace::SetObjectRects(LPCRECT lprcPos, LPCRECT lprcVisRect)
  620. {
  621. DOUT(TEXT("SrvrInPlace::SetObjectRects\r\n"));
  622. if (lprcPos == NULL || lprcVisRect == NULL)
  623. {
  624. DOUT(TEXT("SrvrInPlace::SetObjectRects E_INVALIDARG\r\n"));
  625. return E_INVALIDARG;
  626. }
  627. _fClientResize = TRUE; //indicate that we are being resized by client
  628. //
  629. // calculate and do the new child window positioning
  630. //
  631. RECT rc = *lprcPos;
  632. if(_pCtrl->IsIPBEnabled())
  633. {
  634. _IPB.SetSize(_hwnd, rc);
  635. }
  636. else
  637. {
  638. SetWindowPos( _hwnd, NULL, rc.left, rc.top,
  639. rc.right - rc.left, rc.bottom - rc.top,
  640. SWP_NOZORDER);
  641. }
  642. //
  643. // update our border rect (child window coordinates)
  644. //
  645. _rcFrame.right = rc.right - rc.left;
  646. _rcFrame.bottom = rc.bottom - rc.top;
  647. //
  648. // update our "native" extent
  649. //
  650. SIZEL sizel = { HimetricFromHPix(_rcFrame.right - _rcFrame.left),
  651. HimetricFromVPix(_rcFrame.bottom - _rcFrame.top) };
  652. _pCtrl->SetExtent(DVASPECT_CONTENT, &sizel);
  653. _fClientResize = FALSE; // indicate that client resize is over
  654. return NOERROR;
  655. }
  656. //+---------------------------------------------------------------
  657. //
  658. // Member: SrvrInPlace::ReactivateAndUndo, public
  659. //
  660. // Synopsis: Method of IOleInPlaceObject interface
  661. //
  662. // Notes: This method returns E_FAIL. If the server wishes
  663. // to support undo it should override this method.
  664. //
  665. //---------------------------------------------------------------
  666. STDMETHODIMP
  667. SrvrInPlace::ReactivateAndUndo(void)
  668. {
  669. DOUT(TEXT("SrvrInPlace::ReactivateAndUndo E_NOTIMPL\r\n"));
  670. return E_NOTIMPL;
  671. }
  672. //+---------------------------------------------------------------
  673. //
  674. // Member: SrvrInPlace::TranslateAccelerator, public
  675. //
  676. // Synopsis: Method of IOleInPlaceActiveObject interface
  677. //
  678. // Notes: This method translates the message according
  679. // to the accelerator table in the class descriptor
  680. // structure.
  681. //
  682. //---------------------------------------------------------------
  683. STDMETHODIMP
  684. SrvrInPlace::TranslateAccelerator(LPMSG lpmsg)
  685. {
  686. //
  687. // translate the message via the SrvrInPlace accelerator table
  688. //
  689. if (_pClass->_haccel &&
  690. ::TranslateAccelerator(_hwnd, _pClass->_haccel, lpmsg))
  691. {
  692. return NOERROR;
  693. }
  694. return S_FALSE;
  695. }
  696. //+---------------------------------------------------------------
  697. //
  698. // Member: SrvrInPlace::OnFrameWindowActivate, public
  699. //
  700. // Synopsis: Method of IOleInPlaceObject interface
  701. //
  702. // Notes: This method changes the color of our border shading
  703. // depending on whether our frame window is activating
  704. // or deactivating.
  705. //
  706. //---------------------------------------------------------------
  707. STDMETHODIMP
  708. SrvrInPlace::OnFrameWindowActivate(BOOL fActivate)
  709. {
  710. DOUT(TEXT("SrvrInPlace::OnFrameWindowActivate\r\n"));
  711. if(_pCtrl->IsIPBEnabled())
  712. _IPB.SetParentActive(fActivate);
  713. if(fActivate && _hwnd && (_pCtrl->State() != OS_OPEN))
  714. SetFocus(_hwnd);
  715. return NOERROR;
  716. }
  717. //+---------------------------------------------------------------
  718. //
  719. // Member: SrvrInPlace::OnDocWindowActivate, public
  720. //
  721. // Synopsis: Method of IOleInPlaceObject interface
  722. //
  723. // Notes: This method will install or remove the frame
  724. // U.I. elements using the InstallFrameUI or RemoveFrameUI
  725. // methods. This is to properly handle the MDI application
  726. // case. It also updates our shading color.
  727. //
  728. //---------------------------------------------------------------
  729. STDMETHODIMP
  730. SrvrInPlace::OnDocWindowActivate(BOOL fActivate)
  731. {
  732. DOUT(TEXT("SrvrInPlace::OnDocWindowActivate\r\n"));
  733. if (fActivate)
  734. {
  735. InstallFrameUI();
  736. SetFocus(_hwnd);
  737. }
  738. else if (!fActivate)
  739. RemoveFrameUI();
  740. if(_pCtrl->IsIPBEnabled())
  741. _IPB.SetParentActive(fActivate);
  742. return NOERROR;
  743. }
  744. //+---------------------------------------------------------------
  745. //
  746. // Member: SrvrInPlace::ResizeBorder, public
  747. //
  748. // Synopsis: Method of IOleInPlaceObject interface
  749. //
  750. // Notes: There are no standard border adornments so we do
  751. // nothing in this method. Servers that have additional
  752. // U.I. elements that are installed on the frame or
  753. // document windows should override this method.
  754. //
  755. //---------------------------------------------------------------
  756. STDMETHODIMP
  757. SrvrInPlace::ResizeBorder(LPCRECT lprc,
  758. LPOLEINPLACEUIWINDOW pUIWindow,
  759. BOOL fFrameWindow)
  760. {
  761. DOUT(TEXT("SrvrInPlace::ResizeBorder\r\n"));
  762. // we do not install any tools on our frame or document windows.
  763. //REVIEW: This must be implemented if we do implement a frame or document
  764. //REVIEW: toolbar.
  765. return NOERROR;
  766. }
  767. //+---------------------------------------------------------------
  768. //
  769. // Member: SrvrInPlace::EnableModeless, public
  770. //
  771. // Synopsis: Method of IOleInPlaceObject interface
  772. //
  773. // Notes: If we are a DLL and hence don't have a separate
  774. // message pump we can ignore this call and simply
  775. // return NOERROR.
  776. //
  777. //---------------------------------------------------------------
  778. STDMETHODIMP
  779. SrvrInPlace::EnableModeless(BOOL fEnable)
  780. {
  781. DOUT(TEXT("SrvrInPlace::EnableModeless\r\n"));
  782. return NOERROR;
  783. }
  784.