急!!!翻译原码(c++ -> pascal) ****(400大分)**** (200分)

  • 主题发起人 主题发起人 ronaldun
  • 开始时间 开始时间
R

ronaldun

Unregistered / Unconfirmed
GUEST, unregistred user!
(****請看下面我新貼出的貼子﹐只希望能幫我檢查我所翻譯的內容﹗﹗﹗*****)
有谁可帮我翻译这份原始档(要求转成pascal)?
(积分不够可以再加啊!!)
!!!!!!*******************************************
若不能翻译全部,都能希望能帮我翻译这个function:
1. BOOL CIM::GetCandidateList(HWND hWnd){......}
2. BOOL CIM::CandidateToString(LPCANDIDATELIST lpCandidateList)
!!!!!************************************************

//******************************************************************//
// 做这个东西的时候得到了论坛上网友的热心帮助,整理之后再送给大家
// 这是个在DX程序下使用系统输入法的解决方案,可能有点bug :)
// 不过还没发现,如果发现了,告诉我啊 jerrywang@163.net
// 程序中使用的CHK()CHKB()是为了监测内存泄漏,可以去掉,CTTFFONT
// 为显示信息用,可以用其它方法替换如 TxtOut() 等
//  http://go2.163.com/jerrywang/
//******************************************************************//
//////////////////////////////////////////////////////////////////////
// IM.h: CIM class (使用系统)输入法类
// 2001/4/30 Write by Jerry Wang
// 感谢大大鱼的帮助
// Need Lib: imm32.lib
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_IM_H__6887B165_972D_4D17_8A75_FE07930CE59C__INCLUDED_)
#define AFX_IM_H__6887B165_972D_4D17_8A75_FE07930CE59C__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define _CIM_MAXINPUTCHARNUMBER 24 //最多输入的字节数
#include "FindMe.h"
class CIM
{
private:
CTTFFont ttffont; //显示信息
LPCANDIDATELIST m_lpCandList; //输入法候选文字列表
LPSTR m_lpszImeInput; //指向IME输入的文字字符串指针
LPSTR m_lpszCurInputLanguageDesc;
//指向当前输入语言描述的指针
char m_cCandidateList[255]; //候选文字列表缓冲区
char m_cInput[64]; //输入的字母
BOOL CandidateToString(
  LPCANDIDATELIST lpCandidateList
   ); //转换候选文字列表到字符串
public:
CIM();
virtual ~CIM();
LPSTR GetResultString( void ); //取得输入的字符串
void UpdateShow( ); //显示输入法信息
LPSTR GetCurInputLanguageDesc( ); //取得应用程序当前使用语言的描述
void ClearCandidateList( void ); //清除输入法文字候选列表
BOOL GetCandidateList( HWND hWnd ); //取得输入法文字候选列表
BOOL ImeIsOpen( void ); //输入法是否打开
void OnChar( TCHAR ch ); //处理WM_IME_CHAR消息
void OnImeNotify( HWND hWnd,
    WPARAM wParam );         //处理WM_IME_NOTIFY消息
void OnImeComposition( HWND hWnd,
    LPARAM lParam );   //处理WM_IME_COMPOSITION消息
};
#endif // !defined(AFX_IM_H__6887B165_972D_4D17_8A75_FE07930CE59C__INCLUDED_)
//****************************************************************************//
//////////////////////////////////////////////////////////////////////
//
// IM.cpp: CIM class (使用系统)输入法类
// 2001/4/30 Write by Jerry Wang
// 感谢大大鱼的帮助
// Need Lib: imm32.lib
//
//////////////////////////////////////////////////////////////////////
#include "imm.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CIM::CIM()
{
m_lpszImeInput = new char[_CIM_MAXINPUTCHARNUMBER];
ZeroMemory( m_lpszImeInput,_CIM_MAXINPUTCHARNUMBER );
*m_lpszImeInput = '/0';
*m_cInput = '/0';
ttffont.Create( "黑体",15,RGB(255,255,255) );
GetCurInputLanguageDesc();
}
CIM::~CIM()
{
ZeroMemory( m_lpszImeInput,_CIM_MAXINPUTCHARNUMBER );
CHKB( delete m_lpszImeInput );
if( m_lpszCurInputLanguageDesc != NULL )
CHKB( delete m_lpszCurInputLanguageDesc );
}
void CIM::OnImeComposition(HWND hWnd, LPARAM lParam)
{
if (lParam &
GCS_RESULTSTR)
{
HIMC hIMC; //输入设备上下文
DWORD dwLen;
LPSTR lpResultStr;
hIMC = ImmGetContext(hWnd); //取得输入上下文
if (!hIMC)
return;
dwLen = ImmGetCompositionString(hIMC,GCS_RESULTSTR,NULL,0L);
dwLen+=1;
if(dwLen)
{
lpResultStr = new char[ dwLen ];
//// 缓冲区已经满了
if( strlen( m_lpszImeInput ) + dwLen > _CIM_MAXINPUTCHARNUMBER - 2 )
{
MessageBeep( 0 );
return;
}
ZeroMemory( lpResultStr ,dwLen );
if (lpResultStr)
{
ImmGetCompositionString(hIMC,GCS_RESULTSTR,
lpResultStr,dwLen);
strcat( m_lpszImeInput,lpResultStr );
}
delete lpResultStr;
}
ImmReleaseContext(hWnd,hIMC); //释放输入上下文
}

}
void CIM::OnImeNotify(HWND hWnd, WPARAM wParam)
{
DWORD dwCommand = (DWORD) wParam;
switch( dwCommand )
{
case IMN_CHANGECANDIDATE:
GetCandidateList( hWnd );
break;
case IMN_CLOSECANDIDATE:
ClearCandidateList();
break;
case IMN_OPENCANDIDATE:
GetCandidateList( hWnd );
break;
}
}
void CIM::OnChar( TCHAR ch )
{
int len = strlen( m_lpszImeInput );
if( ImeIsOpen() ) //输入法打开状态
{
}
else
//输入法关闭状态
{
    //输入的是英文字母
if( ch >= 32 &&
ch < 128 &&
len < _CIM_MAXINPUTCHARNUMBER - 1 ) {
*( m_lpszImeInput + len ) = ch;
*( m_lpszImeInput + len + 1) = '/0';
}
}
if( ch == 8 ) //BackSpace字符
{
if( len == 0 ) //字符串长度为零
return;
if( len == 1 ) //只有一个字符
{
*m_lpszImeInput = '/0';
return;
}
BYTE cc1,cc2;
cc1 = *(m_lpszImeInput + len -1); //分离字节
cc2 = *(m_lpszImeInput + len -2);
if( cc1 > 0xA0 &&
cc2 > 0xA0 ) //中文双字节的每个字节都>0xA0
*( m_lpszImeInput + len -2 ) = '/0';
else
//是英文字符(单字节)
*( m_lpszImeInput + len -1 ) = '/0';
}
}
BOOL CIM::GetCandidateList(HWND hWnd)
{
DWORD dwSize;
HIMC hIMC;
ZeroMemory( m_cCandidateList,sizeof(m_cCandidateList) );
if( m_lpCandList )
{
delete m_lpCandList;
m_lpCandList = NULL;
}
if( GetKeyboardLayout(0)==0 )
{
return FALSE;
}
hIMC = ImmGetContext(hWnd); //取得输入上下文
if(hIMC == NULL)
{
return FALSE;
}

ZeroMemory( m_cCandidateList,sizeof(m_cCandidateList) );
if(dwSize = ImmGetCandidateList(hIMC,0x0,NULL,0))
{
m_lpCandList = (LPCANDIDATELIST)new char[dwSize];
if(m_lpCandList)
{
ImmGetCandidateList(hIMC,0x0,m_lpCandList,dwSize);
CandidateToString(m_lpCandList);
}
}

ImmReleaseContext(hWnd,hIMC);
return TRUE;
}
void CIM::ClearCandidateList()
{
if(m_lpCandList)
{
delete m_lpCandList;
m_lpCandList = NULL;
}
ZeroMemory( m_cCandidateList,sizeof( m_cCandidateList ) );
}

