Thread: ???How is this done???

  1. #1
    ‡ †hë Ö†hÈr sîÐè ‡ Nor's Avatar
    Join Date
    Nov 2001
    Posts
    299

    ???How is this done???

    OK. A friend of mine made a program in class today and refuses to disclose the code to me.
    Not I don't want to steal his design but he created a window which the mouse goes under. Is this an illusion or is his window above the curser?

    He says it is stright winAPI.
    I know DirectDraw can do this, but can winAPI?
    I have no clue what he did. But I think its cool.
    Any thoughts?
    Last edited by Nor; 05-07-2002 at 10:12 PM.

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    I'm sure there are 100's of ways to do this. Here is a way I just came up with on the fly. I have no idea if this will actually work but I do not see why it would not. Check the mouse movement messages in your WinProc and look for WM_MOUSEMOVE, then get the x and y position. When it is inside of the rectangle that is the window simply call:

    ShowCursor( FALSE );

    and similarly when the cursors' coordinates are outside of the window call

    ShowCursor( TRUE );

    Look up these on MSDN if you have further issues about them. Hope this helps. Tell your buddy don't be stingey.

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    Code:
    case WM_NCMOUSEMOVE://outside client area may need a call to TrackMouseEvent()
    ShowCursor(TRUE);
    break;
    case WM_MOUSEMOVE://in window
    ShowCursor(FALSE)
    break;
    Could also use PtInRect() and MAKEPOINTS() on the mouse coods.

    Try this to restrict the mouse to smaller and smaller areas inside the dialog
    Code:
    case WM_MOUSELEAVE:
    static RECT        Rect;
    static UNIT        uTimer=0;
    GetWindowRect(hWnd,&Rect);
    ClipCursor(&Rect);
    uTimer=SetTimer(hWnd, WM_USER+10001,20000,NULL);
    break;
    case WM_LBUTTONDOWN://each time clicked will reduce the area by 100x100
    Rect.left+=50;
    Rect.top+=50;
    Rect.right-=50;
    Rect.bottom-=50;
    ReleaseCapture()
    ClipCursor(hWnd,&Rect);
    break;
    case WM_TIMER://will release the cursor after 20 sec
    if(wParam==uTimer)
    {
         ReleaseCapture();
         KillTimer(hWnd,uTimer);
    }
    break;
    Needs error checking for the Rect (ie if left>right)
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  4. #4
    Registered User
    Join Date
    Mar 2002
    Posts
    88
    hmmm


    maybe he just drawed a new cursor that is invisible

    and the cursor takes effect only when the mouse is on the window

    so you can think that it goes behind the window

  5. #5
    *
    Guest
    You cannot put the mouse behind any window. The best you can do is to hide it, or change it to a map/mask with no pixmap.

    It's purely an illusion.

    he has no control over the depth of the mouse, that is handled by the desktop and windows managers.

Popular pages Recent additions subscribe to a feed