CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2005
    Posts
    2

    Is it possible to throw mouse messages to behind window?

    Hello.

    Can the mouse message be passed to the window in the back?

    I made the window with the TOPMOST attribute. This has the same size
    as the screen. Moreover, it is half transparent window.

    OS delivers the mouse message to this window when the mouse is moved or
    it clicks. Therefore, the user cannot operate other windows hidden in the
    window.

    I tried.
    It threw out some mouse message using PostMessage functions. The
    window handle used and acquired the WindowFromPoint function.
    However, it did not operate well.

    Please teach something a good idea.

  2. #2
    Join Date
    Mar 2004
    Location
    (Upper-) Austria
    Posts
    2,899

    Re: Is it possible to throw mouse messages to behind window?

    Because it won't operate well, since WindowFromPoint will always return your huge window. For WindowFromPoint() to operate will you need to minimize your huge window, so it can find the windows behind yours. Or you keep a track of the windows (by hooking or enuming them and store them somewhere) and then operate on them. But this is pretty much reinwenting the wheel.
    I am not offering technical guidiance via email or IM
    Come on share your photo with us! CG members photo album!
    Use the Code Tags!

  3. #3
    Join Date
    Aug 2005
    Posts
    2

    Re: Is it possible to throw mouse messages to behind window?

    Thank you for advice.
    I tried and looked at the following codes.However, it did not operate as expected.

    I'll try using EnumWindows API.


    if(WM_MOUSEFIRST <= message && message <= WM_MOUSELAST)
    {
    POINT pt = { LOWORD(lParam), HIWORD(lParam) };
    ClientToScreen(hWnd, &pt);

    SetWindowPos (hWnd, NULL, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOREDRAW);

    HWND hTarget = WindowFromPoint(pt);

    SetWindowPos (hWnd, NULL, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOREDRAW);

    if(hTarget && hTarget != hWnd)
    {
    ScreenToClient(hTarget, &pt);
    PostMessage(hTarget, message, wParam, MAKELPARAM(pt.x, pt.y));
    }
    }

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