读书人

看看小弟我的代码那错了

发布时间: 2012-02-05 12:07:15 作者: rapoo

看看我的代码那错了?
m_message_tag = packed record
AsciiCode: DWORD;
scanCode: DWORD;
flags: DWORD;
time: DWORD;
dwExtraInfo:DWORD;
end;
m_message = ^m_message_tag;

function m_hookproc (nCode: Integer;WParam: WPARAM;LParam: LPARAM):LRESULT; stdcall;
var
p:m_message;
s:string;
begin
p:=m_message(LParam);
if p.AsciiCode=65 then p.AsciiCode=66; //(1)如果按下的“a”则该成“b”,这里为什么不对呀。
Result:=CallNextHookEx(m_hook,ncode,Wparam,lParam);
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
m_hook := SetWindowsHookExW(WH_KEYBOARD_LL,m_hookproc, Hinstance, 0);
end;



我该怎么做才能使按下a的时候转换成b?


[解决办法]
你要控制哪个控件的按键,然后

就用你的WINPROC替代原控件的WINPROC,因为每一个控件都有自己的消自己循环的哦!


如 EDIT,FORM......

读书人网 >.NET

热点推荐