Results 1 to 2 of 2

Thread: SetCapture and the Missing Mouse Cursor?

  1. #1

    Thread Starter
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339

    SetCapture and the Missing Mouse Cursor?

    Has anyone else ran into problems with SetCapture where the mouse pointer seems to disappear or change its zOrder to the desktop?

    I am using this sample code and in the demo it works right but in my project the pointer disappears. I now have most of the code cut and pasted but still it does it on me. The only thing I can think of thats different is that I am using a control that was created at run time and in the demo it was made at design time. Would that have anything to do with it?

    VB Code:
    1. 'here is the snippet that is harassing me
    2. Private Sub cShow(ByVal x As Long, ByVal Y As Long)
    3. Dim tP As POINTAPI
    4. Dim hWndDesktop As Long
    5. Dim lStyle As Long
    6. Dim lhWnd As Long
    7. Dim lParenthWNd As Long
    8.    
    9.    ' Make sure the picture box won't appear in the
    10.    ' task bar by making it into a Tool Window:
    11.    lhWnd = PopUpList.hwnd
    12.    lStyle = GetWindowLong(lhWnd, GWL_EXSTYLE)
    13.    lStyle = lStyle Or WS_EX_TOOLWINDOW
    14.    lStyle = lStyle And Not (WS_EX_APPWINDOW)
    15.    SetWindowLong lhWnd, GWL_EXSTYLE, lStyle
    16.    
    17.    ' Determine where to show it in Screen coordinates:
    18.    tP.x = x \ Screen.TwipsPerPixelX: tP.Y = Y \ Screen.TwipsPerPixelY
    19.    lParenthWNd = PopUpList.Parent.hwnd
    20.    ClientToScreen lParenthWNd, tP
    21.    
    22.    ' Make the listview a child of the desktop (so
    23.    ' it can be fully shown even if it extends beyond
    24.    ' the form boundaries):
    25.    SetParent lhWnd, hWndDesktop
    26.    
    27.    ' Show the form:
    28.    SetWindowPos lhWnd, lParenthWNd, tP.x, tP.Y, PopUpList.Width \ Screen.TwipsPerPixelX, PopUpList.Height \ Screen.TwipsPerPixelY, SWP_SHOWWINDOW
    29.      
    30.    ' Tell VB it is shown:
    31.    PopUpList.Visible = True
    32.    PopUpList.ZOrder
    33.    
    34.    ' Try to set focus:
    35.    SetFocusAPI lhWnd
    36.  
    37.    ' Capture all mouse messages.
    38.    SetCapture lhWnd
    39. End Sub

  2. #2
    Member
    Join Date
    Feb 2001
    Posts
    52

    Yes that problem is quite irritating.

    You can save the pointers location. then display that screen on a form, set the timer interval to about 3 milli sec. Then on mouse move ,move a icon-then on mouse move event, shift the location of the icon. Then in timer event position mouse to the saved location and capture( the icon positons at that location,) then make icon invisible and disable the timer.
    That will capture the mouse pointer i.e.
    Its not API exactly (just a trick i figured to save the poiter position to scqreenshot)
    Got it?
    Regards,
    LXS
    lxs

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