하나의 대안 옵션은 주식 표준 편집 컨트롤을 메시지 후크 기능과 함께 사용하는 것입니다.
이렇게하면 WM_KEYDOWN 키보드가 해당 편집 컨트롤로 전송 된 것을 트랩 할 수 있습니다.
후크 기능은 다음과 같이 보일 것입니다 :
LRESULT CALLBACK MessageHook(int code, WPARAM wParam, LPMSG lpMsg)
{
LRESULT lResult = 0;
if ((code >= 0) && (code == MSGF_DIALOGBOX))
{
if (lpMsg->message == WM_KEYDOWN)
{
//-- process the key down message
lResult = 1;
}
}
// do default processing if required
if (lResult == 0)
{
lResult = CallNextHookEx(MessageFilterHook, code, wParam, (LPARAM)lpMsg);
}
return lResult;
}
후크 다음 편집 컨트롤이 포커스를 얻었을 때 다음과 같은 컨트롤을 편집 첨부 할 수 있습니다 :
//-- create an instance thunk for our hook callback
FARPROC FilterProc = (FARPROC) MakeProcInstance((HOOKPROC)(MessageHook),
hInstance);
//-- attach the message hook
FilterHook = SetWindowsHookEx(WH_MSGFILTER,
(HOOKPROC)FilterProc,
hInstance, GetCurrentThreadId());
을 제거 할 때 편집 포커스가 느슨해지면 다음과 같이 제어 :
//-- remove a message hook
UnhookWindowsHookEx(MessageFilterHook);
편집 컨트롤에 포커스가 있으면 y 누름이 후크로 전송됩니다.
이것은 꽤 좋아 보인다. 내가 이것을 구현할 수 있는지 알게 될 것이고 기회가 생길 때 다시 게시 할 것이다. – tfinniga