半角输入>>:标点半角输入!! (10分)

  • 主题发起人 主题发起人 wiseinfo
  • 开始时间 开始时间
W

wiseinfo

Unregistered / Unconfirmed
GUEST, unregistred user!
用下面的方法可以实现字符的转为半角输入:
h := ImmGetContext(Handle);
if h <> 0 then
if ImmGetConversionStatus(h, fdwConversion, fdwSentence) then //
ImmSetConversionStatus(h, fdwConversion and (not IME_CMODE_FULLSHAPE), fdwSentence);
end;
用immsimulateHotkey(handle,IME_CHotKey_symbol_Toggle);
可以实现切换到半角标点!!但是不知道怎么判断是否已经是半解标点了,因为上面的语句好象
是模拟按键的!!如果再执行一下就又到了全角标点!!有没有象实现半角字符的方法检测是否已经
是半角标点了??



 
对,在不在啊?

不在我就不用了

对了楼主,有它的正式版吗?给我发一个?
eyes@58866.com.cn
 
whf在彻底改写RM,好脱离FR,正大光明的买.
 
我上去了,没问题的吧!!

继续支持!
 
求求你!!
 

h := ImmGetContext(Handle);
if h <> 0 then
if ImmGetConversionStatus(h, fdwConversion, fdwSentence) then
if (fdwConversion and IME_CMODE_FULLSHAPE)=1 then ///////这里判断
ImmSetConversionStatus(h, fdwConversion and (not IME_CMODE_FULLSHAPE), fdwSentence);
end;


 
小伙,下面的好象不行啊!!!我说的是标点的全角/半角,不是字符!!,是输入框上的
那个。,东东,判断他是全角还是半角!
h := ImmGetContext(Handle);
if h <> 0 then
if ImmGetConversionStatus(h, fdwConversion, fdwSentence) then
if (fdwConversion and IME_CMODE_FULLSHAPE)=1 then ///////能够判断,标点全角/或半角吗??
ImmSetConversionStatus(h, fdwConversion and (not IME_CMODE_FULLSHAPE), fdwSentence);
end;
 
IME_CMODE_FULLSHAPE 是位的概念

把它改成 (1 shl IME_CMODE_FULLSHAPE) 试试
还要看位是从哪边开始编的,是从1还是0开始。
查查文档!
 
ImmSetConversionStatus(h, fdwConversion and (not IME_CMODE_FULLSHAPE), fdwSentence);
能够设置标点全角/或半角吗??
 
给你一段C代码参考吧

