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.

852 lines
24 KiB

  1. //**********************************************************************
  2. // File name: app.cpp
  3. //
  4. // Implementation file for the CSimpleApp Class
  5. //
  6. // Functions:
  7. //
  8. // See app.h for a list of member functions.
  9. //
  10. // Copyright (c) 1992 - 1993 Microsoft Corporation. All rights reserved.
  11. //**********************************************************************
  12. #include "pre.h"
  13. #include "iocs.h"
  14. #include "ias.h"
  15. #include "app.h"
  16. #include "site.h"
  17. #include "doc.h"
  18. #include <testmess.h>
  19. #ifdef WIN32
  20. extern INT_PTR CALLBACK About(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam);
  21. #endif
  22. //**********************************************************************
  23. //
  24. // CSimpleApp::CSimpleApp()
  25. //
  26. // Purpose:
  27. //
  28. // Constructor for CSimpleApp
  29. //
  30. // Parameters:
  31. //
  32. // None
  33. //
  34. // Return Value:
  35. //
  36. // None
  37. //
  38. // Function Calls:
  39. // Function Location
  40. //
  41. // TestDebugOut Windows API
  42. //
  43. //********************************************************************
  44. CSimpleApp::CSimpleApp()
  45. {
  46. TestDebugOut("In CSimpleApp's Constructor \r\n");
  47. // Set Ref Count
  48. m_nCount = 0;
  49. // clear members
  50. m_hAppWnd = NULL;
  51. m_hInst = NULL;
  52. m_lpDoc = NULL;
  53. // clear flags
  54. m_fInitialized = FALSE;
  55. // Initialize effects we allow.
  56. m_dwSourceEffect = DROPEFFECT_COPY | DROPEFFECT_MOVE;
  57. m_dwTargetEffect = DROPEFFECT_COPY | DROPEFFECT_MOVE;
  58. }
  59. //**********************************************************************
  60. //
  61. // CSimpleApp::~CSimpleApp()
  62. //
  63. // Purpose:
  64. //
  65. // Destructor for CSimpleApp Class.
  66. //
  67. // Parameters:
  68. //
  69. // None
  70. //
  71. // Return Value:
  72. //
  73. // None
  74. //
  75. // Function Calls:
  76. // Function Location
  77. //
  78. // OutdebugString Windows API
  79. // OleUninitialize OLE API
  80. //
  81. //
  82. //********************************************************************
  83. CSimpleApp::~CSimpleApp()
  84. {
  85. TestDebugOut("In CSimpleApp's Destructor\r\n");
  86. // need to uninit the library...
  87. if (m_fInitialized)
  88. OleUninitialize();
  89. }
  90. //**********************************************************************
  91. //
  92. // CSimpleApp::DestroyDocs()
  93. //
  94. // Purpose:
  95. //
  96. // Destroys all of the open documents in the application (Only one
  97. // since this is an SDI app, but could easily be modified to
  98. // support MDI).
  99. //
  100. // Parameters:
  101. //
  102. // None
  103. //
  104. // Return Value:
  105. //
  106. // None
  107. //
  108. // Function Calls:
  109. // Function Location
  110. //
  111. // CSimpleDoc::Close DOC.CPP
  112. //
  113. //********************************************************************
  114. void CSimpleApp::DestroyDocs()
  115. {
  116. m_lpDoc->Close(); // we have only 1 document
  117. }
  118. //**********************************************************************
  119. //
  120. // CSimpleApp::QueryInterface
  121. //
  122. // Purpose:
  123. //
  124. // Used for interface negotiation at the Application level.
  125. //
  126. // Parameters:
  127. //
  128. // REFIID riid - A reference to the interface that is
  129. // being queried.
  130. //
  131. // LPVOID FAR* ppvObj - An out parameter to return a pointer to
  132. // the interface.
  133. //
  134. // Return Value:
  135. //
  136. // S_OK - The interface is supported.
  137. // S_FALSE - The interface is not supported
  138. //
  139. // Function Calls:
  140. // Function Location
  141. //
  142. // TestDebugOut Windows API
  143. // ResultFromScode OLE API
  144. //
  145. //********************************************************************
  146. STDMETHODIMP CSimpleApp::QueryInterface(REFIID riid, LPVOID FAR* ppvObj)
  147. {
  148. TestDebugOut("In CSimpleApp::QueryInterface\r\n");
  149. *ppvObj = NULL; // must set out pointer parameters to NULL
  150. // Not a supported interface
  151. return ResultFromScode(E_NOINTERFACE);
  152. }
  153. //**********************************************************************
  154. //
  155. // CSimpleApp::AddRef
  156. //
  157. // Purpose:
  158. //
  159. // Adds to the reference count at the Application level.
  160. //
  161. // Parameters:
  162. //
  163. // None
  164. //
  165. // Return Value:
  166. //
  167. // ULONG - The new reference count of the application.
  168. //
  169. // Function Calls:
  170. // Function Location
  171. //
  172. // TestDebugOut Windows API
  173. //
  174. // Comments:
  175. //
  176. // Due to the reference counting model that is used in this
  177. // implementation, this reference count is the sum of the
  178. // reference counts on all interfaces of all objects open
  179. // in the application.
  180. //
  181. //********************************************************************
  182. STDMETHODIMP_(ULONG) CSimpleApp::AddRef()
  183. {
  184. TestDebugOut("In CSimpleApp::AddRef\r\n");
  185. return ++m_nCount;
  186. }
  187. //**********************************************************************
  188. //
  189. // CSimpleApp::Release
  190. //
  191. // Purpose:
  192. //
  193. // Decrements the reference count at the application level
  194. //
  195. // Parameters:
  196. //
  197. // None
  198. //
  199. // Return Value:
  200. //
  201. // ULONG - The new reference count of the application.
  202. //
  203. // Function Calls:
  204. // Function Location
  205. //
  206. // TestDebugOut Windows API
  207. //
  208. //
  209. //********************************************************************
  210. STDMETHODIMP_(ULONG) CSimpleApp::Release()
  211. {
  212. TestDebugOut("In CSimpleApp::Release\r\n");
  213. if (--m_nCount == 0)
  214. {
  215. delete this;
  216. return 0;
  217. }
  218. return m_nCount;
  219. }
  220. //**********************************************************************
  221. //
  222. // CSimpleApp::fInitApplication
  223. //
  224. // Purpose:
  225. //
  226. // Initializes the application
  227. //
  228. // Parameters:
  229. //
  230. // HANDLE hInstance - Instance handle of the application.
  231. //
  232. // Return Value:
  233. //
  234. // TRUE - Application was successfully initialized.
  235. // FALSE - Application could not be initialized
  236. //
  237. // Function Calls:
  238. // Function Location
  239. //
  240. // LoadIcon Windows API
  241. // LoadCursor Windows API
  242. // GetStockObject Windows API
  243. // RegisterClass Windows API
  244. //
  245. //
  246. //********************************************************************
  247. BOOL CSimpleApp::fInitApplication(HANDLE hInstance)
  248. {
  249. WNDCLASS wc;
  250. // Fill in window class structure with parameters that describe the
  251. // main window.
  252. wc.style = NULL; // Class style(s).
  253. wc.lpfnWndProc = MainWndProc; // Function to retrieve messages for
  254. // windows of this class.
  255. wc.cbClsExtra = 0; // No per-class extra data.
  256. wc.cbWndExtra = 0; // No per-window extra data.
  257. wc.hInstance =(HINSTANCE) hInstance; // Application that owns
  258. // the class.
  259. wc.hIcon = LoadIcon((HINSTANCE)hInstance,TEXT("SimpDnd"));
  260. wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  261. wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
  262. wc.lpszMenuName = TEXT("SIMPLEMENU"); // Name of menu resource in
  263. // .RC file.
  264. wc.lpszClassName = TEXT("SimpDndAppWClass"); // Name used in
  265. // CreateWindow call.
  266. if (!RegisterClass(&wc))
  267. return FALSE;
  268. wc.style = CS_DBLCLKS; // Class style(s). allow DBLCLK's
  269. wc.lpfnWndProc = DocWndProc; // Function to retrieve messages for
  270. // windows of this class.
  271. wc.cbClsExtra = 0; // No per-class extra data.
  272. wc.cbWndExtra = 0; // No per-window extra data.
  273. wc.hInstance = (HINSTANCE) hInstance; // Application that owns
  274. // the class.
  275. wc.hIcon = NULL;
  276. wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  277. wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
  278. wc.lpszMenuName = NULL;
  279. wc.lpszClassName = TEXT("SimpDndDocWClass"); // Name used in
  280. //CreateWindow call.
  281. // Register the window class and return success/failure code.
  282. return (RegisterClass(&wc));
  283. }
  284. //**********************************************************************
  285. //
  286. // CSimpleApp::fInitInstance
  287. //
  288. // Purpose:
  289. //
  290. // Instance initialization.
  291. //
  292. // Parameters:
  293. //
  294. // HANDLE hInstance - App. Instance Handle.
  295. //
  296. // int nCmdShow - Show parameter from WinMain
  297. //
  298. // Return Value:
  299. //
  300. // TRUE - Initialization Successful
  301. // FALSE - Initialization Failed.
  302. //
  303. //
  304. // Function Calls:
  305. // Function Location
  306. //
  307. // CreateWindow Windows API
  308. // ShowWindow Windows API
  309. // UpdateWindow Windows API
  310. // GetProfileInt Windows API
  311. // OleBuildVersion OLE API
  312. // OleInitialize OLE API
  313. // OleStdCreateDbAlloc OLE2UI
  314. //
  315. // Comments:
  316. //
  317. // Note that successful Initalization of the OLE libraries
  318. // is remembered so the UnInit is only called if needed.
  319. //
  320. //********************************************************************
  321. BOOL CSimpleApp::fInitInstance (HANDLE hInstance, int nCmdShow)
  322. {
  323. LPMALLOC lpMalloc = NULL;
  324. #ifndef WIN32
  325. /* Since OLE is part of the operating system in Win32, we don't need to
  326. * check the version number in Win32.
  327. */
  328. DWORD dwVer = OleBuildVersion();
  329. // check to see if we are compatible with this version of the libraries
  330. if (HIWORD(dwVer) != rmm || LOWORD(dwVer) < rup)
  331. {
  332. #ifdef _DEBUG
  333. TestDebugOut("WARNING: Incompatible OLE library version\r\n");
  334. #else
  335. return FALSE;
  336. #endif
  337. }
  338. #endif // WIN32
  339. #if defined( _DEBUG )
  340. /* OLE2NOTE: Use a special debug allocator to help track down
  341. ** memory leaks.
  342. */
  343. OleStdCreateDbAlloc(0, &lpMalloc);
  344. #endif
  345. // We try passing in our own allocator first - if that fails we
  346. // try without overriding the allocator.
  347. if (SUCCEEDED(OleInitialize(lpMalloc)) ||
  348. SUCCEEDED(OleInitialize(NULL)))
  349. {
  350. m_fInitialized = TRUE;
  351. }
  352. #if defined( _DEBUG )
  353. /* OLE2NOTE: release the special debug allocator so that only OLE is
  354. ** holding on to it. later when OleUninitialize is called, then
  355. ** the debug allocator object will be destroyed. when the debug
  356. ** allocator object is destoyed, it will report (to the Output
  357. ** Debug Terminal) whether there are any memory leaks.
  358. */
  359. if (lpMalloc) lpMalloc->Release();
  360. #endif
  361. m_hInst = (HINSTANCE) hInstance;
  362. // Create the "application" windows
  363. m_hAppWnd = CreateWindow (TEXT("SimpDndAppWClass"),
  364. TEXT("Simple OLE 2.0 Drag/Drop Container"),
  365. WS_OVERLAPPEDWINDOW,
  366. CW_USEDEFAULT,
  367. CW_USEDEFAULT,
  368. CW_USEDEFAULT,
  369. CW_USEDEFAULT,
  370. NULL,
  371. NULL,
  372. (HINSTANCE) hInstance,
  373. NULL);
  374. if (!m_hAppWnd)
  375. return FALSE;
  376. // if we have been launched by the test driver, tell it our window handle
  377. if( m_hDriverWnd )
  378. {
  379. PostMessage(m_hDriverWnd, WM_TESTREG, (WPARAM)m_hAppWnd, 0);
  380. }
  381. // delay before dragging should start, in milliseconds
  382. m_nDragDelay = GetProfileInt(
  383. TEXT("windows"),
  384. TEXT("DragDelay"),
  385. DD_DEFDRAGDELAY
  386. );
  387. // minimum distance (radius) before drag should start, in pixels
  388. m_nDragMinDist = GetProfileInt(
  389. TEXT("windows"),
  390. TEXT("DragMinDist"),
  391. DD_DEFDRAGMINDIST
  392. );
  393. // delay before scrolling, in milliseconds
  394. m_nScrollDelay = GetProfileInt(
  395. TEXT("windows"),
  396. TEXT("DragScrollDelay"),
  397. DD_DEFSCROLLDELAY
  398. );
  399. // inset-width of the hot zone, in pixels
  400. m_nScrollInset = GetProfileInt(
  401. TEXT("windows"),
  402. TEXT("DragScrollInset"),
  403. DD_DEFSCROLLINSET
  404. );
  405. // scroll interval, in milliseconds
  406. m_nScrollInterval = GetProfileInt(
  407. TEXT("windows"),
  408. TEXT("DragScrollInterval"),
  409. DD_DEFSCROLLINTERVAL
  410. );
  411. ShowWindow (m_hAppWnd, nCmdShow);
  412. UpdateWindow (m_hAppWnd);
  413. return m_fInitialized;
  414. }
  415. //+-------------------------------------------------------------------------
  416. //
  417. // Member: CSimpleApp::UpdateDragDropEffects
  418. //
  419. // Synopsis: Update drag/drop effects
  420. //
  421. // Arguments: [iMenuPos] - menu position either source or target
  422. // [iMenuCommand] - what command the menu selection maps to
  423. // [dwEffect] - new effects
  424. // [pdwEffectToUpdate] - where to store the effects
  425. //
  426. // Algorithm: Get the menu for either source or target. Then clear any
  427. // outstanding check marks. Check the appropriate item. Finally
  428. // update the effects that we allow.
  429. //
  430. // History: dd-mmm-yy Author Comment
  431. // 06-May-94 Ricksa author
  432. //
  433. //--------------------------------------------------------------------------
  434. void CSimpleApp::UpdateDragDropEffects(
  435. int iMenuPos,
  436. int iMenuCommand,
  437. DWORD dwEffect,
  438. DWORD *pdwEffectToUpdate)
  439. {
  440. // Get the menu that we want to process
  441. HMENU hMenuItem = GetSubMenu(m_hHelpMenu, iMenuPos);
  442. // Clear any current check marks
  443. for (int i = 0; i < 3; i++)
  444. {
  445. CheckMenuItem(hMenuItem, i, MF_BYPOSITION | MF_UNCHECKED);
  446. }
  447. // Check the appropriate item.
  448. CheckMenuItem(hMenuItem, iMenuCommand, MF_BYCOMMAND | MF_CHECKED);
  449. *pdwEffectToUpdate = dwEffect;
  450. }
  451. //**********************************************************************
  452. //
  453. // CSimpleApp::lCommandHandler
  454. //
  455. // Purpose:
  456. //
  457. // Handles the processing of WM_COMMAND.
  458. //
  459. // Parameters:
  460. //
  461. // HWND hWnd - Handle to the application Window
  462. //
  463. // UINT message - message (always WM_COMMAND)
  464. //
  465. // WPARAM wParam - Same as passed to the WndProc
  466. //
  467. // LPARAM lParam - Same as passed to the WndProc
  468. //
  469. // Return Value:
  470. //
  471. // NULL
  472. //
  473. // Function Calls:
  474. // Function Location
  475. //
  476. // IOleObject::DoVerb Object
  477. // GetClientRect Windows API
  478. // MessageBox Windows API
  479. // DialogBox Windows API
  480. // MakeProcInstance Windows API
  481. // FreeProcInstance Windows API
  482. // SendMessage Windows API
  483. // DefWindowProc Windows API
  484. // CSimpleDoc::InsertObject DOC.CPP
  485. // CSimpleDoc::CopyObjectToClip DOC.CPP
  486. // CSimpleDoc::Close DOC.CPP
  487. //
  488. //********************************************************************
  489. LRESULT CSimpleApp::lCommandHandler (HWND hWnd, UINT message,
  490. WPARAM wParam, LPARAM lParam)
  491. {
  492. RECT rect;
  493. // see if the command is a verb selections
  494. if (wParam >= IDM_VERB0)
  495. {
  496. // get the rectangle of the object
  497. m_lpDoc->m_lpSite->GetObjRect(&rect);
  498. if (m_lpDoc->m_lpSite->m_lpOleObject->DoVerb(
  499. wParam - IDM_VERB0, NULL,
  500. &m_lpDoc->m_lpSite->m_OleClientSite, -1,
  501. m_lpDoc->m_hDocWnd, &rect)
  502. != ResultFromScode(S_OK))
  503. {
  504. TestDebugOut("Fail in IOleObject::DoVerb\n");
  505. }
  506. }
  507. else
  508. {
  509. switch (wParam)
  510. {
  511. // bring up the About box
  512. case IDM_ABOUT:
  513. {
  514. #ifdef WIN32
  515. DialogBox(m_hInst, // current instance
  516. TEXT("AboutBox"), // resource to use
  517. m_hAppWnd, // parent handle
  518. About); // About() instance address
  519. #else
  520. FARPROC lpProcAbout = MakeProcInstance((FARPROC)About,
  521. m_hInst);
  522. DialogBox(m_hInst, // current instance
  523. TEXT("AboutBox"), // resource to use
  524. m_hAppWnd, // parent handle
  525. lpProcAbout); // About() instance address
  526. FreeProcInstance(lpProcAbout);
  527. #endif
  528. break;
  529. }
  530. // bring up the InsertObject Dialog
  531. case IDM_INSERTOBJECT:
  532. m_lpDoc->InsertObject();
  533. break;
  534. // Copy the object to the Clipboard
  535. case IDM_COPY:
  536. m_lpDoc->CopyObjectToClip();
  537. break;
  538. // exit the application
  539. case IDM_EXIT:
  540. SendMessage(hWnd, WM_SYSCOMMAND, SC_CLOSE, 0L);
  541. break;
  542. case IDM_NEW:
  543. lCreateDoc(hWnd, 0, 0, 0);
  544. break;
  545. // Only allow copy from the source
  546. case IDM_SOURCE_COPY:
  547. UpdateDragDropEffects(SOURCE_EFFECTS_MENU_POS,
  548. IDM_SOURCE_COPY, DROPEFFECT_COPY, &m_dwSourceEffect);
  549. break;
  550. // Only allow move from the source
  551. case IDM_SOURCE_MOVE:
  552. UpdateDragDropEffects(SOURCE_EFFECTS_MENU_POS,
  553. IDM_SOURCE_MOVE, DROPEFFECT_MOVE, &m_dwSourceEffect);
  554. break;
  555. // Allow both copy and move from the source
  556. case IDM_SOURCE_COPYMOVE:
  557. UpdateDragDropEffects(SOURCE_EFFECTS_MENU_POS,
  558. IDM_SOURCE_COPYMOVE, DROPEFFECT_COPY | DROPEFFECT_MOVE,
  559. &m_dwSourceEffect);
  560. break;
  561. // Only accept copy in target
  562. case IDM_TARGET_COPY:
  563. UpdateDragDropEffects(TARGET_EFFECTS_MENU_POS,
  564. IDM_TARGET_COPY, DROPEFFECT_COPY, &m_dwTargetEffect);
  565. break;
  566. // Only accept move in target
  567. case IDM_TARGET_MOVE:
  568. UpdateDragDropEffects(TARGET_EFFECTS_MENU_POS,
  569. IDM_TARGET_MOVE, DROPEFFECT_MOVE, &m_dwTargetEffect);
  570. break;
  571. // Accept both move and copy in the target
  572. case IDM_TARGET_COPYMOVE:
  573. UpdateDragDropEffects(TARGET_EFFECTS_MENU_POS,
  574. IDM_TARGET_COPYMOVE, DROPEFFECT_COPY | DROPEFFECT_MOVE,
  575. &m_dwTargetEffect);
  576. break;
  577. default:
  578. return (DefWindowProc(hWnd, message, wParam, lParam));
  579. } // end of switch
  580. } // end of else
  581. return NULL;
  582. }
  583. //**********************************************************************
  584. //
  585. // CSimpleApp::lSizeHandler
  586. //
  587. // Purpose:
  588. //
  589. // Handles the WM_SIZE message
  590. //
  591. // Parameters:
  592. //
  593. // HWND hWnd - Handle to the application Window
  594. //
  595. // UINT message - message (always WM_SIZE)
  596. //
  597. // WPARAM wParam - Same as passed to the WndProc
  598. //
  599. // LPARAM lParam - Same as passed to the WndProc
  600. //
  601. // Return Value:
  602. //
  603. // LONG - returned from the "document" resizing
  604. //
  605. // Function Calls:
  606. // Function Location
  607. //
  608. // GetClientRect Windows API
  609. // CSimpleDoc::lResizeDoc DOC.CPP
  610. //
  611. //
  612. //********************************************************************
  613. long CSimpleApp::lSizeHandler (HWND hWnd, UINT message,
  614. WPARAM wParam, LPARAM lParam)
  615. {
  616. RECT rect;
  617. GetClientRect(m_hAppWnd, &rect);
  618. return m_lpDoc->lResizeDoc(&rect);
  619. }
  620. //**********************************************************************
  621. //
  622. // CSimpleApp::lCreateDoc
  623. //
  624. // Purpose:
  625. //
  626. // Handles the creation of a document object.
  627. //
  628. // Parameters:
  629. //
  630. // HWND hWnd - Handle to the application Window
  631. //
  632. // UINT message - message (always WM_CREATE)
  633. //
  634. // WPARAM wParam - Same as passed to the WndProc
  635. //
  636. // LPARAM lParam - Same as passed to the WndProc
  637. //
  638. // Return Value:
  639. //
  640. // NULL
  641. //
  642. // Function Calls:
  643. // Function Location
  644. //
  645. // GetClientRect Windows API
  646. // CSimpleDoc::CSimpleDoc DOC.CPP
  647. //
  648. //
  649. //********************************************************************
  650. long CSimpleApp::lCreateDoc (HWND hWnd, UINT message,
  651. WPARAM wParam, LPARAM lParam)
  652. {
  653. RECT rect;
  654. static BOOL fFirstTime = TRUE;
  655. if (m_lpDoc != NULL)
  656. {
  657. // There is a document defined already so we close it without
  658. // saving which is equivalent to deleting the object.
  659. m_lpDoc->Close();
  660. m_lpDoc = NULL;
  661. }
  662. GetClientRect(hWnd, &rect);
  663. m_lpDoc = CSimpleDoc::Create(this, &rect, hWnd);
  664. // First time initialization - for some reason the doc sets the
  665. // the application's m_hHelpMenu which we need. So we do the
  666. // initialization here.
  667. if (fFirstTime)
  668. {
  669. fFirstTime = FALSE;
  670. // Check default allowed effects for the source
  671. UpdateDragDropEffects(SOURCE_EFFECTS_MENU_POS, IDM_SOURCE_COPYMOVE,
  672. m_dwSourceEffect, &m_dwSourceEffect);
  673. // Check default allowed effects for the target
  674. UpdateDragDropEffects(TARGET_EFFECTS_MENU_POS, IDM_TARGET_COPYMOVE,
  675. m_dwTargetEffect, &m_dwTargetEffect);
  676. }
  677. return NULL;
  678. }
  679. //**********************************************************************
  680. //
  681. // CSimpleApp::HandleAccelerators
  682. //
  683. // Purpose:
  684. //
  685. // To properly handle accelerators in the Message Loop
  686. //
  687. // Parameters:
  688. //
  689. // LPMSG lpMsg - A pointer to the message structure.
  690. //
  691. // Return Value:
  692. //
  693. // TRUE - The accelerator was handled
  694. // FALSE - The accelerator was not handled
  695. //
  696. // Function Calls:
  697. // Function Location
  698. //
  699. //
  700. //********************************************************************
  701. BOOL CSimpleApp::HandleAccelerators(LPMSG lpMsg)
  702. {
  703. BOOL retval = FALSE;
  704. // we do not have any accelerators
  705. return retval;
  706. }
  707. //**********************************************************************
  708. //
  709. // CSimpleApp::PaintApp
  710. //
  711. // Purpose:
  712. //
  713. // Handles the painting of the doc window.
  714. //
  715. //
  716. // Parameters:
  717. //
  718. // HDC hDC - hDC to the Doc Window.
  719. //
  720. // Return Value:
  721. //
  722. // None
  723. //
  724. // Function Calls:
  725. // Function Location
  726. //
  727. // CSimpleDoc::PaintDoc DOC.CPP
  728. //
  729. // Comments:
  730. //
  731. // This is an app level function in case we want to do palette
  732. // management.
  733. //
  734. //********************************************************************
  735. void CSimpleApp::PaintApp (HDC hDC)
  736. {
  737. // at this level, we could enumerate through all of the
  738. // visible objects in the application, so that a palette
  739. // that best fits all of the objects can be built.
  740. // This app is designed to take on the same palette
  741. // functionality that was provided in OLE 1.0, the palette
  742. // of the last object drawn is realized. Since we only
  743. // support one object at a time, it shouldn't be a big
  744. // deal.
  745. // if we supported multiple documents, we would enumerate
  746. // through each of the open documents and call paint.
  747. if (m_lpDoc)
  748. {
  749. m_lpDoc->PaintDoc(hDC);
  750. }
  751. }