-
October 16th, 2010, 07:30 AM
#1
showing a dialog at keypress
I am trying to show a dialog at key press like intellisense. i have written the following code inside the keyboard hook function.
Code:
if(wParam== WM_KEYDOWN)
{
KBDLLHOOKSTRUCT* kbd =((KBDLLHOOKSTRUCT*)lParam);
TCHAR sz[50]={0};
POINT caretPosition;
GUITHREADINFO thrInfo;
thrInfo.cbSize = sizeof(thrInfo);
::GetGUIThreadInfo(0,&thrInfo);
caretPosition.x = (int)thrInfo.rcCaret.left ;
caretPosition.y = (int)thrInfo.rcCaret.bottom ;
ClientToScreen(thrInfo.hwndCaret,&caretPosition);
if ((kbd->vkCode==VK_RIGHT))
{
if (!m_pModeless){
m_pModeless = new CMfcDialog();
}
CWnd* pcWnd=0;
pcWnd= CWnd::FromHandle(thrInfo.hwndCaret);
CRect rct;
if (!::IsWindow(m_pModeless->GetSafeHwnd()))
{
m_pModeless->Create(IDD_DIALOG1,pcWnd);
m_pModeless->GetWindowRect(&rct);
m_pModeless->SetWindowPos(CWnd::FromHandle(HWND_TOPMOST),caretPosition.x,caretPosition.y,rct.Width(),rct.Height(),SWP_NOACTIVATE);
m_pModeless->ShowWindow(SW_SHOW);
}
else{
CWnd* oldWnd = m_pModeless->SetParent(pcWnd);
m_pModeless->GetWindowRect(&rct);
pcWnd = CWnd::FromHandle(thrInfo.hwndCaret);
m_pModeless->MoveWindow(caretPosition.x,caretPosition.y,rct.Width(),rct.Height());
m_pModeless->SetForegroundWindow();
}
I am not able to bring the window second time at the cursor position and also the window is not displaying as SWP_NOACTIVATE.
Please advice,
Regards and thanks,
John.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|