LRESULT a CALLBACK KeyboardProc (int nCode, WPARAM WPARAM, LPARAM LPARAM)
{
BOOL Discard=FALSE;
If ((wParam==WM_KEYDOWN) & amp; & (HC_ACTION==nCode))
{
PKBDLLHOOKSTRUCT p=(lParam PKBDLLHOOKSTRUCT);
If (VK_F4==p - & gt; VkCode)
{
Cstrings strAmt=CaptureImage ();
If (NULL!=g_pDlg)
{
G_pDlg - & gt; SetAmt (strAmt);
G_pDlg - & gt; ShowWindow (SW_SHOW);
G_pDlg - & gt; SetCapture ();
PostMessage (g_pDlg - & gt; GetSafeHwnd (), WM_SETFOCUS, NULL, NULL);
PostMessage (g_pDlg - & gt; M_editCode. GetSafeHwnd (), WM_SETFOCUS, NULL, NULL);
G_pDlg - & gt; M_editCode. SetCapture ();
}
}
Else if (VK_ESCAPE==p - & gt; VkCode)
{
G_pDlg - & gt; ShowWindowEx (FALSE);
}
}
If ((wParam==WM_CHAR) & amp; & (HC_ACTION==nCode))
{
TRACE (" 44444444444444444444 \ n ");
}
Return CallNextHookEx (NULL, nCode wParam, lParam);
}
BOOL Installhook ()
{
HINSTANCE hins=AfxGetInstanceHandle ();
G_Hook=SetWindowsHookEx (WH_KEYBOARD_LL, HOOKPROC KeyboardProc, hins, 0).
Return (BOOL) g_Hook;
}
1. Based on the dialog box dlgA, put hooks in its called Installhook OnInit
2 open notepad, input
3. Press F4 tuning up a modal dialog g_pDlg, g_pDlg have an edit box m_editCode
The steps above normal
4. Adjustable g_pDlg later, looking at the cursor on the m_editCode box, but the data content is displayed in the open notepad before
Now the problem is to input content on m_editCode,
Trying several set focus ways can set the input to the m_editCode,
Trouble great god give directions, thank you
CodePudding user response:
Try sending a message set the focus changes to the APISetFocus (g_pDlg - & gt; M_editCode. GetSafeHwnd ());
CodePudding user response:
If (( wParam==WM_CHAR ) & amp; & (HC_ACTION==nCode))WM_CHAR is the result of the Up and Down
CodePudding user response:
Cursor blink, focus should be false