Old fashion design for PC-104
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.

129 lines
3.5 KiB

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //----------------------------------------------------------------------------
  2. // Laser Guard Ltd.
  3. // Copyright � 2000-2002. All Rights Reserved.
  4. // Version 1.0 01/01/2000
  5. // Last modification: 08/10/2003
  6. // PROJECT:
  7. // SUBSYSTEM:
  8. // FILE: LogoWnd.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of LogoWnd.cpp
  13. //----------------------------------------------------------------------------
  14. // LogoWnd.cpp : implementation file
  15. //
  16. #include "stdafx.h"
  17. #include "chicago.h"
  18. #include "LogoWnd.h"
  19. #include "..\..\LgLib\Version.h"
  20. #ifdef _DEBUG
  21. #define new DEBUG_NEW
  22. #undef THIS_FILE
  23. static char THIS_FILE[] = __FILE__;
  24. #endif
  25. /////////////////////////////////////////////////////////////////////////////
  26. // CLogoWnd
  27. CLogoWnd::CLogoWnd()
  28. {
  29. m_pOverlayBitmapOld = NULL;
  30. m_bRotate = FALSE;
  31. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CLogoWnd::CLogoWnd") );
  32. }
  33. CLogoWnd::~CLogoWnd()
  34. {
  35. if( m_pOverlayBitmapOld )
  36. {
  37. m_OverlayDC.SelectObject( m_pOverlayBitmapOld );
  38. m_OverlayBitmap.DeleteObject();
  39. m_OverlayDC.DeleteDC();
  40. }
  41. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CLogoWnd::~CLogoWnd") );
  42. }
  43. BEGIN_MESSAGE_MAP(CLogoWnd, CWnd)
  44. //{{AFX_MSG_MAP(CLogoWnd)
  45. ON_WM_PAINT()
  46. ON_WM_TIMER()
  47. //}}AFX_MSG_MAP
  48. END_MESSAGE_MAP()
  49. /////////////////////////////////////////////////////////////////////////////
  50. // CLogoWnd message handlers
  51. BOOL CLogoWnd::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
  52. {
  53. if( CWnd::CreateEx( WS_EX_DLGMODALFRAME, lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext) )
  54. {
  55. CDC *pDC = GetDC();
  56. m_OverlayDC.CreateCompatibleDC( pDC );
  57. ReleaseDC( pDC );
  58. HBITMAP hBitmap = (HBITMAP)::LoadImage( NULL, "LOGO.BMP", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_DEFAULTSIZE );
  59. m_OverlayBitmap.Attach( hBitmap );
  60. // m_OverlayBitmap.LoadBitmap( IDB_BITMAP_LOGO );
  61. m_pOverlayBitmapOld = m_OverlayDC.SelectObject( &m_OverlayBitmap );
  62. m_nStage = 0;
  63. // SetTimer( 0, 125, NULL );
  64. return TRUE;
  65. }
  66. return FALSE;
  67. }
  68. void CLogoWnd::PaintLogo(CDC *pDC)
  69. {
  70. // SYSTEMTIME st;
  71. // ::GetLocalTime( &st );
  72. CRect rect;
  73. GetClientRect( &rect );
  74. const int width = 128;
  75. const int height = 128;
  76. CPoint p( (rect.Width() - width) / 2, (rect.Height() - height) / 2 );
  77. CRect rect1( rect.left, rect.top, rect.left + p.x, rect.bottom );
  78. CRect rect2( rect.left + p.x + width, rect.top, rect.right, rect.bottom );
  79. CRect rect3( rect.left + p.x, rect.top, rect.left + p.x + width, rect.top + p.y );
  80. CRect rect4( rect.left + p.x, rect.top + p.y + height, rect.left + p.x + width, rect.bottom );
  81. COLORREF color = m_OverlayDC.GetPixel( 0, 0 );
  82. pDC->FillSolidRect( &rect1, color );
  83. pDC->FillSolidRect( &rect2, color );
  84. pDC->FillSolidRect( &rect3, color );
  85. pDC->FillSolidRect( &rect4, color );
  86. if( m_bRotate )
  87. pDC->BitBlt( p.x, p.y, width, height, &m_OverlayDC, width * m_nStage, 0, SRCCOPY );
  88. else
  89. pDC->BitBlt( p.x, p.y, width, height, &m_OverlayDC, width * 8, 0, SRCCOPY );
  90. }
  91. void CLogoWnd::OnPaint()
  92. {
  93. CPaintDC dc(this); // device context for painting
  94. PaintLogo( &dc );
  95. }
  96. void CLogoWnd::OnTimer(UINT nIDEvent)
  97. {
  98. m_nStage = (m_nStage+1)%8;
  99. CDC *pDC = GetDC();
  100. PaintLogo( pDC );
  101. ReleaseDC( pDC );
  102. CWnd::OnTimer(nIDEvent);
  103. }
  104. void CLogoWnd::Rotate(BOOL bRotate)
  105. {
  106. m_bRotate = bRotate;
  107. }