LPSTR CIM::GetCurInputLanguageDesc()
{
HKL hKL = GetKeyboardLayout(0);

if( m_lpszCurInputLanguageDesc != NULL )
CHKB( delete m_lpszCurInputLanguageDesc ); //删除先 ^o^
int lengh = ImmGetDescription(hKL,NULL,0); //取得描述的长度
CHK( m_lpszCurInputLanguageDesc = new char[ lengh ] );
if( lengh )
{
ImmGetDescription(hKL,m_lpszCurInputLanguageDesc,lengh);
}
else
{
strcpy( m_lpszCurInputLanguageDesc,"输入法关闭" );
}
return m_lpszCurInputLanguageDesc;
}
void CIM::UpdateShow()
{
POINT pt;
pt.y = 450;
pt.x = 400;
ttffont.SetSurface( DD_GetBackScreen() );
ttffont.ShowText( m_lpszCurInputLanguageDesc,
    &pt,
    RGB( 255,255,0 ));  //显示输入法描述
pt.y = 420;
pt.x = 20;
ttffont.ShowText( m_cCandidateList,&pt );

pt.y = 450;
pt.x = 20;
if( *m_lpszImeInput == '/0' )
return;
ttffont.ShowText( m_lpszImeInput,&pt,RGB( 255,255,0 )); //输入的文字
}
LPSTR CIM::GetResultString()
{
return m_lpszImeInput;
}
BOOL CIM::CandidateToString(LPCANDIDATELIST lpCandidateList)
{
if( !m_lpCandList )
return FALSE;
if( m_lpCandList->dwCount>0 )
{
LPDWORD lpdwOffset;
lpdwOffset = &m_lpCandList->dwOffset[0];
lpdwOffset += m_lpCandList->dwPageStart;
ZeroMemory( m_lpCandList,sizeof( m_lpCandList ) );

DWORD z=1;
for (DWORD i = m_lpCandList->dwPageStart;

(i < lpCandidateList->dwCount) &&

(i < m_lpCandList->dwPageStart + m_lpCandList->dwPageSize);
i++)
{
LPSTR lpstr = (LPSTR)m_lpCandList + *lpdwOffset++;
char buf[255];
sprintf( buf,"%d.%s",z,lpstr );
strcat( m_cCandidateList,buf );
z++;
}
return TRUE;
}
return FALSE;
}
BOOL CIM::ImeIsOpen()
{
return ImmIsIME( GetKeyboardLayout(0) );
}
 
