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

📄 xmit.cpp

📁 Windows Mobile平台的日文输入法
💻 CPP
字号:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES OR INDEMNITIES.
//
/*++

	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.

	Module Name:  

	xmit.cpp

Module Name

	xmit.cpp

Abstract:

	Calls SOFTKB with results.  These functions are called from RTHREAD.C to eliminate posting 
	messages to WPAD and Main just to get results back.  Faster and no more timing errors!
	
--*/

#include <windows.h>
#include <commctrl.h>
#ifndef	UNDER_CE
#include "wchar.h"
#endif
#include "resource.h"
#include "dllmain.h"
#include "im.h"

#include "multibox.h"

extern	IIMCallback	   *g_pIMCallback;
extern	IIMCallbackEx  *g_pIMCallbackEx;

#ifndef	UNDER_CE
#define	KEYEVENTF_SILENT	0
#endif

extern "C"
{
extern	int		giHalf;
};

void SendIMEOnSpace()
{
	HWXRESULTPRI   *phr;
	phr = (HWXRESULTPRI *) LocalAlloc(LPTR, sizeof(HWXRESULTPRI));

	if (phr == (HWXRESULTPRI *) NULL)
		return;

	phr->cbCount = 1;
	phr->awchAlts[0] = giHalf ? 0x0020 : 0x3000;
	phr->anScore[0] = 0;

	SendAltList(phr);
}

void SendIMEOnSpace2()
{
	UINT uChar;
    KEY_STATE_FLAGS nShiftState;

	if ( giHalf )
	{
		uChar = 0x0020;
	} else {
		uChar = 0x3000;
	}
	nShiftState = KeyStateDownFlag;
	g_pIMCallbackEx->SendCharEvents(VK_PROCESSKEY,nShiftState,1,&nShiftState,&uChar);
	nShiftState = KeyShiftNoCharacterFlag;
	g_pIMCallbackEx->SendCharEvents(VK_PROCESSKEY,nShiftState,1,&nShiftState,&uChar);
}

void SendIMEOffSpace()
{
	UINT uChar;
    KEY_STATE_FLAGS nShiftState;
    DWORD dwVkFlags;
	BYTE	bVk = VK_SPACE;

	if ( giHalf )
	{
        dwVkFlags = KEYEVENTF_SILENT;
		g_pIMCallbackEx->SendVirtualKey(bVk, dwVkFlags );
        dwVkFlags = KEYEVENTF_KEYUP | KEYEVENTF_SILENT;
		g_pIMCallbackEx->SendVirtualKey(bVk, dwVkFlags );
	}
	else
	{
		uChar = 0x3000;
		nShiftState = KeyStateDownFlag;
		g_pIMCallbackEx->SendCharEvents(bVk,nShiftState,1,&nShiftState,&uChar);
		nShiftState = KeyShiftNoCharacterFlag;
		g_pIMCallbackEx->SendCharEvents(bVk,nShiftState,1,&nShiftState,&uChar);
	}
}

void SendProperSpace()
{
	if ( ImmGetOpenStatus((HIMC)NULL) &&
		 ImmGetCompositionString(NULL,GCS_COMPSTR,NULL,0) )
	{
		SendIMEOnSpace();
	}
	else if ( ImmGetOpenStatus((HIMC)NULL) &&
		 	  !ImmGetCompositionString(NULL,GCS_COMPSTR,NULL,0) )
	{
		SendIMEOnSpace2();
	}
	else
	{
	 	SendIMEOffSpace();
	}

}

void SendVKCode(WPARAM wParam)
{
	switch (wParam)
	{
	case VK_RETURN:
#ifdef	UNDER_CE
		{
			UINT	nShiftState;
			UINT	uChar;

			uChar = 0x0d;
			nShiftState = KeyStateDownFlag;
			g_pIMCallback->SendCharEvents(VK_RETURN,nShiftState,1,&nShiftState,&uChar);
			nShiftState = KeyShiftNoCharacterFlag;
			g_pIMCallback->SendCharEvents(VK_RETURN,nShiftState,1,&nShiftState,&uChar);
			break;
		}
#endif

	case VK_SPACE:
	case VK_BACK:
	case VK_ESCAPE:
	case VK_DELETE:
	case VK_CONVERT:
		g_pIMCallback->SendVirtualKey(wParam,KEYEVENTF_SILENT);
		g_pIMCallback->SendVirtualKey(wParam,KEYEVENTF_KEYUP | KEYEVENTF_SILENT);
		break;

	default:
		break;
	}
}

void SendString(LPTSTR psz, DWORD cch)
{
	g_pIMCallback->SendString(psz, cch);
}

void SendCharEvent(UINT wVK, UINT wChar, UINT wFlags, UINT wShift)
{
	g_pIMCallback->SendCharEvents(wVK, wFlags, 1, &wShift, &wChar);
}

void *MakeLMDATA(HWXRESULTPRI *phr)
{
	LMDATA		   *plm;
	WORD		   *pw;
	DWORD		   *pdw;
	int				ialt;
	int				cbSize;

	// Properly byte align the DWORD's after the WORD's.  This should only affect
	// us when we have an odd number of characters.
	cbSize = sizeof(WORD) * ((phr->cbCount + 1) & ~1) + sizeof(DWORD) * phr->cbCount;
	plm = (LMDATA *) LocalAlloc(LPTR, sizeof(LMDATA) + cbSize);

	if (plm != (LMDATA *) NULL)
	{
		plm->dwVersion = 0x00010000;
		plm->flags = 0x00000102;
		plm->cnt = phr->cbCount;
		plm->dwOffsetSymbols = 0;
		plm->dwOffsetSkip = 0;
		plm->dwOffsetScore = sizeof(WORD) * ((plm->cnt + 1) & ~1);

		pw  = (WORD *)  &plm->ab[plm->dwOffsetSymbols];
		pdw = (DWORD *) &plm->ab[plm->dwOffsetScore];

		for (ialt = 0; ialt < phr->cbCount; ialt++)
		{
			pw[ialt]  = phr->awchAlts[ialt];
			pdw[ialt] = phr->anScore[ialt];
		}
	}

	LocalFree(phr);

	return (void *) plm;
}

void SendAltList(HWXRESULTPRI *phr)
{
	g_pIMCallbackEx->SendAlternatives((LMDATA *) MakeLMDATA(phr));
}

⌨️ 快捷键说明

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