CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Hybrid View

  1. #1
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    WM_LBUTTONDOWN and SendMessage

    Hi,

    I am trying to simulate a click at a certain point in a webbrowser control. I found its handle but i can't format the lparam of WM_LBUTTONDOWN/UP so that it clicks in the correct position. Can someone tell me how to format the lparam so that (for example) X=32 and Y=32. Also, i only want to use sendmessage, not mouse_event.

    Thanks in advance!

    Iouri Boutchkine
    iboutchkine@hotmail.com
    Iouri Boutchkine
    iouri@hotsheet.NOSPAM.com

  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: WM_LBUTTONDOWN and SendMessage

    you can try the MAkeDWord function, that I have "found" on the web (may be even in this forum? I don't remember).


    private Function MakeDWord(wHi as Integer, wLo as Integer) as Long
    If wHi And &H8000& then
    MakeDWord = (((wHi And &H7FFF&) * 65536) Or (wLo And &HFFFF&)) Or &H80000000
    else
    MakeDWord = (wHi * 65535) + wLo
    End If
    End Function



    lparam = Makedword...

    >Also, i only want to use sendmessage, not mouse_event.

    Any reason for that?
    MS WANTS you to use mouse_event, or better yet, SendInput.




  3. #3
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: WM_LBUTTONDOWN and SendMessage

    Hi,

    Thanks for your code, however, only part of it works. the loword comes out to zero, when inserted into the PostMessage function. so X32 Y32 (X=loword, Y=hiword) come out like X0 Y32. Can you look at it again and find, what, if anything, is wrong? I appreciate your help.

    Thanks!


    Iouri Boutchkine
    iboutchkine@hotmail.com
    Iouri Boutchkine
    iouri@hotsheet.NOSPAM.com

  4. #4
    Join Date
    May 1999
    Posts
    3,332

    Re: WM_LBUTTONDOWN and SendMessage

    wanna try this one? from MSDN?


    Function MakeDWord(LoWord as Integer, HiWord as Integer) as Long
    MakeDWord = (HiWord * &H10000) Or (LoWord And &HFFFF&)
    End Function



    untested!


  5. #5
    Join Date
    Aug 2000
    Posts
    2

    Re: WM_LBUTTONDOWN and SendMessage

    Hi, I waste a lot of time for emulating mouse event with webbrowser control.
    And no result yet.
    I can't send message (with API and right coord) to control becouse I can't define Hwnd for browser.
    And now I decide use IE object model. But there is another problem.

    At first, my task.
    Implement feature that allow users browser thought html doc by mousedouwn event. You press mouse button on some link and browser go to the link while you pressing mouse button.

    I try to use WebBrowser.Document property that has event onmousedown, but when I get
    set doc = WebBrowser.Document
    doc.ActiveElement has [object] (as I see it's pointer on document object), after next mousedown or mouseup events doc.ActiveElement has current URL (that exact what I need). Focus changed from [object] to link.

    So, how can I reach URL on _First_ mousedown (by one mouse event)?












  6. #6
    Join Date
    Dec 2003
    Location
    United States
    Posts
    9
    Not sure if this is what your asking, but there is a macro

    LPARAM MAKELPARAM(
    WORD wLow,
    WORD wHigh
    );

    So for your case i'd do the following...

    SendMessage(hWnd, WM_LBUTTONDOWN, 0, MAKELPARAM(32,32));

    - where 'hWnd' is the handle to the window

  7. #7
    Join Date
    Oct 2003
    Location
    .NET2.0 / VS2005 Developer
    Posts
    7,104

    Re: Re: WM_LBUTTONDOWN and SendMessage

    Originally posted by Marsha Dastin
    You press mouse button on some link and browser go to the link while you pressing mouse button.
    umm.. browsers go to the link on museup, not mousedown...

    or is that what youre trying to implement (why??)
    "it's a fax from your dog, Mr Dansworth. It looks like your cat" - Gary Larson...DW1: Data Walkthroughs 1.1...DW2: Data Walkthroughs 2.0...DDS: The DataSet Designer Surface...ANO: ADO.NET2 Orientation...DAN: Deeper ADO.NET...DNU...PQ

  8. #8
    Join Date
    Jan 2003
    Location
    7,107 Islands
    Posts
    2,487

    Re: WM_LBUTTONDOWN and SendMessage

    Originally posted by Iouri
    Hi,

    I am trying to simulate a click at a certain point in a webbrowser control. I found its handle but i can't format the lparam of WM_LBUTTONDOWN/UP so that it clicks in the correct position. Can someone tell me how to format the lparam so that (for example) X=32 and Y=32. Also, i only want to use sendmessage, not mouse_event.

    Thanks in advance!

    Iouri Boutchkine
    iboutchkine@hotmail.com
    Hi,

    Have you tried something like this? The first WM_LBUTTONDOWN will activate the button.
    Code:
      PostMessage hwnd, WM_LBUTTONDOWN, 0&, CLng(&H90009)
      PostMessage hwnd, WM_LBUTTONDOWN, 0&, CLng(&H90009)
      PostMessage hwnd, WM_LBUTTONUP, 0&, CLng(&H90009)
    Or take a look at this link http://www.codeguru.com/forum/showth...hreadid=271953
    Busy

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