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

//----------------------------------------------------------------------------
// Laser Guard Ltd.
// Copyright © 2000-2002. All Rights Reserved.
// Version 1.0 01/01/2000
// Last modification: 08/10/2003
// PROJECT:
// SUBSYSTEM:
// FILE: HexEdit.cpp
// AUTHOR: Sergey Chizhevskiy
// OVERVIEW
// ~~~~~~~~
// Source file of HexEdit.cpp
//----------------------------------------------------------------------------
// HexEdit.cpp : implementation file
//
#include "stdafx.h"
#include "setuplgs.h"
#include "HexEdit.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CHexEdit
CHexEdit::CHexEdit()
{
}
CHexEdit::~CHexEdit()
{
}
BEGIN_MESSAGE_MAP(CHexEdit, CEdit)
//{{AFX_MSG_MAP(CHexEdit)
ON_WM_CHAR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CHexEdit message handlers
void CHexEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if( ( GetKeyState( VK_CONTROL ) & 0x80 ) ||
( GetKeyState( VK_MENU ) & 0x80 ) )
{
CEdit::OnChar(nChar, nRepCnt, nFlags);
}
else
{
// extended key
if( nFlags & (1<<24) )
{
CEdit::OnChar(nChar, nRepCnt, nFlags);
}
else
{
TCHAR pBuffer[] = { 0, 0 };
switch( nChar )
{
case VK_DELETE:
case VK_BACK:
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
case 'a': case 'A':
case 'b': case 'B':
case 'c': case 'C':
case 'd': case 'D':
case 'e': case 'E':
case 'f': case 'F':
CEdit::OnChar( nChar, nRepCnt, nFlags );
break;
}
}
}
}
void CHexEdit::SetHex( DWORD value )
{
ASSERT( GetSafeHwnd() );
TCHAR pBuffer[10];
_stprintf( pBuffer, _T("%08X"), value );
SetWindowText( pBuffer );
SetLimitText( 8 );
}
void CHexEdit::SetHex( WORD value )
{
ASSERT( GetSafeHwnd() );
TCHAR pBuffer[10];
_stprintf( pBuffer, _T("%04X"), value );
SetWindowText( pBuffer );
SetLimitText( 4 );
}
void CHexEdit::SetHex( BYTE value )
{
ASSERT( GetSafeHwnd() );
TCHAR pBuffer[10];
_stprintf( pBuffer, _T("%02X"), value );
SetWindowText( pBuffer );
SetLimitText( 2 );
}
DWORD CHexEdit::GetHex()
{
ASSERT( GetSafeHwnd() );
DWORD value = 0UL;
TCHAR pBuffer[10];
GetWindowText( pBuffer, 10 );
_stscanf( pBuffer, _T("%X"), &value );
return value;
}