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:
'here is the snippet that is harassing me Private Sub cShow(ByVal x As Long, ByVal Y As Long) Dim tP As POINTAPI Dim hWndDesktop As Long Dim lStyle As Long Dim lhWnd As Long Dim lParenthWNd As Long ' Make sure the picture box won't appear in the ' task bar by making it into a Tool Window: lhWnd = PopUpList.hwnd lStyle = GetWindowLong(lhWnd, GWL_EXSTYLE) lStyle = lStyle Or WS_EX_TOOLWINDOW lStyle = lStyle And Not (WS_EX_APPWINDOW) SetWindowLong lhWnd, GWL_EXSTYLE, lStyle ' Determine where to show it in Screen coordinates: tP.x = x \ Screen.TwipsPerPixelX: tP.Y = Y \ Screen.TwipsPerPixelY lParenthWNd = PopUpList.Parent.hwnd ClientToScreen lParenthWNd, tP ' Make the listview a child of the desktop (so ' it can be fully shown even if it extends beyond ' the form boundaries): SetParent lhWnd, hWndDesktop ' Show the form: SetWindowPos lhWnd, lParenthWNd, tP.x, tP.Y, PopUpList.Width \ Screen.TwipsPerPixelX, PopUpList.Height \ Screen.TwipsPerPixelY, SWP_SHOWWINDOW ' Tell VB it is shown: PopUpList.Visible = True PopUpList.ZOrder ' Try to set focus: SetFocusAPI lhWnd ' Capture all mouse messages. SetCapture lhWnd End Sub




Reply With Quote