好长啊,要是改成PASCAL要好半天了,可能还有搞什么record的,天![:(]
 
请各位尽量帮助我吧,我已翻译了几天了,不过还未能实现这程序的全部功能,所以才找各位高人协助。
 
你最好只提出碰到什么困难,而不能指望别人帮你翻译完。 [:)]
 
这可不是几百分的问题,很费精力的。
 
请大侠们帮忙看看这个:
http://www.delphibbs.com/delphibbs/dispq.asp?lid=1098619
谢谢!!!
 
既然如此,我就附上我所翻译的原码,希望各位能够帮忙。
<a href="http://bblight.uhome.net/temp/ime.zip">下载请按这里</a>
主要是想各位能检出我在
procedure ConvertCandList(pCandList:pCANDIDATELIST;var pszCandList:pchar );
procedure CandidateToString(pCandList:PCANDIDATELIST );
这两个procedure所转换的错误,拜托!

unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,imm, Menus;
type
TForm1 = class(TForm)
Edit1: TEdit;
Memo1: TMemo;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Memo2: TMemo;
procedure Edit1KeyUp(Sender: TObject;
var Key: Word;
Shift: TShiftState);
procedure FormDblClick(Sender: TObject);
procedure FormClick(Sender: TObject);
procedure Label1Click(Sender: TObject);
procedure Label2Click(Sender: TObject);
procedure Label3Click(Sender: TObject);
procedure Label4Click(Sender: TObject);
procedure Label5Click(Sender: TObject);
private
public
a:boolean;
g_nImeCursor:longint;
g_lpcandlist:PCandidateList;
g_bImeSharp,g_bImeSymbol:boolean;
g_szCandList,g_szImeName,g_szCompStr,g_szCompReadStr:pchar;
cHIMC:hIMC;
aHWND:hWnd;
aWPARAM:wParam;
dwConversion, dwSentence,dwSize:dword;
g_bime:boolean;
procedure add(msg:variant);
function IfImeSharp:boolean;//岆瘁&#63477;倛
function IfImeSymbol:boolean;//岆瘁笢恅梓萸
procedure NextIme;//ピ遙善狟珨笱怀&#11980;楊ㄛ斛剕EnableIme綴符衄虴
procedure SharpIme( cHWND:hWnd );//ピ遙&#63477;倛/圉倛
procedure SymbolIme( cHWND:hWnd );//ピ遙笢/荎恅梓萸
function GetImeName:pchar;//腕善怀&#11980;楊靡趼ㄛ&#11964;彆絞ゴ岆荎恅寀殿隙NULL
//袨怓滲杅
procedure GetImeInput(var pszCompStr,pszCompReadStr:pchar;
var pnImeCursor:integer;
var pszCandList:pchar );
procedure DisableIme;//壽敕甜輦砦怀&#11980;楊ㄛ&#11964;ime眒冪湖羲寀壽敕ㄛ森綴俙模祥夔蚚&#63506;瑩網堤ime
procedure EnableIme;//埰勍怀&#11980;楊ㄛ森綴俙模褫眕蚚&#63506;瑩網堤ime
//messsage
procedure OnWM_IME_COMPOSITION(var message:tmessage );
message WM_IME_COMPOSITION;
procedure OnWM_INPUTLANGCHANGEREQUEST(var message:tmessage );
message WM_INPUTLANGCHANGEREQUEST;
procedure OnWM_IME_SETCONTEXT(var message:tmessage );
message WM_IME_SETCONTEXT;
procedure OnWM_IME_STARTCOMPOSITION(var message:tmessage );
message WM_IME_STARTCOMPOSITION;
procedure OnWM_IME_ENDCOMPOSITION(var message:tmessage );
message WM_IME_ENDCOMPOSITION;
procedure OnWM_INPUTLANGCHANGE(var message:tmessage );
message WM_INPUTLANGCHANGE;
procedure OnWM_IME_NOTIFY(var message:tmessage );
message WM_IME_NOTIFY;
procedure ConvertCandList(pCandList:pCANDIDATELIST;var pszCandList:pchar );
procedure CandidateToString(pCandList:PCANDIDATELIST );
end;

