Re: CEdit and WM_LBUTTONUP
On Jul 2, 12:20 pm, Mark Salsbery [MVP]
<MarkSalsbery...@discussions.microsoft.com> wrote:
You may want to review the docs for SetCapture().
For example:
"SetCapture captures mouse input either when the mouse is over the capturing
window, or when the mouse button was pressed while the mouse was over the
capturing window and the button is still down."
Mark
--
Mark Salsbery
Microsoft MVP - Visual C++
"Cliff" wrote:
OK here is the scenario. I'm trying to find out when the user clicks
outside of a CEdit control. To do this I'm calling SetCapture from
within a CEdit derived class when the control gets focus. I do this so
that all messages should be sent to the CEdit. I ReleaseCapture on the
KillFocus.
I have placed a trace inside of the WM_LBUTTONUP handler and the
KillFocus handler. I can click outside of the control and I get the
WM_LBUTTONUP notification only once. If I keep clicking after the
first click I get nothing. I never get a notification of KillFocus
either. So the CEdit should still have SetCapture activated.
If I click the CEdit again the whole process repeats. Does anyone know
why I don't get the WM_LBUTTONUP message more than once?
P.S. I've also tried WM_LBUTTONDOWN as well. I've tried both of these
messages from PreTranslateMessage and WindowProc.
Thanks for the reply, but I couldn't get my methods to work out for
me. I decided to switch gears and create a mouse hook. I don't like
this approach, but nothing else is readily apparent. Here is what I
did...
HHOOK g_hHook;
g_hHook = SetWindowsHookEx(WH_MOUSE,
(HOOKPROC) MouseCheckerProc,
AfxGetInstanceHandle(),
AfxGetThread()->m_nThreadID);
LRESULT CALLBACK MouseCheckerProc(
int nCode, // hook code
WPARAM wParam, // message identifier
LPARAM lParam) // mouse coordinates
{
if (nCode == HC_ACTION)
{
if (lParam)
{
MOUSEHOOKSTRUCT *pMH = reinterpret_cast<MOUSEHOOKSTRUCT
*>(lParam);
switch (wParam)
{
case WM_NCLBUTTONDOWN:
case WM_NCRBUTTONDOWN:
case WM_NCMBUTTONDOWN:
case WM_LBUTTONDOWN:
case WM_MBUTTONDOWN:
case WM_RBUTTONDOWN:
{
//put code here
}
break;
default:
break;
}
}
}
return ::CallNextHookEx(g_hHook, nCode, wParam, lParam);
}
....I feel like I cheated but what else could I do. Don't wanna get
fired for not finishing on time :D