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.

73 lines
1.7 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: LgButton.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of LgButton.cpp
  13. //----------------------------------------------------------------------------
  14. #include "stdafx.h"
  15. #include "LgButton.h"
  16. #ifdef _DEBUG
  17. #define new DEBUG_NEW
  18. #undef THIS_FILE
  19. static char THIS_FILE[] = __FILE__;
  20. #endif
  21. CLgButton::CLgButton()
  22. {
  23. m_hUpBitmap = m_hDownBitmap = NULL;
  24. }
  25. CLgButton::~CLgButton()
  26. {
  27. if( m_hUpBitmap )
  28. ::DeleteObject( m_hUpBitmap );
  29. if( m_hDownBitmap )
  30. ::DeleteObject( m_hDownBitmap );
  31. }
  32. BEGIN_MESSAGE_MAP(CLgButton, CButton)
  33. //{{AFX_MSG_MAP(CLgButton)
  34. //}}AFX_MSG_MAP
  35. END_MESSAGE_MAP()
  36. LRESULT CLgButton::WindowProc( UINT message, WPARAM wParam, LPARAM lParam )
  37. {
  38. switch( message )
  39. {
  40. case BM_SETSTATE:
  41. GetParent()->SendMessage( LG_BUTTON_BM_SET_STATE, wParam, GetDlgCtrlID() );
  42. UpdateImages();
  43. break;
  44. }
  45. return CButton::WindowProc(message, wParam, lParam);
  46. }
  47. BOOL CLgButton::SetBitmaps( UINT nUp, UINT nDown )
  48. {
  49. if( m_hUpBitmap )
  50. ::DeleteObject( m_hUpBitmap );
  51. if( m_hDownBitmap )
  52. ::DeleteObject( m_hDownBitmap );
  53. m_hUpBitmap = ::LoadBitmap( (HINSTANCE)GetWindowLong( GetSafeHwnd(), GWL_HINSTANCE ), (LPCTSTR)nUp );
  54. m_hDownBitmap = ::LoadBitmap( (HINSTANCE)GetWindowLong( GetSafeHwnd(), GWL_HINSTANCE ), (LPCTSTR)nDown );
  55. UpdateImages();
  56. return TRUE;
  57. }
  58. void CLgButton::UpdateImages()
  59. {
  60. SetBitmap( GetCheck() ? (m_hDownBitmap?m_hDownBitmap:m_hUpBitmap) : m_hUpBitmap );
  61. }