var
Form1: TForm1;
implementation
//uses directxime;
{$R *.dfm}
procedure tform1.CandidateToString(pCandList:PCANDIDATELIST );
var lpdwOffset:LPDWORD;
z,i:DWORD;
clpstr:LPSTR;
buf:pchar;
temp:string;
begin
z:=1;
//if( pCandList<>nil )then
return FALSE;
if( pCandList.dwCount>0 ) then
begin
//
lpdwOffset := lpdword(pCandList.dwOffset[1]);
lpdwoffset:=pdword(pCandList.dwOffset[1]+pCandList.dwPageStart);
//ZeroMemory( pCandList,sizeof(pCandList ) );
// pCandList.dwPageStart
for i := 0 to (pCandList.dwCount div pcandlist.dwPageSize) do
if i < pCandList.dwPageStart +pCandList.dwPageSize then
begin

inc(lpdwoffset);//:=lpdwOffset+1;
str(cardinal(lpdwOffset),temp);
clpstr:= LPSTR(pchar(pCandList)+temp) ;
memo2.text:=memo2.text+buf+inttostr(z)+clpstr;
//strcat( buf,pchar(pCandList) );
// pcandlist:=pcandlist AND buf;
inc(z);
end;
end;
end;

procedure tform1.ConvertCandList(pCandList:pCANDIDATELIST;var pszCandList:pchar );
var i:longword;
temp,temp1:pchar;
tmpstr,tmpstr1:string;
begin
add('ConvertCandList');
//ZeroMemory( pszCandList,sizeof(pszCandList) );
if( pCandList<>nil ) then
begin
pCandList := nil;
end;
if( GetKeyboardLayout(0)=0 ) then
exit;
chIMC := ImmGetContext(form1.Handle); //&#63467;腕怀&#11980;奻狟恅
if(chIMC =0)then
exit;
//ZeroMemory( pszCandList,sizeof(pszCandList) );
if(dwSize = ImmGetCandidateList(chIMC,0,nil,0)) then
begin
pCandList :=new(pcandidatelist);
if(pCandList<>nil)then
begin
ImmGetCandidateList(chIMC,0,pCandList,dwSize);
CandidateToString(pCandList);
end;
end;

