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.

741 lines
24 KiB

  1. /******************************************************************************/
  2. /* THUMNAIL.CPP: IMPLEMENTATION OF THE CThumbNailView and CFloatThumNailView */
  3. /* and CFullScreenThumbNailView Classes */
  4. /* */
  5. /******************************************************************************/
  6. /* */
  7. /* Methods in this file */
  8. /* */
  9. /* CThumbNailView Class Object */
  10. /* CThumbNailView::CThumbNailView */
  11. /* CThumbNailView::CThumbNailView */
  12. /* CThumbNailView::~CThumbNailView */
  13. /* CThumbNailView::Create */
  14. /* CThumbNailView::OnSize */
  15. /* CThumbNailView::OnPaint */
  16. /* CThumbNailView::DrawImage */
  17. /* CThumbNailView::DrawTracker */
  18. /* CThumbNailView::RefreshImage */
  19. /* CThumbNailView::GetImgWnd */
  20. /* CThumbNailView::OnKeyDown */
  21. /* CThumbNailView::OnLButtonDown */
  22. /* CThumbNailView::OnRButtonDown */
  23. /* CThumbNailView::OnThumbnailThumbnail */
  24. /* CThumbNailView::OnUpdateThumbnailThumbnail */
  25. /* */
  26. /* CFloatThumbNailView Class Object */
  27. /* CFloatThumbNailView::CFloatThumbNailView */
  28. /* CFloatThumbNailView::~CFloatThumbNailView */
  29. /* CFloatThumbNailView::Create */
  30. /* CFloatThumbNailView::OnClose */
  31. /* CFloatThumbNailView::OnSize */
  32. /* */
  33. /* CFullScreenThumbNailView Class Object */
  34. /* CFullScreenThumbNailView::CFullScreenThumbNailView */
  35. /* CFullScreenThumbNailView::CFullScreenThumbNailView */
  36. /* CFullScreenThumbNailView::~CFullScreenThumbNailView */
  37. /* CFullScreenThumbNailView::Create */
  38. /* CFullScreenThumbNailView::OnLButtonDown */
  39. /* CFullScreenThumbNailView::OnKeyDown */
  40. /* */
  41. /******************************************************************************/
  42. /* */
  43. /* These 3 objects provide a layer around the thumbnail view window, which */
  44. /* allow it to easily be a child, floating or a full screen. The ThumbNail */
  45. /* View Window is just a CWnd Window which on paints does a BitBlt from the */
  46. /* CImgWnd it was passsed on construction. */
  47. /* */
  48. /* The structure of the objects is as follows: */
  49. /* */
  50. /* CFullScreenThumbNailView is a Frame Window (with no border and sized to */
  51. /* full screen). It destroys itself on any keystroke or button click */
  52. /* while visible, it dissables the main application window. It contains */
  53. /* a CThumbNailView object as a child window. */
  54. /* */
  55. /* CFloatThumbNailView is a MiniFrame Window */
  56. /* CThumbNailView is a Child Window (which is sizable) A child of the */
  57. /* the CFloatThumbNailView window. This can be created */
  58. /* independent if a floating window is not desired (i.e. */
  59. /* for the docked view). It is this window which has the */
  60. /* image drawn into it. */
  61. /* */
  62. /* */
  63. /******************************************************************************/
  64. #include "stdafx.h"
  65. #include "global.h"
  66. #include "pbrush.h"
  67. #include "pbrusdoc.h"
  68. #include "pbrusfrm.h"
  69. #include "pbrusvw.h"
  70. #include "minifwnd.h"
  71. #include "docking.h"
  72. #include "bmobject.h"
  73. #include "imgsuprt.h"
  74. #include "imgwnd.h"
  75. #include "imgcolor.h"
  76. #include "imgbrush.h"
  77. #include "imgwell.h"
  78. #include "imgtools.h"
  79. #include "imgwnd.h"
  80. #include "thumnail.h"
  81. #ifdef _DEBUG
  82. #undef THIS_FILE
  83. static CHAR BASED_CODE THIS_FILE[] = __FILE__;
  84. #endif
  85. IMPLEMENT_DYNAMIC(CThumbNailView, CWnd)
  86. IMPLEMENT_DYNAMIC(CFloatThumbNailView, CMiniFrmWnd)
  87. IMPLEMENT_DYNAMIC(CFullScreenThumbNailView, CFrameWnd)
  88. #include "memtrace.h"
  89. /******************************************************************************/
  90. /******************************************************************************/
  91. /******************************************************************************/
  92. BEGIN_MESSAGE_MAP(CThumbNailView, CWnd)
  93. //{{AFX_MSG_MAP(CThumbNailView)
  94. ON_WM_PAINT()
  95. ON_WM_KEYDOWN()
  96. ON_WM_LBUTTONDOWN()
  97. ON_WM_RBUTTONDOWN()
  98. ON_COMMAND(ID_THUMBNAIL_THUMBNAIL, OnThumbnailThumbnail)
  99. ON_UPDATE_COMMAND_UI(ID_THUMBNAIL_THUMBNAIL, OnUpdateThumbnailThumbnail)
  100. ON_WM_CLOSE()
  101. //}}AFX_MSG_MAP
  102. END_MESSAGE_MAP()
  103. /******************************************************************************/
  104. CThumbNailView::CThumbNailView(CImgWnd *pcImgWnd)
  105. {
  106. m_pcImgWnd = pcImgWnd;
  107. }
  108. /******************************************************************************/
  109. CThumbNailView::CThumbNailView()
  110. {
  111. m_pcImgWnd = NULL;
  112. }
  113. /******************************************************************************/
  114. CThumbNailView::~CThumbNailView(void)
  115. {
  116. }
  117. /******************************************************************************/
  118. BOOL CThumbNailView::Create(DWORD dwStyle, CRect cRectWindow, CWnd *pcParentWnd)
  119. {
  120. return( CWnd::Create(NULL, TEXT(""), dwStyle, cRectWindow, pcParentWnd, NULL) );
  121. }
  122. /***************************************************************************/
  123. void CThumbNailView::OnClose()
  124. {
  125. ShowWindow(SW_HIDE);
  126. }
  127. /******************************************************************************/
  128. void CThumbNailView::OnPaint()
  129. {
  130. CPaintDC dc(this); // device context for painting
  131. // TODO: Add your message handler code here
  132. #ifdef USE_MIRRORING
  133. //
  134. // Disable RTL mirroring on full screen window
  135. //
  136. if (PBGetLayout(dc.GetSafeHdc()) & LAYOUT_RTL)
  137. {
  138. PBSetLayout(dc.GetSafeHdc(), 0);
  139. }
  140. #endif
  141. // Do not call CWnd::OnPaint() for painting messages
  142. DrawImage(&dc);
  143. }
  144. /******************************************************************************/
  145. void CThumbNailView::DrawImage(CDC* pDC)
  146. {
  147. /*
  148. ** when there is nothing to do, then don't do it
  149. */
  150. if (! theApp.m_bShowThumbnail || m_pcImgWnd == NULL
  151. || m_pcImgWnd->m_pImg == NULL )
  152. return;
  153. CRect crectClient;
  154. int iMinWidth;
  155. int iMinHeight;
  156. int iLeft;
  157. int iTop;
  158. CSize cSizeScrollPos = m_pcImgWnd->GetScrollPos();
  159. cSizeScrollPos.cx = abs( cSizeScrollPos.cx ) - CTracker::HANDLE_SIZE;
  160. cSizeScrollPos.cy = abs( cSizeScrollPos.cy ) - CTracker::HANDLE_SIZE;
  161. GetClientRect(crectClient);
  162. // find the smaller of the two the real image or the thumbnail window.
  163. iMinWidth = min( crectClient.Width() , m_pcImgWnd->m_pImg->cxWidth );
  164. iMinHeight = min( crectClient.Height(), m_pcImgWnd->m_pImg->cyHeight );
  165. if (crectClient.Width() >= m_pcImgWnd->m_pImg->cxWidth)
  166. {
  167. iLeft = 0; // can fit the whole image width into the thumbnail
  168. }
  169. else // image width greater than thumbnail width
  170. {
  171. // does thumbnail extend past end if started at scroll pos?
  172. if (cSizeScrollPos.cx + crectClient.Width() > m_pcImgWnd->m_pImg->cxWidth)
  173. {
  174. iLeft = cSizeScrollPos.cx - ( (cSizeScrollPos.cx
  175. + crectClient.Width()
  176. - m_pcImgWnd->m_pImg->cxWidth));
  177. }
  178. else
  179. {
  180. iLeft = cSizeScrollPos.cx;
  181. }
  182. }
  183. if (crectClient.Height() >= m_pcImgWnd->m_pImg->cyHeight)
  184. {
  185. iTop = 0; // can fit the whole image height into the thumbnail
  186. }
  187. else // image height greater than thumbnail height
  188. {
  189. // does thumbnail extend past bottom if started at scroll pos?
  190. if (cSizeScrollPos.cy + crectClient.Height() > m_pcImgWnd->m_pImg->cyHeight)
  191. {
  192. iTop = cSizeScrollPos.cy - ( (cSizeScrollPos.cy
  193. + crectClient.Height()
  194. - m_pcImgWnd->m_pImg->cyHeight));
  195. }
  196. else
  197. {
  198. iTop = cSizeScrollPos.cy;
  199. }
  200. }
  201. CDC cDC;
  202. cDC.Attach(m_pcImgWnd->m_pImg->hDC);
  203. CPalette* ppalOldSrc = theImgBrush.SetBrushPalette(&cDC, FALSE);
  204. CPalette* ppalOldDst = theImgBrush.SetBrushPalette( pDC, FALSE);
  205. pDC->BitBlt(0, 0, iMinWidth, iMinHeight,
  206. &cDC, iLeft, iTop, SRCCOPY);
  207. if (ppalOldDst)
  208. {
  209. pDC->SelectPalette(ppalOldDst, FALSE);
  210. }
  211. if (ppalOldSrc)
  212. {
  213. cDC.SelectPalette(ppalOldSrc, FALSE);
  214. }
  215. cDC.Detach();
  216. DrawTracker(pDC);
  217. }
  218. /******************************************************************************/
  219. /* basically the same processing as the imgwnd::drawtracker method, without */
  220. /* the zoom */
  221. void CThumbNailView::DrawTracker(CDC *pDC)
  222. {
  223. // BOOL bDrawTrackerRgn = FALSE;
  224. if (m_pcImgWnd->GetCurrent() != m_pcImgWnd
  225. || theImgBrush.m_bMoveSel
  226. || theImgBrush.m_bSmearSel
  227. || theImgBrush.m_bMakingSelection)
  228. {
  229. // This is not the active view, or the user is doing something
  230. // to prevent the tracker from appearing.
  231. return;
  232. }
  233. BOOL bReleaseDC = FALSE;
  234. CRect clientRect;
  235. if (pDC == NULL)
  236. {
  237. pDC = GetDC();
  238. if (pDC == NULL)
  239. {
  240. theApp.SetGdiEmergency(FALSE);
  241. return;
  242. }
  243. bReleaseDC = TRUE;
  244. }
  245. GetClientRect(&clientRect);
  246. CRect trackerRect;
  247. m_pcImgWnd->GetImageRect(trackerRect);
  248. trackerRect.InflateRect(CTracker::HANDLE_SIZE, CTracker::HANDLE_SIZE);
  249. CTracker::EDGES edges = (CTracker::EDGES)(CTracker::right | CTracker::bottom);
  250. // if (CImgTool::GetCurrentID() == IDMB_PICKRGNTOOL)
  251. // {
  252. // bDrawTrackerRgn = TRUE;
  253. // }
  254. if (m_pcImgWnd->m_pImg == theImgBrush.m_pImg)
  255. {
  256. edges = CTracker::all;
  257. CSize cSzScroll = m_pcImgWnd->GetScrollPos();
  258. trackerRect = theImgBrush.m_rcSelection;
  259. // trackerRect.InflateRect( CTracker::HANDLE_SIZE,
  260. // CTracker::HANDLE_SIZE);
  261. trackerRect.OffsetRect( cSzScroll.cx, cSzScroll.cy);
  262. }
  263. if (m_pcImgWnd->m_pImg == theImgBrush.m_pImg)
  264. {
  265. // if (bDrawTrackerRgn)
  266. // {
  267. // CTracker::DrawBorderRgn( pDC, trackerRect, &(theImgBrush.m_cRgnPolyFreeHandSel) );
  268. // }
  269. // else
  270. // {
  271. CTracker::DrawBorder( pDC, trackerRect );
  272. // }
  273. }
  274. if (bReleaseDC)
  275. {
  276. ReleaseDC(pDC);
  277. }
  278. }
  279. /******************************************************************************/
  280. /* Basically Do a paint without an erase background to prevent blinking */
  281. void CThumbNailView::RefreshImage(void)
  282. {
  283. if (theApp.m_bShowThumbnail)
  284. {
  285. TRY
  286. {
  287. CClientDC dc(this);
  288. DrawImage(&dc);
  289. }
  290. CATCH(CResourceException,e)
  291. {
  292. }
  293. END_CATCH
  294. }
  295. }
  296. /******************************************************************************/
  297. CImgWnd* CThumbNailView::GetImgWnd(void)
  298. {
  299. return m_pcImgWnd;
  300. }
  301. /******************************************************************************/
  302. void CThumbNailView::UpdateThumbNailView()
  303. {
  304. CPBView* pcbActiveView = (CPBView*)((CFrameWnd*)AfxGetMainWnd())->GetActiveView();
  305. m_pcImgWnd = pcbActiveView->m_pImgWnd;
  306. }
  307. /******************************************************************************/
  308. void CThumbNailView::OnKeyDown(UINT /*nChar*/, UINT /*nRepCnt*/, UINT /*nFlags*/)
  309. {
  310. const MSG* pmsg = GetCurrentMessage();
  311. GetParent()->SendMessage( pmsg->message, pmsg->wParam, pmsg->lParam );
  312. }
  313. /******************************************************************************/
  314. void CThumbNailView::OnLButtonDown(UINT /*nFlags*/, CPoint /*point*/)
  315. {
  316. const MSG* pmsg = GetCurrentMessage();
  317. GetParent()->SendMessage(pmsg->message, pmsg->wParam, pmsg->lParam);
  318. }
  319. /******************************************************************************/
  320. void CThumbNailView::OnRButtonDown(UINT /*nFlags*/, CPoint point)
  321. {
  322. HWND hwnd = GetSafeHwnd(); // must do this before calling SendMsg to parent, since it could delete us,
  323. const MSG* pmsg = GetCurrentMessage();
  324. GetParent()->SendMessage(pmsg->message, pmsg->wParam, pmsg->lParam);
  325. // the window is destroyed by the parent if FullScreenView
  326. if (::IsWindow(hwnd) != FALSE) // window still exists => object still valid, put up pop up menu.
  327. {
  328. CMenu cMenuPopup;
  329. CMenu *pcContextMenu;
  330. BOOL bRC;
  331. CRect cRectClient;
  332. GetClientRect(&cRectClient);
  333. bRC = cMenuPopup.LoadMenu( IDR_THUMBNAIL_POPUP );
  334. ASSERT(bRC != 0);
  335. if (bRC != 0)
  336. {
  337. pcContextMenu = cMenuPopup.GetSubMenu(0);
  338. ASSERT(pcContextMenu != NULL);
  339. if (pcContextMenu != NULL)
  340. {
  341. // update the check marks
  342. ClientToScreen(&point);
  343. ClientToScreen(&cRectClient);
  344. pcContextMenu->CheckMenuItem(ID_THUMBNAIL_THUMBNAIL, MF_BYCOMMAND | MF_CHECKED);
  345. pcContextMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this, &cRectClient);
  346. }
  347. }
  348. }
  349. }
  350. /******************************************************************************/
  351. void CThumbNailView::OnThumbnailThumbnail()
  352. {
  353. CPBView* pView = (CPBView*)(((CFrameWnd*)AfxGetMainWnd())->GetActiveView());
  354. if (pView != NULL && pView->IsKindOf( RUNTIME_CLASS( CPBView ) ))
  355. pView->HideThumbNailView();
  356. }
  357. /******************************************************************************/
  358. void CThumbNailView::OnUpdateThumbnailThumbnail(CCmdUI* pCmdUI)
  359. {
  360. pCmdUI->SetCheck();
  361. }
  362. /******************************************************************************/
  363. /******************************************************************************/
  364. /******************************************************************************/
  365. BEGIN_MESSAGE_MAP(CFloatThumbNailView, CMiniFrmWnd)
  366. //{{AFX_MSG_MAP(CFloatThumbNailView)
  367. ON_WM_CLOSE()
  368. ON_WM_SIZE()
  369. ON_WM_GETMINMAXINFO()
  370. //}}AFX_MSG_MAP
  371. END_MESSAGE_MAP()
  372. /******************************************************************************/
  373. CFloatThumbNailView::CFloatThumbNailView(CImgWnd *pcMainImgWnd)
  374. {
  375. m_pcThumbNailView = new CThumbNailView(pcMainImgWnd);
  376. if (m_pcThumbNailView == NULL)
  377. {
  378. theApp.SetMemoryEmergency();
  379. TRACE( TEXT("New Thumbnail View faild\n") );
  380. }
  381. }
  382. /******************************************************************************/
  383. CFloatThumbNailView::CFloatThumbNailView()
  384. {
  385. m_pcThumbNailView = NULL;
  386. }
  387. /******************************************************************************/
  388. CFloatThumbNailView::~CFloatThumbNailView(void)
  389. {
  390. }
  391. /******************************************************************************/
  392. BOOL CFloatThumbNailView::Create(CWnd* pParentWnd)
  393. {
  394. BOOL bRC;
  395. CRect cWindowRect;
  396. pParentWnd->GetWindowRect( &cWindowRect );
  397. cWindowRect.BottomRight() = cWindowRect.TopLeft();
  398. cWindowRect.right += 120;
  399. cWindowRect.bottom += 120;
  400. cWindowRect.OffsetRect( 15, 15 );
  401. if (! theApp.m_rectFloatThumbnail.IsRectEmpty())
  402. {
  403. cWindowRect = theApp.m_rectFloatThumbnail;
  404. }
  405. CString pWindowName;
  406. pWindowName.LoadString( IDS_VIEW );
  407. bRC = CMiniFrmWnd::Create( pWindowName, WS_THICKFRAME, cWindowRect, pParentWnd );
  408. if (bRC)
  409. {
  410. ASSERT( m_pcThumbNailView );
  411. GetClientRect( &cWindowRect );
  412. if (!m_pcThumbNailView->Create( WS_CHILD | WS_VISIBLE, cWindowRect, this ))
  413. {
  414. bRC = FALSE;
  415. theApp.SetMemoryEmergency();
  416. TRACE( TEXT("New Thumbnail View faild\n") );
  417. }
  418. }
  419. GetWindowRect( &theApp.m_rectFloatThumbnail );
  420. return bRC;
  421. }
  422. /******************************************************************************/
  423. // OnClose
  424. //
  425. // A Colorsbox is usally created by the parent, and will be destroyed
  426. // specifically by the parent upon leaving the app. When the user closes
  427. // the Colorsbox, it is simply hidden. The parent can then reshow it without
  428. // recreating it.
  429. //
  430. void CFloatThumbNailView::OnClose()
  431. {
  432. theApp.m_bShowThumbnail = FALSE;
  433. ShowWindow(SW_HIDE);
  434. }
  435. /******************************************************************************/
  436. void CFloatThumbNailView::PostNcDestroy()
  437. {
  438. if (m_pcThumbNailView != NULL)
  439. {
  440. delete m_pcThumbNailView;
  441. m_pcThumbNailView = NULL;
  442. }
  443. CWnd::PostNcDestroy();
  444. }
  445. /******************************************************************************/
  446. void CFloatThumbNailView::OnSize(UINT nType, int cx, int cy)
  447. {
  448. CMiniFrmWnd::OnSize(nType, cx, cy);
  449. if (m_pcThumbNailView != NULL
  450. && m_pcThumbNailView->GetSafeHwnd() != NULL)
  451. {
  452. m_pcThumbNailView->SetWindowPos( &wndTop, 0, 0, cx, cy, SWP_NOACTIVATE );
  453. }
  454. theApp.m_rectFloatThumbnail.right = theApp.m_rectFloatThumbnail.left + cx;
  455. theApp.m_rectFloatThumbnail.bottom = theApp.m_rectFloatThumbnail.top + cy;
  456. }
  457. /******************************************************************************/
  458. void CFloatThumbNailView::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
  459. {
  460. lpMMI->ptMinTrackSize.x = 2 * GetSystemMetrics( SM_CXICON );
  461. lpMMI->ptMinTrackSize.y = 2 * GetSystemMetrics( SM_CYICON );
  462. CWnd::OnGetMinMaxInfo( lpMMI );
  463. }
  464. /******************************************************************************/
  465. /******************************************************************************/
  466. /******************************************************************************/
  467. BEGIN_MESSAGE_MAP(CFullScreenThumbNailView, CFrameWnd)
  468. //{{AFX_MSG_MAP(CFullScreenThumbNailView)
  469. ON_WM_LBUTTONDOWN()
  470. ON_WM_KEYDOWN()
  471. ON_WM_RBUTTONDOWN()
  472. ON_WM_ERASEBKGND()
  473. ON_WM_CLOSE()
  474. //}}AFX_MSG_MAP
  475. END_MESSAGE_MAP()
  476. /******************************************************************************/
  477. CFullScreenThumbNailView::CFullScreenThumbNailView(CImgWnd *pcMainImgWnd)
  478. {
  479. m_bSaveShowFlag = theApp.m_bShowThumbnail;
  480. theApp.m_bShowThumbnail = TRUE;
  481. // m_brBackground.CreateSolidBrush( ::GetSysColor( COLOR_BACKGROUND ) );
  482. m_pcThumbNailView = new CThumbNailView(pcMainImgWnd);
  483. if (m_pcThumbNailView == NULL)
  484. {
  485. theApp.SetMemoryEmergency();
  486. TRACE( TEXT("New Thumbnail View faild\n") );
  487. }
  488. }
  489. /******************************************************************************/
  490. CFullScreenThumbNailView::CFullScreenThumbNailView()
  491. {
  492. m_hOldIcon = 0;
  493. m_pcThumbNailView = NULL;
  494. }
  495. /******************************************************************************/
  496. CFullScreenThumbNailView::~CFullScreenThumbNailView(void)
  497. {
  498. if (m_hOldIcon)
  499. {
  500. SetClassLongPtr (((CFrameWnd*)this)->GetSafeHwnd(), GCLP_HICON, (LONG_PTR)m_hOldIcon);
  501. }
  502. if (m_pcThumbNailView != NULL)
  503. {
  504. delete m_pcThumbNailView;
  505. theApp.m_bShowThumbnail = m_bSaveShowFlag;
  506. }
  507. // if (m_brBackground.m_hObject != NULL)
  508. // m_brBackground.DeleteObject();
  509. }
  510. /******************************************************************************/
  511. BOOL CFullScreenThumbNailView::Create(LPCTSTR szCaption)
  512. {
  513. ASSERT( m_pcThumbNailView );
  514. TCHAR szFileName[MAX_PATH];
  515. HICON hIcon;
  516. CRect cWindowRect( 0, 0, ::GetSystemMetrics( SM_CXSCREEN ),
  517. ::GetSystemMetrics( SM_CYSCREEN ) );
  518. //
  519. // Use the current file name as the caption of the window so
  520. // it shows up in alt-tab
  521. if (szCaption && *szCaption)
  522. {
  523. GetFileTitle (szCaption, szFileName, MAX_PATH);
  524. }
  525. else
  526. {
  527. LoadString (GetModuleHandle (NULL), AFX_IDS_UNTITLED, szFileName, MAX_PATH);
  528. }
  529. BOOL bRC = CFrameWnd::Create( NULL, szFileName, WS_POPUP|WS_VISIBLE | WS_CLIPCHILDREN,
  530. cWindowRect );
  531. //
  532. // This window needs a Paint icon instead of a boring icon
  533. // So set the class's icon to the Paint icon
  534. // We want alt-tab to work decently
  535. hIcon = LoadIcon (GetModuleHandle (NULL), MAKEINTRESOURCE(ID_MAINFRAME));
  536. m_hOldIcon = SetClassLongPtr (((CFrameWnd*)this)->GetSafeHwnd(), GCLP_HICON, (LONG_PTR)hIcon);
  537. if (bRC)
  538. {
  539. ASSERT( m_pcThumbNailView );
  540. AfxGetMainWnd()->EnableWindow( FALSE );
  541. CImgWnd* pcImgWnd = m_pcThumbNailView->GetImgWnd();
  542. if (pcImgWnd != NULL)
  543. {
  544. // find the smaller of the two the real image or the full screen window size.
  545. int iMinWidth = min( cWindowRect.Width(), pcImgWnd->m_pImg->cxWidth );
  546. int iMinHeight = min( cWindowRect.Height(), pcImgWnd->m_pImg->cyHeight );
  547. // center the image in the full screen window.
  548. cWindowRect.left = (cWindowRect.Width() - iMinWidth) / 2;
  549. cWindowRect.top = (cWindowRect.Height() - iMinHeight) / 2;
  550. cWindowRect.right = cWindowRect.left + iMinWidth;
  551. cWindowRect.bottom = cWindowRect.top + iMinHeight;
  552. m_pcThumbNailView->Create( WS_CHILD | WS_VISIBLE, cWindowRect, this );
  553. }
  554. }
  555. return bRC;
  556. }
  557. /******************************************************************************/
  558. BOOL CFullScreenThumbNailView::OnEraseBkgnd( CDC* pDC )
  559. {
  560. CBrush* pbr = GetSysBrush( COLOR_BACKGROUND );
  561. // if (m_brBackground.m_hObject == NULL)
  562. if (! pbr)
  563. return CFrameWnd::OnEraseBkgnd( pDC );
  564. CRect cRectClient;
  565. GetClientRect( &cRectClient );
  566. pDC->FillRect( &cRectClient, pbr /* &m_brBackground */ );
  567. return TRUE;
  568. }
  569. /******************************************************************************/
  570. void CFullScreenThumbNailView::OnLButtonDown(UINT /*nFlags*/, CPoint /*point*/)
  571. {
  572. PostMessage (WM_CLOSE, 0, 0);
  573. }
  574. /******************************************************************************/
  575. void CFullScreenThumbNailView::OnKeyDown(UINT /*nChar*/, UINT /*nRepCnt*/, UINT /*nFlags*/)
  576. {
  577. PostMessage (WM_CLOSE, 0, 0);
  578. }
  579. /******************************************************************************/
  580. void CFullScreenThumbNailView::OnClose ()
  581. {
  582. AfxGetMainWnd()->EnableWindow( TRUE );
  583. ::DestroyWindow( m_hWnd );
  584. }
  585. /******************************************************************************/