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.

126 lines
2.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: HexEdit.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of HexEdit.cpp
  13. //----------------------------------------------------------------------------
  14. // HexEdit.cpp : implementation file
  15. //
  16. #include "stdafx.h"
  17. #include "setuplgs.h"
  18. #include "HexEdit.h"
  19. #ifdef _DEBUG
  20. #define new DEBUG_NEW
  21. #undef THIS_FILE
  22. static char THIS_FILE[] = __FILE__;
  23. #endif
  24. /////////////////////////////////////////////////////////////////////////////
  25. // CHexEdit
  26. CHexEdit::CHexEdit()
  27. {
  28. }
  29. CHexEdit::~CHexEdit()
  30. {
  31. }
  32. BEGIN_MESSAGE_MAP(CHexEdit, CEdit)
  33. //{{AFX_MSG_MAP(CHexEdit)
  34. ON_WM_CHAR()
  35. //}}AFX_MSG_MAP
  36. END_MESSAGE_MAP()
  37. /////////////////////////////////////////////////////////////////////////////
  38. // CHexEdit message handlers
  39. void CHexEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
  40. {
  41. if( ( GetKeyState( VK_CONTROL ) & 0x80 ) ||
  42. ( GetKeyState( VK_MENU ) & 0x80 ) )
  43. {
  44. CEdit::OnChar(nChar, nRepCnt, nFlags);
  45. }
  46. else
  47. {
  48. // extended key
  49. if( nFlags & (1<<24) )
  50. {
  51. CEdit::OnChar(nChar, nRepCnt, nFlags);
  52. }
  53. else
  54. {
  55. TCHAR pBuffer[] = { 0, 0 };
  56. switch( nChar )
  57. {
  58. case VK_DELETE:
  59. case VK_BACK:
  60. case '0': case '1': case '2': case '3': case '4':
  61. case '5': case '6': case '7': case '8': case '9':
  62. case 'a': case 'A':
  63. case 'b': case 'B':
  64. case 'c': case 'C':
  65. case 'd': case 'D':
  66. case 'e': case 'E':
  67. case 'f': case 'F':
  68. CEdit::OnChar( nChar, nRepCnt, nFlags );
  69. break;
  70. }
  71. }
  72. }
  73. }
  74. void CHexEdit::SetHex( DWORD value )
  75. {
  76. ASSERT( GetSafeHwnd() );
  77. TCHAR pBuffer[10];
  78. _stprintf( pBuffer, _T("%08X"), value );
  79. SetWindowText( pBuffer );
  80. SetLimitText( 8 );
  81. }
  82. void CHexEdit::SetHex( WORD value )
  83. {
  84. ASSERT( GetSafeHwnd() );
  85. TCHAR pBuffer[10];
  86. _stprintf( pBuffer, _T("%04X"), value );
  87. SetWindowText( pBuffer );
  88. SetLimitText( 4 );
  89. }
  90. void CHexEdit::SetHex( BYTE value )
  91. {
  92. ASSERT( GetSafeHwnd() );
  93. TCHAR pBuffer[10];
  94. _stprintf( pBuffer, _T("%02X"), value );
  95. SetWindowText( pBuffer );
  96. SetLimitText( 2 );
  97. }
  98. DWORD CHexEdit::GetHex()
  99. {
  100. ASSERT( GetSafeHwnd() );
  101. DWORD value = 0UL;
  102. TCHAR pBuffer[10];
  103. GetWindowText( pBuffer, 10 );
  104. _stscanf( pBuffer, _T("%X"), &value );
  105. return value;
  106. }