ImmReleaseContext(ahWnd,chIMC);

end;

procedure tform1.NextIme();
begin
if( g_bIme ) then
ActivateKeyboardLayout(HKL_NEXT, 0 );
end;

procedure tform1.SharpIme( cHWND:hWnd );
begin
ImmSimulateHotKey( chWnd, IME_CHOTKEY_SHAPE_TOGGLE );
end;

procedure tform1.SymbolIme( cHWND:hWnd );
begin
ImmSimulateHotKey( chWnd, IME_CHOTKEY_SYMBOL_TOGGLE );
end;

procedure tform1.DisableIme;
begin
while( ImmIsIME( GetKeyboardLayout( 0 ))) do
ActivateKeyboardLayout(HKL_NEXT, 0 );//&#11964;彆ime湖羲籵徹隙&#63472;ピ遙善狟珨跺壽敕

g_bIme := false;
g_szImeName:=nil;
g_szCompStr:=nil;
g_szCompReadStr:=nil;
g_szCandList:=nil;
g_nImeCursor := 0;
end;

procedure tform1.EnableIme;
begin
g_bIme := true;
end;

function tform1.GetImeName:pchar;
begin
if g_szImeName<>nil then
getimename:=g_szImeName
else
GetImeName:= nil;
end;

function tform1.IfImeSharp():boolean;//岆瘁&#63477;倛
begin
ifimesharp:=g_bImeSharp;
end;

function tform1.IfImeSymbol():boolean;//岆瘁笢恅梓萸
begin
IfImeSymbol:=g_bImeSymbol;
end;

procedure tform1.GetImeInput( var pszCompStr:pchar;var pszCompReadStr:pchar;
var pnImeCursor:integer;
var pszCandList:pchar );
begin
if( pszCompStr<>nil) then
pszCompStr:= g_szCompStr;
if( pszCompReadStr<>nil ) then
pszCompReadStr := g_szCompReadStr;
if( pnImeCursor<>0 )then
pnImeCursor := g_nImeCursor;
if( pszCandList<>nil )then
pszCandList := g_szCandList;
end;

procedure tform1.OnWM_IME_SETCONTEXT(var message:tmessage );
begin
add('OnWM_IME_SETCONTEXT');
//
end;

procedure tform1.OnWM_IME_STARTCOMPOSITION(var message:tmessage );
begin
add('OnWM_IME_STARTCOMPOSITION');
//
end;

procedure tform1.OnWM_IME_ENDCOMPOSITION(var message:tmessage );
begin
add('OnWM_IME_ENDCOMPOSITION');
//
end;

procedure tform1.OnWM_INPUTLANGCHANGEREQUEST(var message:tmessage );
var f:tmessage;
begin
add('OnWM_INPUTLANGCHANGEREQUEST');
getimeinput(g_szCompStr,g_szCompReadStr,g_nImeCursor,g_szCandList );
//
end;

procedure tform1.OnWM_INPUTLANGCHANGE(var message:tmessage );
var chkl:HKL;
begin
add('OnWM_INPUTLANGCHANGE');
//ime蜊曹
cHKL:= GetKeyboardLayout( 0 );
if( ImmIsIME( chKL )) then
begin
cHIMC:= ImmGetContext( ahwnd );
ImmEscape( chKL, chIMC, IME_ESC_IME_NAME, g_szImeName);//&#63467;腕陔怀&#11980;楊靡趼
ImmGetConversionStatus( chIMC, dwConversion, dwSentence );
if (dwConversion=IME_CMODE_FULLSHAPE) then
g_bImeSharp := true//&#63467;腕&#63477;倛梓祩
else
g_bImeSharp := false;
if ( dwConversion=IME_CMODE_SYMBOL ) then
g_bImeSymbol := true
else
g_bImeSymbol := false;//&#63467;腕笢恅梓萸梓祩
ImmReleaseContext( ahWnd, chIMC );
end
else
//荎恅怀&#11980;
g_szImeName:=nil;
//軞岆殿隙falseㄛ秪峈剒猁弝敦滲杅覃蚚DefWindowProc樟哿揭燴
end;

procedure tform1.OnWM_IME_COMPOSITION(var message:tmessage);//怀&#11980;蜊曹
var
p,str:pchar;
begin
p:='';
str:='';
chIMC := ImmGetContext( ahWnd );
if( message.LParam = GCS_COMPSTR ) then
begin
dwSize := ImmGetCompositionString( chIMC, GCS_COMPSTR, g_szCompStr, sizeof( g_szCompStr ));
//changed
g_szCompStr:= nil;
end;
//&#63467;腕szCompStr
if( message.LParam = GCS_COMPREADSTR )then
begin
dwSize := ImmGetCompositionString( chIMC, GCS_COMPREADSTR,g_szCompReadStr, sizeof( g_szCompReadStr ));
//changed
g_szCompReadStr := nil;
end;
//&#63467;腕szCompReadStr
if( message.LParam = GCS_CURSORPOS )then
begin
g_nImeCursor := 65535 and ImmGetCompositionString( chIMC, GCS_CURSORPOS, Nil, 0 );
end;
//&#63467;腕nImeCursor
if( message.LParam = GCS_RESULTSTR )then
begin
dwSize := ImmGetCompositionString( chIMC, GCS_RESULTSTR, str, sizeof( str ));//&#63467;腕犖趼怀&#11980;揹
//changed
str := nil;
p := str;
while( p<>nil ) do
begin
PostMessage( ahWnd, WM_CHAR, WPARAM(p), 1 );//蛌傖WM_CHAR秏洘
inc(p);
end;
end;
ImmReleaseContext( ahWnd, chIMC );
add('OnWM_IME_COMPOSITION');//軞岆殿隙trueㄛ滅砦ime弝敦湖羲
end;

procedure tform1.OnWM_IME_NOTIFY(var message:tmessage );
begin
add('OnWM_IME_NOTIFY');
//ahwnd:=form1.Handle;
//ImmGetDefaultIMEWnd()
awparam:=message.WParam;
//chimc:= ImmGetContext( ahWnd );
case awParam of
IMN_SETCONVERSIONMODE://&#63477;倛/圉倛ㄛ笢/荎恅梓萸蜊曹
begin
ImmGetConversionStatus( chIMC, dwConversion, dwSentence );
if dwConversion =IME_CMODE_FULLSHAPE then
g_bImeSharp := true
else
g_bImeSharp := false;
if ( dwConversion = IME_CMODE_SYMBOL ) then
g_bImeSymbol := true
else
g_bImeSymbol := false;
add('&#63477;倛/圉倛ㄛ笢/荎恅梓萸蜊曹');
ImmReleaseContext( ahWnd, chIMC );
end;
IMN_OPENCANDIDATE:
begin
add('輛&#11980;恁趼袨怓');//輛&#11980;恁趼袨怓
if( g_lpCandList<>nil ) then
ConvertCandList( g_lpCandList, g_szCandList );//恁趼桶淕燴傖揹
end;
IMN_CHANGECANDIDATE://恁趼桶楹珜
begin
add('恁趼桶楹珜');
if( g_lpCandList<>nil ) then
begin
//庋溫眕ゴ腔恁趼桶
// freemem(g_lpcandlist);
// g_lpCandList := Nil;
end;
if( dwSize = ImmGetCandidateList( chIMC, 0, nil, 0 )) then
begin
// LPCANDIDATELIST
g_lpCandList := pcandidatelist(GlobalAlloc( GPTR, dwSize ));
if( g_lpCandList<>nil ) then
ImmGetCandidateList( chIMC, 0, g_lpCandList, dwSize );
end;
//腕善陔腔恁趼桶
if( g_lpCandList<>nil ) then
ConvertCandList( g_lpCandList, g_szCandList );//恁趼桶淕燴傖揹
ImmReleaseContext( ahWnd, chIMC );
end;
IMN_CLOSECANDIDATE://壽敕恁趼桶
begin
add('壽敕恁趼桶');
if( g_lpCandList<>nil )then
begin
//freemem(g_lpcandlist);
g_lpCandList := Nil;
end;
//庋溫
g_szCandList:=nil;
end;
end;

