⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 im.cpp

📁 EP9315开发板的Wince6.0的BSP包文件
💻 CPP
字号:
//**********************************************************************
//                                                                      
// Filename: window.h
//                                                                      
// Description: 
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Use of this source code is subject to the terms of the Cirrus end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to 
// use this source code. For a copy of the EULA, please see the 
// EULA.RTF on your install media.
//
// Copyright(c) Cirrus Logic Corporation 2005, All Rights Reserved                       
//                                                                      
//**********************************************************************

#include <windows.h>
#include <commctrl.h>
#include <sipapi.h>
//#include "resource.h"
#include "dllmain.h"
#include "im.h"
#include "keybd.h"


static IIMCallback *g_pIMCallback = NULL;
static HWND			g_hwndMain=NULL;

//static TCHAR const g_pwszClassName[] = TEXT("95429667-ae14-12d0-a0f8-11aa00a04999 - CirusLogicNULLKeyboard");
static TCHAR const g_pwszClassName[] = TEXT("42429667-ae04-11d0-a4f8-00aa00a749b9 - CirusLogicNULLKeyboard");

//{F2D1A07D-46DE-424c-AE45-A5F07B11AEAE}

//
// Keyboard layouts.  Here we define the VK code, shift, unshifted, and control
// characters, and whether or not the key generates a character or just a VK
// code (and thus should be sent via SendVirtualKey).
//

LRESULT
WINAPI
ImWndProc(
	HWND	hwnd,
	UINT	msg,
	WPARAM	wParam,
	LPARAM	lParam
	)
{
	switch ( msg )
		{
		case WM_PAINT:
			{
			PAINTSTRUCT ps;
			BeginPaint(hwnd, &ps);
			EndPaint(hwnd, &ps);
			}
			return 0;

		case WM_LBUTTONDOWN:
		case WM_LBUTTONUP:
		case WM_MOUSEMOVE:
		case WM_LBUTTONDBLCLK:
			return 0;
			//return IM_OnMouseEvent(hwnd, msg, wParam, lParam);

		}

	return DefWindowProc(hwnd, msg, wParam, lParam);
}





//
// IInputMethod implementation.
//


//
// Ctor, Dtor.
//

CInputMethod::CInputMethod( IUnknown *pUnkOuter, HINSTANCE hInstance )
{
    m_cRef = 0;
    g_dwObjectCount++;

    if( !pUnkOuter ) {
        m_pUnkOuter = this;
    } else {
        m_pUnkOuter = pUnkOuter;
    }

    return;
}

CInputMethod::~CInputMethod()
{
    g_dwObjectCount--;
    return;
}


//
// IInputMethod methods.
//

STDMETHODIMP CInputMethod::Select( HWND hwndSip )
{
    WNDCLASS wc;

    ZeroMemory( &wc, sizeof(wc) );
    wc.style = CS_DBLCLKS;
    wc.lpfnWndProc = ImWndProc;
    wc.hInstance = g_hInstDll;
    wc.hbrBackground = NULL;
    wc.lpszClassName = g_pwszClassName;

    if( !RegisterClass( &wc ) ) {
        return E_FAIL;
    }
    g_hwndMain = CreateWindow(
                        g_pwszClassName,
                        TEXT(""),
                        WS_CHILD,
                        0,
                        0,
                        10,
                        10,
                        hwndSip,
                        (HMENU)NULL,
                        g_hInstDll,
                        NULL );

    ShowWindow( g_hwndMain, SW_SHOWNOACTIVATE );


    return NOERROR;
}


STDMETHODIMP CInputMethod::Deselect( void )
{
    DestroyWindow( g_hwndMain );


    UnregisterClass( g_pwszClassName, g_hInstDll );
	
    return NOERROR;
}


STDMETHODIMP CInputMethod::Showing( void )
{
    ShowWindow( g_hwndMain , SW_HIDE );
	return NOERROR;
}


STDMETHODIMP CInputMethod::Hiding( void )
{
	ShowWindow( g_hwndMain , SW_HIDE );
    return NOERROR;
}


STDMETHODIMP CInputMethod::GetInfo( IMINFO *pimi )
{
    pimi->fdwFlags = SIPF_OFF | SIPF_LOCKED;
    pimi->hImageNarrow = (HANDLE)NULL;
    pimi->hImageWide = (HANDLE)NULL;
    pimi->iNarrow = pimi->iWide = 0;
    pimi->rcSipRect.left = pimi->rcSipRect.top = 0;
    pimi->rcSipRect.right = 20;//BITMAP_WIDTH;
    pimi->rcSipRect.bottom = 20;//BITMAP_HEIGHT;

    return NOERROR;
}


STDMETHODIMP CInputMethod::ReceiveSipInfo( SIPINFO *psi )
{
	ShowWindow( g_hwndMain , SW_HIDE );
	ShowWindow( GetParent( g_hwndMain ), SW_HIDE );

	return NOERROR;
	//return E_NOTIMPL;
}


STDMETHODIMP CInputMethod::RegisterCallback( IIMCallback *pIMCallback )
{
	IMINFO  imminfo;

    g_pIMCallback = pIMCallback;

	GetInfo(&imminfo);

	g_pIMCallback->SetImInfo( &imminfo );
    return NOERROR;
}


STDMETHODIMP CInputMethod::GetImData( DWORD dwSize, void *pvImData )
{
    return E_NOTIMPL;
}


STDMETHODIMP CInputMethod::SetImData( DWORD dwSize, void *pvImData )
{
    return NOERROR;
}


STDMETHODIMP CInputMethod::UserOptionsDlg( HWND hwndParent )
{
  return NOERROR;
}


//
// IUnknown methods.
//

STDMETHODIMP CInputMethod::QueryInterface( REFIID riid, LPVOID FAR* ppobj )
{
    if( IID_IUnknown == riid || IID_IInputMethod == riid ) {
        *ppobj = this;
        AddRef();
        return NOERROR;
    }
    return E_NOINTERFACE;
}

STDMETHODIMP_(ULONG) CInputMethod::AddRef( void )
{
    return ++m_cRef;
}

STDMETHODIMP_(ULONG) CInputMethod::Release( void )
{
    if( --m_cRef ) {
        return m_cRef;
    }
    delete this;
    return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -