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.

576 lines
14 KiB

  1. //**********************************************************************
  2. // File name: IOIPS.CPP
  3. //
  4. // Implementation file for COleInPlaceSite
  5. //
  6. // Functions:
  7. //
  8. // See IOIPS.H for class Definition
  9. //
  10. // Copyright (c) 1992 - 1996 Microsoft Corporation. All rights reserved.
  11. //**********************************************************************
  12. #include "pre.h"
  13. //**********************************************************************
  14. //
  15. // CConnWizSite::COleInPlaceSite::QueryInterface
  16. //
  17. // Purpose:
  18. //
  19. // Used for interface negotiation at the interface level.
  20. //
  21. // Parameters:
  22. //
  23. // REFIID riid - A reference to the interface that is
  24. // being queried.
  25. //
  26. // LPVOID FAR* ppvObj - An out parameter to return a pointer to
  27. // the interface.
  28. //
  29. // Return Value:
  30. //
  31. // S_OK - The interface is supported.
  32. // S_FALSE - The interface is not supported
  33. //
  34. // Function Calls:
  35. // Function Location
  36. //
  37. // CConnWizSite::QueryInterface SITE.CPP
  38. //
  39. // Comments:
  40. //
  41. //********************************************************************
  42. STDMETHODIMP COleInPlaceSite::QueryInterface(REFIID riid, LPVOID FAR* ppvObj)
  43. {
  44. TraceMsg(TF_GENERAL, "In IOIPS::QueryInterface\r\n");
  45. // delegate to the container Site
  46. return m_pSite->QueryInterface(riid, ppvObj);
  47. }
  48. //**********************************************************************
  49. //
  50. // CConnWizSite::COleInPlaceSite::AddRef
  51. //
  52. // Purpose:
  53. //
  54. // Adds to the reference count at the interface level.
  55. //
  56. // Parameters:
  57. //
  58. // None
  59. //
  60. // Return Value:
  61. //
  62. // ULONG - The new reference count of the interface.
  63. //
  64. // Function Calls:
  65. // Function Location
  66. //
  67. //
  68. // Comments:
  69. //
  70. //********************************************************************
  71. STDMETHODIMP_(ULONG) COleInPlaceSite::AddRef()
  72. {
  73. TraceMsg(TF_GENERAL, "In IOIPS::AddRef\r\n");
  74. // increment the interface reference count (for debugging only)
  75. ++m_nCount;
  76. // delegate to the container Site
  77. return m_pSite->AddRef();
  78. }
  79. //**********************************************************************
  80. //
  81. // CConnWizSite::COleInPlaceSite::Release
  82. //
  83. // Purpose:
  84. //
  85. // Decrements the reference count at this level
  86. //
  87. // Parameters:
  88. //
  89. // None
  90. //
  91. // Return Value:
  92. //
  93. // ULONG - The new reference count of the interface.
  94. //
  95. // Function Calls:
  96. // Function Location
  97. //
  98. // CConnWizSite::Release SITE.CPP
  99. //
  100. // Comments:
  101. //
  102. //********************************************************************
  103. STDMETHODIMP_(ULONG) COleInPlaceSite::Release()
  104. {
  105. TraceMsg(TF_GENERAL, "In IOIPS::Release\r\n");
  106. // decrement the interface reference count (for debugging only)
  107. m_nCount--;
  108. // delegate to the container Site
  109. return m_pSite->Release();
  110. }
  111. //**********************************************************************
  112. //
  113. // COleInPlaceSite::GetWindow
  114. //
  115. // Purpose:
  116. //
  117. // Returns the Window Handle of the client site
  118. //
  119. // Parameters:
  120. //
  121. // HWND FAR* lphwnd - place to return the handle
  122. //
  123. // Return Value:
  124. //
  125. // S_OK
  126. //
  127. // Function Calls:
  128. // Function Location
  129. //
  130. // ResultFromScode OLE API
  131. //
  132. // Comments:
  133. //
  134. //********************************************************************
  135. STDMETHODIMP COleInPlaceSite::GetWindow (HWND FAR* lphwnd)
  136. {
  137. TraceMsg(TF_GENERAL, "In IOIPS::GetWindow\r\n");
  138. // return the handle to our editing window.
  139. *lphwnd = m_pSite->m_hWnd;
  140. return ResultFromScode(S_OK);
  141. }
  142. //**********************************************************************
  143. //
  144. // COleInPlaceSite::ContextSensitiveHelp
  145. //
  146. // Purpose:
  147. //
  148. //
  149. // Parameters:
  150. //
  151. // BOOL fEnterMode - TRUE for entering Context Sensitive help mode
  152. //
  153. // Return Value:
  154. //
  155. // S_OK
  156. //
  157. // Function Calls:
  158. // Function Location
  159. //
  160. // ResultFromScode OLE API
  161. //
  162. // Comments:
  163. //
  164. // Be sure to read the technotes included with the OLE toolkit.
  165. //
  166. //********************************************************************
  167. STDMETHODIMP COleInPlaceSite::ContextSensitiveHelp (BOOL fEnterMode)
  168. {
  169. TraceMsg(TF_GENERAL, "In IOIPS::ContextSensitiveHelp\r\n");
  170. return ResultFromScode(S_OK);
  171. }
  172. //**********************************************************************
  173. //
  174. // COleInPlaceSite::CanInPlaceActivate
  175. //
  176. // Purpose:
  177. //
  178. // Object calls to find out if the container can InPlace activate
  179. //
  180. // Parameters:
  181. //
  182. // None
  183. //
  184. // Return Value:
  185. //
  186. // S_OK
  187. //
  188. // Function Calls:
  189. // Function Location
  190. //
  191. // ResultFromScode OLE API
  192. //
  193. // Comments:
  194. //
  195. //********************************************************************
  196. STDMETHODIMP COleInPlaceSite::CanInPlaceActivate ()
  197. {
  198. TraceMsg(TF_GENERAL, "In IOIPS::CanInPlaceActivate\r\n");
  199. return ResultFromScode(S_OK);
  200. }
  201. //**********************************************************************
  202. //
  203. // COleInPlaceSite::OnInPlaceActivate
  204. //
  205. // Purpose:
  206. //
  207. // Called by the object on InPlace Activation
  208. //
  209. // Parameters:
  210. //
  211. // None
  212. //
  213. // Return Value:
  214. //
  215. // S_OK
  216. //
  217. // Function Calls:
  218. // Function Location
  219. //
  220. // ResultFromScode OLE API
  221. //
  222. // Comments:
  223. //
  224. //********************************************************************
  225. STDMETHODIMP COleInPlaceSite::OnInPlaceActivate ()
  226. {
  227. HRESULT hrErr;
  228. TraceMsg(TF_GENERAL, "In IOIPS::OnInPlaceActivate\r\n");
  229. hrErr = m_pSite->m_lpOleObject->QueryInterface(
  230. IID_IOleInPlaceObject, (LPVOID FAR *)&m_pSite->m_lpInPlaceObject);
  231. if (hrErr != NOERROR)
  232. return ResultFromScode(E_FAIL);
  233. // return S_OK to indicate we can in-place activate.
  234. return ResultFromScode(S_OK);
  235. }
  236. //**********************************************************************
  237. //
  238. // COleInPlaceSite::OnUIActivate
  239. //
  240. // Purpose:
  241. //
  242. // Object calls this method when it displays it's UI.
  243. //
  244. // Parameters:
  245. //
  246. // None.
  247. //
  248. // Return Value:
  249. //
  250. // S_OK
  251. //
  252. // Function Calls:
  253. // Function Location
  254. //
  255. // ResultFromScode OLE API
  256. //
  257. // Comments:
  258. //
  259. //********************************************************************
  260. STDMETHODIMP COleInPlaceSite::OnUIActivate ()
  261. {
  262. TraceMsg(TF_GENERAL, "In IOIPS::OnUIActivate\r\n");
  263. // m_pSite->m_lpDoc->m_fAddMyUI=FALSE;
  264. // m_pSite->m_lpDoc->m_fInPlaceActive = TRUE;
  265. m_pSite->m_fInPlaceActive = TRUE;
  266. m_pSite->m_lpInPlaceObject->GetWindow((HWND FAR*)&m_pSite->m_hwndIPObj);
  267. // return S_OK to continue in-place activation
  268. return ResultFromScode(S_OK);
  269. }
  270. //**********************************************************************
  271. //
  272. // COleInPlaceSite::GetWindowContext
  273. //
  274. // Purpose:
  275. //
  276. // Called by the object to get information for InPlace Negotiation.
  277. //
  278. // Parameters:
  279. //
  280. // LPOLEINPLACEFRAME FAR* lplpFrame - Location to return a pointer
  281. // to IOleInPlaceFrame.
  282. //
  283. // LPOLEINPLACEUIWINDOW FAR* lplpDoc - Location to return a pointer
  284. // to IOleInPlaceUIWindow.
  285. //
  286. // LPRECT lprcPosRect - The rect that the object
  287. // occupies
  288. //
  289. // LPRECT lprcClipRect - The clipping rect
  290. //
  291. // LPOLEINPLACEFRAMEINFO lpFrameInfo - Pointer to FRAMEINFO
  292. //
  293. //
  294. // Return Value:
  295. //
  296. // S_OK
  297. //
  298. // Function Calls:
  299. // Function Location
  300. //
  301. // COleInPlaceFrame::AddRef IOIPF.CPP
  302. // CConnWizSite::GetObjRect SITE.CPP
  303. // SetMapMode Windows API
  304. // GetDC Windows API
  305. // ReleaseDC Windows API
  306. // CopyRect Windows API
  307. // GetClientRect Windows API
  308. // ResultFromScode OLE API
  309. //
  310. // Comments:
  311. //
  312. //********************************************************************
  313. STDMETHODIMP COleInPlaceSite::GetWindowContext (LPOLEINPLACEFRAME FAR* lplpFrame,
  314. LPOLEINPLACEUIWINDOW FAR* lplpDoc,
  315. LPRECT lprcPosRect,
  316. LPRECT lprcClipRect,
  317. LPOLEINPLACEFRAMEINFO lpFrameInfo)
  318. {
  319. RECT rect;
  320. TraceMsg(TF_GENERAL, "In IOIPS::GetWindowContext\r\n");
  321. // the frame is associated with the application object.
  322. // need to AddRef() it...
  323. m_pSite->m_OleInPlaceFrame.AddRef();
  324. *lplpFrame = &m_pSite->m_OleInPlaceFrame;
  325. *lplpDoc = NULL; // must be NULL, cause we're SDI.
  326. // get the size of the object in pixels
  327. m_pSite->GetObjRect(&rect);
  328. // Copy this to the passed buffer
  329. CopyRect(lprcPosRect, &rect);
  330. // fill the clipping region
  331. GetClientRect(m_pSite->m_hWnd, &rect);
  332. CopyRect(lprcClipRect, &rect);
  333. // fill the FRAMEINFO
  334. lpFrameInfo->fMDIApp = FALSE;
  335. lpFrameInfo->hwndFrame = m_pSite->m_hWnd;
  336. lpFrameInfo->haccel = NULL;
  337. lpFrameInfo->cAccelEntries = 0;
  338. return ResultFromScode(S_OK);
  339. }
  340. //**********************************************************************
  341. //
  342. // COleInPlaceSite::Scroll
  343. //
  344. // Purpose:
  345. //
  346. // Not Implemented
  347. //
  348. // Parameters:
  349. //
  350. // Not Implemented
  351. //
  352. // Return Value:
  353. //
  354. // Not Implemented
  355. //
  356. // Function Calls:
  357. // Function Location
  358. //
  359. //
  360. // Comments:
  361. //
  362. // Not Implemented
  363. //
  364. //********************************************************************
  365. STDMETHODIMP COleInPlaceSite::Scroll (SIZE scrollExtent)
  366. {
  367. TraceMsg(TF_GENERAL, "In IOIPS::Scroll\r\n");
  368. return ResultFromScode(E_FAIL);
  369. }
  370. //**********************************************************************
  371. //
  372. // COleInPlaceSite::OnUIDeactivate
  373. //
  374. // Purpose:
  375. //
  376. // Called by the object when its UI goes away
  377. //
  378. // Parameters:
  379. //
  380. // BOOL fUndoable
  381. //
  382. // Return Value:
  383. //
  384. // S_OK
  385. //
  386. // Function Calls:
  387. // Function Location
  388. //
  389. // CConnWizAPP::AddFrameLevelUI APP.CPP
  390. // ResultFromScode OLE API
  391. //
  392. // Comments:
  393. //
  394. //********************************************************************
  395. STDMETHODIMP COleInPlaceSite::OnUIDeactivate (BOOL fUndoable)
  396. {
  397. // need to clear this flag first
  398. m_pSite->m_fInPlaceActive = FALSE;
  399. return ResultFromScode(S_OK);
  400. }
  401. //**********************************************************************
  402. //
  403. // COleInPlaceSite::OnInPlaceDeactivate
  404. //
  405. // Purpose:
  406. //
  407. // Called when the inplace session is over
  408. //
  409. // Parameters:
  410. //
  411. // None
  412. //
  413. // Return Value:
  414. //
  415. // S_OK
  416. //
  417. // Function Calls:
  418. // Function Location
  419. //
  420. // ResultFromScode OLE API
  421. //
  422. // Comments:
  423. //
  424. //********************************************************************
  425. STDMETHODIMP COleInPlaceSite::OnInPlaceDeactivate ()
  426. {
  427. if (m_pSite->m_lpInPlaceObject) {
  428. m_pSite->m_lpInPlaceObject->Release();
  429. m_pSite->m_lpInPlaceObject = NULL;
  430. }
  431. return ResultFromScode(S_OK);
  432. }
  433. //**********************************************************************
  434. //
  435. // COleInPlaceSite::DiscardUndoState
  436. //
  437. // Purpose:
  438. //
  439. // Not Implemented
  440. //
  441. // Parameters:
  442. //
  443. // Not Implemented
  444. //
  445. // Return Value:
  446. //
  447. // Not Implemented
  448. //
  449. // Function Calls:
  450. // Function Location
  451. //
  452. //
  453. // Comments:
  454. //
  455. // Not Implemented
  456. //
  457. //********************************************************************
  458. STDMETHODIMP COleInPlaceSite::DiscardUndoState ()
  459. {
  460. TraceMsg(TF_GENERAL, "In IOIPS::DiscardUndoState\r\n");
  461. return ResultFromScode(E_FAIL);
  462. }
  463. //**********************************************************************
  464. //
  465. // COleInPlaceSite::DeactivateAndUndo
  466. //
  467. // Purpose:
  468. //
  469. // Not Implemented
  470. //
  471. // Parameters:
  472. //
  473. // Not Implemented
  474. //
  475. // Return Value:
  476. //
  477. // Not Implemented
  478. //
  479. // Function Calls:
  480. // Function Location
  481. //
  482. //
  483. // Comments:
  484. //
  485. // Not Implemented
  486. //
  487. //********************************************************************
  488. STDMETHODIMP COleInPlaceSite::DeactivateAndUndo ()
  489. {
  490. TraceMsg(TF_GENERAL, "In IOIPS::DeactivateAndUndo\r\n");
  491. return ResultFromScode(E_FAIL);
  492. }
  493. //**********************************************************************
  494. //
  495. // COleInPlaceSite::OnPosRectChange
  496. //
  497. // Purpose:
  498. //
  499. // The object calls this method when it's size changes during an
  500. // InPlace Session
  501. //
  502. // Parameters:
  503. //
  504. // LPCRECT lprcPosRect - The new object rect
  505. //
  506. // Return Value:
  507. //
  508. // S_OK
  509. //
  510. // Function Calls:
  511. // Function Location
  512. //
  513. // GetClientRect Windows API
  514. // IOleObject::GetExtent Object
  515. // IOleObject::QueryInterface Object
  516. // IOleInPlaceObject::SetObjectRects Object
  517. // IOleInPlaceObject::Release Object
  518. // ResultFromScode OLE API
  519. //
  520. // Comments:
  521. //
  522. //********************************************************************
  523. STDMETHODIMP COleInPlaceSite::OnPosRectChange (LPCRECT lprcPosRect)
  524. {
  525. return ResultFromScode(S_OK);
  526. }