end;

procedure tform1.add(msg:variant);
begin
memo1.Lines.Add(msg);
end;

procedure TForm1.Edit1KeyUp(Sender: TObject;
var Key: Word;
Shift: TShiftState);
var f:tmessage;
begin
end;

procedure TForm1.FormDblClick(Sender: TObject);
begin
EDIT1.Enabled:=NOT EDIT1.Enabled;
end;

procedure TForm1.FormClick(Sender: TObject);
var s:string;
begin
s:=getimename;
add(s);
end;

procedure TForm1.Label1Click(Sender: TObject);
begin
enableime;
nextime;
end;

procedure TForm1.Label2Click(Sender: TObject);
begin
disableime;
end;

procedure TForm1.Label3Click(Sender: TObject);
begin
nextime;
end;

procedure TForm1.Label4Click(Sender: TObject);
begin
sharpime(form1.Handle);
end;

procedure TForm1.Label5Click(Sender: TObject);
begin
symbolime(form1.Handle);
end;

end.
 
大概是这样,这里网吧,只能这样了。:)
function GetCandidateList(Handle: THandle): Boolean;
var
dwSize: DWORD;
hImc: HIMC;
begin
FillChar(m_cCandidateList^, SizeOf(m_cCandidateList));
if Assigned(m_lpCandList) then
begin
FreeMem(m_lpCandList);
m_lpCandList := nil;
end;

Result := GetKeyboardLayout(0) <> 0;
if not Result then
Exit;
hImc := ImmGetContext(Handle);
Result := hImc <> 0;
if not Result then
Exit;
FillChar(m_cCandidateList, SizeOf(m_cCandidateList));
dwSize := ImmGetCandidateList(hImc, 0, nil, 0);
if dwSize > 0 then
begin
GetMem(m_lpCandList, dwSize);
ImmGetCandidatelist(hImc, 0, m_lpCandList, dwSize);
CandidateToString(m_lpCandList);
end;
ImmReleaseContext(hWnd,hIMC);
end;

function CandidateToString(lpCandidateList: LPCANDIDATELIST);
var
I, Z: DWORD;
Buf: string;
lpStr: PChar;
lpOffset: PDWORD;
begin
Result := False;
if not Assigned(m_lpCandList) then
Exit;

if PCandidateList(m_lpCandList)^.dwCount > 0 then
begin
lpOffset := @m_lpCandList^.dwOffset[0];
lpOffset := Integer(lpOffset) + m_lpCandList^.dwPageStart;
FillChar(m_lpCandList^, SizeOf(m_lpCandList);
I := 0;
with m_lpCandList^ do

while (I < (lpCandidateList^.dwCount - 1)) and (I < dwPageStart + dwPageSize) do
begin
//得到一个指向字符串的指针
lpStr := PChar(Integer(m_lpCandList) + lpOffset^);
Inc(lpOffset);
//得到字符串
Buf := Format('%d, %s', [Z, StrPas(lpStr)]);
m_cCandidateList := m_cCandidateList + Buf;
Inc(Z);
end;
end;
end;
 
后退
顶部