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.

200 lines
5.4 KiB

  1. // ipframe.cpp : implementation of the CInPlaceFrame class
  2. //
  3. #include "stdafx.h"
  4. #include "pbrush.h"
  5. #include "pbrusfrm.h"
  6. #include "pbrusvw.h"
  7. #include "ipframe.h"
  8. #include "minifwnd.h"
  9. #include "imgwell.h"
  10. #include "toolbox.h"
  11. #include "imgcolor.h"
  12. #include "bmobject.h"
  13. #include "imgsuprt.h"
  14. #include "global.h"
  15. #include "colorsrc.h"
  16. #include <htmlhelp.h>
  17. #ifdef _DEBUG
  18. #undef THIS_FILE
  19. static CHAR BASED_CODE THIS_FILE[] = __FILE__;
  20. #endif
  21. IMPLEMENT_DYNCREATE(CInPlaceFrame, COleIPFrameWnd)
  22. #include "memtrace.h"
  23. /***************************************************************************/
  24. // CInPlaceFrame
  25. BEGIN_MESSAGE_MAP(CInPlaceFrame, COleIPFrameWnd)
  26. //{{AFX_MSG_MAP(CInPlaceFrame)
  27. ON_WM_CREATE()
  28. ON_WM_SIZE()
  29. ON_WM_SYSCOLORCHANGE()
  30. ON_WM_CLOSE()
  31. //}}AFX_MSG_MAP
  32. ON_MESSAGE(WM_CONTEXTMENU, OnContextMenu)
  33. // Global help commands
  34. ON_COMMAND(ID_HELP_INDEX, OnHelpIndex)
  35. ON_COMMAND(ID_HELP_USING, OnHelpUsing)
  36. ON_COMMAND(ID_HELP, OnHelp)
  37. ON_COMMAND(ID_DEFAULT_HELP, OnHelpIndex)
  38. ON_COMMAND(ID_CONTEXT_HELP, OnContextHelp)
  39. ON_UPDATE_COMMAND_UI(ID_VIEW_TOOL_BOX, COleIPFrameWnd::OnUpdateControlBarMenu)
  40. ON_COMMAND_EX(ID_VIEW_TOOL_BOX, COleIPFrameWnd::OnBarCheck)
  41. ON_UPDATE_COMMAND_UI(ID_VIEW_COLOR_BOX, COleIPFrameWnd::OnUpdateControlBarMenu)
  42. ON_COMMAND_EX(ID_VIEW_COLOR_BOX, COleIPFrameWnd::OnBarCheck)
  43. END_MESSAGE_MAP()
  44. /***************************************************************************/
  45. // CInPlaceFrame construction/destruction
  46. CInPlaceFrame::CInPlaceFrame()
  47. {
  48. theApp.m_pwndInPlaceFrame = this;
  49. }
  50. /***************************************************************************/
  51. CInPlaceFrame::~CInPlaceFrame()
  52. {
  53. theApp.m_pwndInPlaceFrame = NULL;
  54. theApp.m_hwndInPlaceApp = NULL;
  55. g_pStatBarWnd = 0;
  56. g_pImgToolWnd = 0;
  57. g_pImgColorsWnd = 0;
  58. }
  59. /***************************************************************************/
  60. CWnd* CInPlaceFrame::GetMessageBar()
  61. {
  62. CPBFrame* pwndMain = (CPBFrame*)theApp.m_pMainWnd;
  63. if (pwndMain != NULL
  64. && pwndMain->m_statBar.m_hWnd != NULL)
  65. return &(pwndMain->m_statBar);
  66. return NULL;
  67. }
  68. /***************************************************************************/
  69. int CInPlaceFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  70. {
  71. if (COleIPFrameWnd::OnCreate(lpCreateStruct) == -1)
  72. return -1;
  73. // CResizeBar implements in-place resizing.
  74. if (! m_wndResizeBar.Create( this ))
  75. {
  76. TRACE(TEXT("MSPaint Failed to create resize bar\n"));
  77. return -1; // fail to create
  78. }
  79. // By default, it is a good idea to register a drop-target that does
  80. // nothing with your frame window. This prevents drops from
  81. // "falling through" to a container that supports drag-drop.
  82. m_dropTarget.Register( this );
  83. return 0;
  84. }
  85. /******************************************************************************/
  86. BOOL CInPlaceFrame::OnCreateControlBars( CFrameWnd* pWndFrame, CFrameWnd* pWndDoc )
  87. {
  88. theApp.m_hwndInPlaceApp = pWndFrame->GetSafeHwnd();
  89. CPBView* pView = (CPBView*)GetActiveView();
  90. ASSERT( pView != NULL );
  91. if (pView == NULL || ! pView->IsKindOf( RUNTIME_CLASS( CPBView ) ))
  92. return FALSE;
  93. g_pStatBarWnd = &m_statBar;
  94. g_pImgToolWnd = &m_toolBar;
  95. g_pImgColorsWnd = &m_colorBar;
  96. pView->SetTools();
  97. return TRUE;
  98. }
  99. /***************************************************************************/
  100. void CInPlaceFrame::RepositionFrame( LPCRECT lpPosRect, LPCRECT lpClipRect )
  101. {
  102. COleIPFrameWnd::RepositionFrame( lpPosRect, lpClipRect );
  103. // The other control bars can overlap and result in mispaints
  104. if ( IsWindow(m_wndResizeBar.m_hWnd) )
  105. m_wndResizeBar.Invalidate();
  106. }
  107. /***************************************************************************/
  108. void CInPlaceFrame::OnSize(UINT nType, int cx, int cy)
  109. {
  110. COleIPFrameWnd::OnSize( nType, cx, cy );
  111. TRACE( TEXT("MSPaint New Size %d x %d\n"), cx, cy );
  112. }
  113. /***************************************************************************/
  114. // CInPlaceFrame diagnostics
  115. #ifdef _DEBUG
  116. void CInPlaceFrame::AssertValid() const
  117. {
  118. COleIPFrameWnd::AssertValid();
  119. }
  120. /***************************************************************************/
  121. void CInPlaceFrame::Dump(CDumpContext& dc) const
  122. {
  123. COleIPFrameWnd::Dump(dc);
  124. }
  125. #endif //_DEBUG
  126. /***************************************************************************/
  127. void CInPlaceFrame::OnSysColorChange()
  128. {
  129. COleIPFrameWnd::OnSysColorChange();
  130. ResetSysBrushes();
  131. }
  132. /***************************************************************************/
  133. void CInPlaceFrame::OnClose()
  134. {
  135. // TODO: Add your message handler code here and/or call default
  136. SaveBarState(TEXT("General"));
  137. CancelToolMode (FALSE);
  138. COleIPFrameWnd::OnClose();
  139. }
  140. void CInPlaceFrame::OnHelpIndex()
  141. {
  142. ::HtmlHelpA( ::GetDesktopWindow(), "mspaint.chm", HH_DISPLAY_TOPIC, 0L );
  143. }
  144. LRESULT CInPlaceFrame::OnContextMenu(WPARAM wParam, LPARAM lParam)
  145. {
  146. // Just make sure this message does not get passed to the parent
  147. return(1);
  148. }