MODE.C
/**********************************************************************/ /* */ /* MODE.C */ /* */ /* Copyright (c) 1995-1997 Microsoft Corporation */ /* */ /**********************************************************************/ #include "windows.h" #include "imm.h" #include "resource.h" #include "imeapps.h" LRESULT HandleModeCommand(HWND hWnd,WPARAM wParam,LPARAM lParam) { HIMC hIMC = ImmGetContext(hWndCompStr); DWORD dwConv, dwSent; DWORD dwTemp; ImmGetConversionStatus(hIMC,&amp;dwConv,&amp;dwSent); switch(LOWORD(wParam)) { case IDM_NATIVEMODE: dwTemp = dwConv &amp; ~IME_CMODE_LANGUAGE; switch (dwConv &amp; IME_CMODE_LANGUAGE) { case IME_CMODE_ALPHANUMERIC: dwTemp |= IME_CMODE_NATIVE; break; case IME_CMODE_NATIVE: dwTemp |= (IME_CMODE_NATIVE | IME_CMODE_KATAKANA); break; case (IME_CMODE_NATIVE | IME_CMODE_KATAKANA): default: break; } dwConv = dwTemp; break; case IDM_FULLHALF: if (dwConv &amp; IME_CMODE_FULLSHAPE) dwConv &amp;= ~IME_CMODE_FULLSHAPE; else dwConv |= IME_CMODE_FULLSHAPE; break; case IDM_ROMAN: if (dwConv &amp; IME_CMODE_ROMAN) dwConv &amp;= ~IME_CMODE_ROMAN; else dwConv |= IME_CMODE_ROMAN; break; case IDM_CHARCODE: if (dwConv &amp; IME_CMODE_CHARCODE) dwConv &amp;= ~IME_CMODE_CHARCODE; else dwConv |= IME_CMODE_CHARCODE; break; case IDM_HANJA: if (dwConv &amp; IME_CMODE_HANJACONVERT) dwConv &amp;= ~IME_CMODE_HANJACONVERT; else dwConv |= IME_CMODE_HANJACONVERT; break; case IDM_SOFTKBD: if (dwConv &amp; IME_CMODE_SOFTKBD) dwConv &amp;= ~IME_CMODE_SOFTKBD; else dwConv |= IME_CMODE_SOFTKBD; break; case IDM_EUDC: if (dwConv &amp; IME_CMODE_EUDC) dwConv &amp;= ~IME_CMODE_EUDC; else dwConv |= IME_CMODE_EUDC; break; case IDM_SYMBOL: if (dwConv &amp; IME_CMODE_SYMBOL) dwConv &amp;= ~IME_CMODE_SYMBOL; else dwConv |= IME_CMODE_SYMBOL; break; } ImmSetConversionStatus(hIMC,dwConv,dwSent); ImmReleaseContext(hWndCompStr,hIMC); return 1L; } LRESULT HandleConvertCommand(HWND hWnd,WPARAM wParam,LPARAM lParam) { HIMC hIMC = ImmGetContext(hWndCompStr); DWORD dwSel; DWORD dwSize; LPCANDIDATELIST lpCL; switch(wParam) { case IDM_CONVERT: ImmNotifyIME(hIMC,NI_COMPOSITIONSTR,CPS_CONVERT,0); break; case IDM_CANCEL: ImmNotifyIME(hIMC,NI_COMPOSITIONSTR,CPS_CANCEL,0); break; case IDM_REVERT: ImmNotifyIME(hIMC,NI_COMPOSITIONSTR,CPS_REVERT,0); break; case IDM_COMPLETE: ImmNotifyIME(hIMC,NI_COMPOSITIONSTR,CPS_COMPLETE,0); break; case IDM_OPENCAND: ImmNotifyIME(hIMC,NI_OPENCANDIDATE,0,0); break; case IDM_CLOSECAND: ImmNotifyIME(hIMC,NI_CLOSECANDIDATE,0,0); break; case IDM_NEXTCAND: case IDM_PREVCAND: if (dwSize = ImmGetCandidateList(hIMC,0x0,NULL,0)) { lpCL = (LPCANDIDATELIST)GlobalAlloc(GPTR,dwSize); ImmGetCandidateList(hIMC,0x0,lpCL,dwSize); dwSel = lpCL->dwSelection; if (wParam == IDM_NEXTCAND) { if (++dwSel >= lpCL->dwCount) dwSel = 0; } else { if (dwSel) dwSel--; else dwSel = lpCL->dwCount - 1; } GlobalFree((HANDLE)lpCL); ImmNotifyIME(hIMC,NI_SELECTCANDIDATESTR,0,dwSel); } break; } ImmReleaseContext(hWndCompStr,hIMC); return 1; }

 
不行,帮忙试试!!THANK YOU !!
 
象不天书样!!你看看贴的效果!!呵呵~~
搞定后;1477059 的分你想要多少就给多少
 
procedure TForm1.Button1Click(Sender: TObject);
var
h:THandle ;
fdwConversion,fdwSentence:Dword;
begin
edit1.setfocus;
h := ImmGetContext(Edit1.Handle);
if h=0 then exit;
if not ImmGetConversionStatus(h, fdwConversion, fdwSentence) then exit;
if (fdwConversion and (IME_CMODE_FULLSHAPE) )=IME_CMODE_FULLSHAPE then
///// 上面这句这儿
begin
showmessage('设置为半角');
ImmSetConversionStatus(h, fdwConversion and (not IME_CMODE_FULLSHAPE), fdwSentence);
end
else showmessage('已经是半角');

end;
 
jsxjd:原来你搞错了!我下面的代码就可以实现你的功能!!
h := ImmGetContext(Handle);
if h <> 0 then
if ImmGetConversionStatus(h, fdwConversion, fdwSentence) then //
ImmSetConversionStatus(h, fdwConversion and (not IME_CMODE_FULLSHAPE), fdwSentence);
end;
我说的是这个按钮旁边的一个!! 不是月亮那个,是控制标点的那个!!
 
procedure TForm1.Button1Click(Sender: TObject);
var
h:THandle ;
fdwConversion,fdwSentence:Dword;
begin
edit1.setfocus;
h := ImmGetContext(Edit1.Handle);
if h=0 then exit;
if not ImmGetConversionStatus(h, fdwConversion, fdwSentence) then exit;

if (fdwConversion and (IME_CMODE_FULLSHAPE) )=IME_CMODE_FULLSHAPE then
begin
showmessage('设置为半角');
ImmSetConversionStatus(h, fdwConversion and (not IME_CMODE_FULLSHAPE), fdwSentence);
end
else showmessage('已经是半角');


//////////加以下这一段
if (fdwconversion and 1024)=1024 then
begin
showmessage('设置为标点半角');
ImmSetConversionStatus(h, fdwConversion and (not 1024), fdwSentence);
end
else showmessage('已经是标点半角');

end;

///////// 我到 1477059 报到
 
上面的 1024 就是 IME_CMODE_SYMBOL
 

Similar threads

I
回复
0
查看
774
import
I
I
回复
0
查看
665
import
I
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
后退
顶部