OCX Hit testing...
Muthu Kumar -- muthu@mbtpost.agw.bt.co.uk Friday, March 01, 1996 VC++ 4.0/Win95/VB4/NT 3.51 How do I find out when the mouse pointer leaves & enters the OCX control? I was using global timer with 100 milliseconds interval. Is this efficient solution? Will it affect the performance of the Container? What would be the correct time interval for tracing the mouse pointer? I also tried OnNcHitTest. The problem is it is not working with the Containers like VC++, VB4 etc Any thoughts would be highly appreciated. Thanks in advance. =~=~=~=~=~=~=~=~=~=~==~=~=~=~=~=~=~=~= K. Muthu Kumar 14 Shreeji Apartments, Kondi Vitta Village, Bombay - 59. INDIA. Ph: (O) +91-22-836 78 42 (R) +91-22-839 08 21 Internet: muthu@mbtpost.agw.bt.co.uk =~=~=~=~=~=~=~=~=~=~==~=~=~=~=~=~=~=~=
Crucial Software -- crucial@ix.netcom.com Monday, March 04, 1996 [Mini-digest: 2 responses] >> How do I find out when the mouse pointer leaves & enters the OCX >> control? WM_MOUSEMOVE messages. But, the problem seems to be a little more complex than that. You've titled the message "hit testing", so I'm guessing that the question you wanted to ask was: How do I find out when the mouse pointer leaves & enters the OCX control while the mouse button is down? If that's what you want to know, you should capture the mouse input when you get WM_LBUTTONDOWN (or whatever button). >> I was using global timer with 100 milliseconds interval. >> Is this efficient solution? Yikes! Messages mean we don't have to poll anymore. :-) When you capture the mouse movement, you'll get WM_MOUSEMOVE messages, even when the mouse moves "outside" of the window that's capturing it. For instance, what buttons do (not having looked at the Windows source code, I'm using my own experience here :-) is capture the mouse movement on WM_LBUTTONDOWN. WM_MOUSEMOVE messages while captured are used to determine if the current mouse position is over the button, and a repaint when moving from one state to the other occurs. If you click down and hold the left MB over a button, then move the mouse over and off the button, you will notice the button moves up and down. I am presuming this is what you're after. -- Brad Wilson, Crucial Software crucial@ix.netcom.com +1 (810) 620-9803 Custom software engineering services for Microsoft Windows NT and Windows 95 "A suited man smiled, said: 'It's just a matter of time; you can have the world at your feet by tomorrow, just sign on this line.'" - Dream Theater -----From: Deepak SaxenaI've never tried this, but here's an idea that popped into my head that should work: In response to WM_MOUSEMOVE: CMyCtrl::OnMouseMove(CPoint point, ...) { if( GetCapture() != this ) { // Since we don't have the mouse yet, we only // receive WM_MOUSEMOVE when the mouse is over // the window. Since we set capture as soon as // we receive a WM_MOUSEMOVE message, it means // that the mouse must be entering the window. SetCapture(); OnMouseEnter(); // Your handler } else { // If we have captured the mouse, we can check if it is // in the window or not by getting the client rect and // doing a hit test. If your control is not rectangular // you can use your own customized hit testing CRect rect = GetClientRect(); // Or whatever function // is called if( !rect.PtInRect(point)) { ReleaseCapture(); OnMouseLeave(); // Your handler } } } Hope this helps(and works) Deepak Saxena
| Вернуться в корень Архива |