bool flagletter ;
BOOL CRcsimuDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application‘s main window is not a dialog
SetIcon(m_hIcon, TRUE);
// Set big icon
SetIcon(m_hIcon, FALSE);
// Set small icon
irsimu_init( m_hWnd, UM_IR_MESSAGE );
return TRUE;
}
void CRcsimuDlg::OnDestroy()
{
irsimu_exit();
CDialog::OnDestroy();
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CRcsimuDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CRcsimuDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
BOOL CRcsimuDlg::PreTranslateMessage(MSG* pMsg)
{
switch( pMsg->message )
{
case WM_KEYDOWN:
irsimu_on_keydown( (unsigned char)pMsg->wParam );
flag = true;
break;
case WM_KEYUP:
irsimu_on_keyup( (unsigned char)pMsg->wParam );
flag = false;
break;
}
return CDialog::PreTranslateMessage(pMsg);
}
//static int rows = 0;
LRESULT CRcsimuDlg::OnIrMessage( WPARAM wParam, LPARAM lParam )
{
CString msg;
static int rows = 0;
static int cha = 0;
static char key = ‘?‘;
UpdateData( TRUE );
if( 15 < rows++ )
{
rows = 0;
m_rc_msg.Empty();
}
switch(wParam)
{
case 0x14c0c0eb:
key = ‘a‘ - cha;
break;
case 0x24c0c0db:
key = ‘b‘ - cha;
break;
case 0x34c0c0cb:
key = ‘c‘ - cha;
break;
case 0x44c0c0bb:
key = ‘d‘ - cha;
break;
case 0x54c0c0ab:
key = ‘e‘ - cha;
break;
case 0x64c0c09b:
key = ‘f‘ - cha;
break;
case 0x74c0c08b:
key = ‘g‘ - cha ;
break;
case 0x84c0c07b:
key = ‘h‘ - cha;
break;
case 0x94c0c06b:
key = ‘i‘ - cha;
break;
case 0xa4c0c05b:
key = ‘j‘ - cha;
break;
case 0xb4c0c04b:
key = ‘k‘ - cha;
break;
case 0xc4c0c03b:
key = ‘l‘ - cha;
break;
case 0xd4c0c02b:
key = ‘m‘ - cha;
break;
case 0xe4c0c01b:
key = ‘n‘ - cha;
break;
case 0xf4c0c00a:
key = ‘o‘ - cha;
break;
case 0x05c0c0fa:
key = ‘p‘ - cha;
break;
case 0x15c0c0ea:
key = ‘q‘ - cha;
break;
case 0x25c0c0da:
key = ‘r‘ - cha;
break;
case 0x35c0c0ca:
key = ‘s‘ - cha;
break;
case 0x45c0c0ba:
key = ‘t‘ - cha;
break;
case 0x55c0c0aa:
key = ‘u‘ - cha;
break;
case 0x65c0c09a:
key = ‘v‘ - cha;
break;
case 0x75c0c08a:
key = ‘w‘ - cha;
break;
case 0x85c0c07a:
key = ‘x‘ - cha;
break;
case 0x95c0c06a:
key = ‘y‘ - cha;
break;
case 0xa5c0c05a:
key = ‘z‘ - cha;
break;
case 0x26c0c0d9:
//key = ‘-‘;
Sleep(1000);
break;
case 0x41c0c0be:
if(cha == 0)
cha = ‘a‘ - ‘A‘;
else
cha = 0;
break;
}
// msg.Format( "wParam=0x%08x, lParam=0x%02x key=%c\n", wParam, lParam, ‘?‘ );
if(key!=‘?‘)
{
//if(key == ‘-‘)
msg.Format("wParam=%x, lParam=0x%02x key=%c\n", wParam, lParam, key );
}
m_rc_msg += msg;
UpdateData( FALSE );
return 0;
}
遥控器模拟键盘还原成电脑键盘(方法二),布布扣,bubuko.com
原文:http://blog.csdn.net/ying909175415/article/details/20639437