CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    Join Date
    Feb 2006
    Posts
    169

    Angry help with WM_LBUTTONDOWN

    Dear all,

    I am trying to capture the x,y of mouse click events. I therefore have added a notification message "WM_LBUTTONDOWN" to my application (Being a IE -- which uses the microsoft activex control).

    Now i am printing some stuff within the event handler of WM_LBUTTONDOWN. however, nothing happens.

    Can someone please give hints

  2. #2
    Join Date
    Sep 2005
    Location
    Singapore
    Posts
    8

    Re: help with WM_LBUTTONDOWN

    I have noticed that it does not work if you are capturing event on the control. However, I can capture the event when I try to detect mouse click on the dialog. What actually you wish to do?

  3. #3
    Join Date
    Feb 2006
    Posts
    169

    Angry Re: help with WM_LBUTTONDOWN

    Quote Originally Posted by zawthet
    I have noticed that it does not work if you are capturing event on the control. However, I can capture the event when I try to detect mouse click on the dialog. What actually you wish to do?
    Actually, the user will be using the IE. I have to save the position of his clicks. so he will be clicking on the microsoft activex control

    Is that not feasible ??

  4. #4
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: help with WM_LBUTTONDOWN

    Quote Originally Posted by llp00na
    Now i am printing some stuff within the event handler of WM_LBUTTONDOWN. however, nothing happens.
    What exactly do you mean by "printing some stuff"? And: Where are you handling the WM_LBUTTONDOWN message? In a class derived from the browser control, or in the containing window? From what you posted, you are handling it in the (CWinApp-derived) application class - this won't work, since it's not a window.[/QUOTE]

  5. #5
    Join Date
    Feb 2006
    Posts
    169

    Re: help with WM_LBUTTONDOWN

    Quote Originally Posted by gstercken
    What exactly do you mean by "printing some stuff"? And: Where are you handling the WM_LBUTTONDOWN message? In a class derived from the browser control, or in the containing window? From what you posted, you are handling it in the (CWinApp-derived) application class - this won't work, since it's not a window.
    [/QUOTE]


    I have added the WM_LBUTTONDOWN message to the main dialog window.
    Please have a look at the attachment.
    Attached Files Attached Files

  6. #6
    Join Date
    Feb 2006
    Posts
    169

    Question Re: help with WM_LBUTTONDOWN

    does nobody knwo how to solve this problem ???

  7. #7
    Join Date
    May 2005
    Location
    Oregon
    Posts
    3,725

    Re: help with WM_LBUTTONDOWN

    Simple Perform Hooking On your Mouse.

  8. #8
    Join Date
    Feb 2006
    Posts
    169

    Thumbs down Re: help with WM_LBUTTONDOWN

    Quote Originally Posted by humptydumpty
    Simple Perform Hooking On your Mouse.
    i have no previous knowledge about hooking. I have been looking at some articles and it looked too complicated for me (i am very notice to visual c++).

    If WM_LBUTTONDOWN is a possible solution, i would prefer to do it this way. else or i will find myself obliged to do it the hard way (mouse hook).

  9. #9
    Join Date
    May 2005
    Location
    Oregon
    Posts
    3,725

    Re: help with WM_LBUTTONDOWN

    See Hooking is not That Much a hard task
    you have to perform following step .details you can found in MSDN if still Problem Let us Know

    1)use SetWindowsHookEx() for installing the hook in your Application
    2)define your Callback procedure now
    3)use UnhookWindowsHookEx() function to unhook your Window

    a idea
    Code:
    ::SetWindowsHookEx(WH_MOUSE,GetMessageProc,....,.......); //Sets the hook on your mouse
    ::UnhookWindowsHookEx(HHOOK hhk)//after finishing your work unhook it
    Code:
    //Now write your Procedure 
    GetMessageProc(int nCode, WPARAM wParam, LPARAM lParam)
    {
    //write your code here
    // Passes the hook information to the next hook procedure in
    // the current hook chain.
    return ::CallNextHookEx(m_hHook, nCode, wParam, lParam);
    }
    thankyou
    Last edited by humptydumpty; May 10th, 2006 at 07:57 AM.

  10. #10
    Join Date
    Feb 2006
    Posts
    169

    Re: help with WM_LBUTTONDOWN

    Quote Originally Posted by humptydumpty
    See Hooking is not That Much a hard task
    you have to perform following step .details you can found in MSDN if still Problem Let us Know

    1)use SetWindowsHookEx() for installing the hook in your Application
    2)define your Callback procedure now
    3)use UnhookWindowsHookEx() function to unhook your Window

    a idea
    Code:
    ::SetWindowsHookEx(WH_MOUSE,GetMessageProc,....,.......); //Sets the hook on your mouse
    ::UnhookWindowsHookEx(HHOOK hhk)//after finishing your work unhook it
    Code:
    //Now write your Procedure 
    GetMessageProc(int nCode, WPARAM wParam, LPARAM lParam)
    {
    //write your code here
    // Passes the hook information to the next hook procedure in
    // the current hook chain.
    return ::CallNextHookEx(m_hHook, nCode, wParam, lParam);
    }
    thankyou
    is there any need to use a dll. and when do i exactly need to use global hook functions.
    In my application i will need to record user left clicks on the microsoft activex control. would your approach described above be sufficient

  11. #11
    Join Date
    May 2005
    Location
    Oregon
    Posts
    3,725

    Re: help with WM_LBUTTONDOWN

    dll for wat ?
    and all above is only a idea to show you that you don't have to take a lot of burden in case of hooking. in case of GetMessageProc() simply do what ever you want.
    Just Read Once Again in MSDN.
    Okay .
    if Still Problem Let us know.So i will Send you a sample workspace .

    Thankyou

  12. #12
    Join Date
    Feb 2006
    Posts
    169

    Re: help with WM_LBUTTONDOWN

    Quote Originally Posted by humptydumpty
    dll for wat ?
    and all above is only a idea to show you that you don't have to take a lot of burden in case of hooking. in case of GetMessageProc() simply do what ever you want.
    Just Read Once Again in MSDN.
    Okay .
    if Still Problem Let us know.So i will Send you a sample workspace .

    Thankyou
    the reason why i mentioned a dll,
    MSDN**
    You must place a global hook procedure in a dynamic-link library (DLL) separate from the application installing the hook procedure**

  13. #13
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,633

    Re: help with WM_LBUTTONDOWN

    Forget about hooking, it's unnecessary.
    Code:
    BOOL CPilotStudyDlg::PreTranslateMessage(MSG* pMsg)
    {
    	if(WM_LBUTTONDOWN == pMsg->message)
    	{
    		fprintf(trial, "\nMouse: x = %i, y = %i ", LOWORD(pMsg->lParam), HIWORD(pMsg->lParam));
    		fflush(trial);
    	}
    	return CDialog::PreTranslateMessage(pMsg);
    }
    Last edited by Igor Vartanov; May 10th, 2006 at 12:21 PM.
    Best regards,
    Igor

  14. #14
    Join Date
    Feb 2006
    Posts
    169

    Thumbs up Re: help with WM_LBUTTONDOWN

    Quote Originally Posted by Igor Vartanov
    Forget about hooking, it's unnecessary.
    Code:
    BOOL CPilotStudyDlg::PreTranslateMessage(MSG* pMsg)
    {
    	if(WM_LBUTTONDOWN == pMsg->message)
    	{
    		fprintf(trial, "\nMouse: x = %i, y = %i ", LOWORD(pMsg->lParam), HIWORD(pMsg->lParam));
    		fflush(trial);
    	}
    	return CDialog::PreTranslateMessage(pMsg);
    }
    Thanx very much,

    your code really helped alot. is there any downsides with using this approach ?

    you have saved me lots of troubles. I am very grateful.

    Thank you

  15. #15
    Join Date
    Feb 2006
    Posts
    169

    Re: help with WM_LBUTTONDOWN

    Quote Originally Posted by Igor Vartanov
    Forget about hooking, it's unnecessary.
    Code:
    BOOL CPilotStudyDlg::PreTranslateMessage(MSG* pMsg)
    {
    	if(WM_LBUTTONDOWN == pMsg->message)
    	{
    		fprintf(trial, "\nMouse: x = %i, y = %i ", LOWORD(pMsg->lParam), HIWORD(pMsg->lParam));
    		fflush(trial);
    	}
    	return CDialog::PreTranslateMessage(pMsg);
    }
    I have got one slight problem. I have noticed that when i click next to the address bar (on Url Address text ) i receive a value for *y* that is bigger than the value of *y* received when clicking on the microsoft control (just below the area where the control and the dialog meets). In fact, y values should increase as i go away from top to bottom.

    Do you have any explanation for that ?

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured