📄 wpw_wapi_mouse_95.html
字号:
<HTML>
<HR><A NAME=WINAPI_MOUSE_PRESSED>
Return to <a href="wpw_wapi_index.html#TOC">Table of Contents for this chapter</a><br>
<H4>Subject: Mouse Pressed Message</H4><PRE>
mfried@linex.com (Marty Fried) writes:
> Once upon a time, geek@GeeksRUs.com (Steve Riggins) wrote:
>
> >I'd like to implement a MouseStillDown message for Windows. IE, it only get
> >sent to my Window between LButtonDown and LButtonUp.
>
> >My current approach is to set a flag on mouse down and send myself a message
> >am a WS_CHILD window) of (WM_USER+256)
>
> >In the mousestill down, I check the flag and if true, I send another
> >(WM_USER+256) to my window.
>
> >In mouse up, I clear the flag.
>
> I think you're close, but the mouse still down message approach
> obviously isn't a good idea. I'm not sure what you're trying to do, but
> it sounds like maybe you should do a SetCapture on the mouse down
> message, setting a flag, then handle mouse move messages and check the
> capture flag. Then ReleaseCapture on mouse up. You could set up a
> timer or do idle-time processing if the capture flag is set. Capturing
> the mouse is done so you will be sure to get the mouse up message, even
> if it occurs in another window.
>
> Marty Fried - mfried@linex.com | KEYBOARD ERROR...
I had a problem recently which could be related to this.
An applicaton reqired a "repeating button" object, a button which would
repeatedly send messages while the user holds down the left mouse
button.
I have this complex para-GUI system where the buttons are not really
buttons, but bitmaps... but anyway:
When you get a mouse-button-down message which "presses" the button,
set mouse-capture and activate a timer routine which will send the
appropriate "still-down" message to the parent. Deactivate the timer on
button-up and release capture.
Actually I used two timer settings, one for the initial delay and the
other for the actual repeat.
This is very close (identical?) to Marty's timer idea.
Slama
<HR>
Something to try:
The window (or control) which was SetCapture()'ed will get WM_CANCELMODE
if a DialogBox comes up when it (the control) has focus. Process
WM_CANCELMODE by calling ReleaseCapture().
OR:
Before you bring up the DialogBox, call SetFocus(hwndSomeControl).
________
-=/ ____ /_ _____ ______ ___ __ Quang Ngo (quang@tiac.net)
-=/ / __/ / / / / __` / __ \/ __` / IRC /nick RX7-turbo on #amiga & #linux
-=/ /__\ / /_/ / /_/ / / / / /_/ / http://www.tiac.net/users/quang/
-=\____,\ \___,_\___,/_/ /_/\___,/ A3000/25 (AmigaOS 3.1) - P5/90 (linux)
\________/ /____/ Software Developer
<HR>
Yes, I've done just that sort of thing. I have bitmapped LCD readouts
in my app, and you can set them up or down by clicking the top or
bottom. If you hold the button down, I do a delay, then slow, then
fast, like setting digital clocks. It's really fairly easy in C++.
I think the important point is to do a mouse capture, as this guarantees
that you will receive the mouseup message, where otherwise, it could go
up after being moved out of your window, and you then wouldn't get the
message.
___________________________________________________________
Marty Fried - mfried@linex.com | KEYBOARD ERROR...
San Anselmo, CA | Press any key to continue
(MSVC + MFC) && Win95; | or any other key to quit
-----------------------------------------------------------
</PRE>
<HR><A NAME=WINAPI_MOUSE_TRAP>
Return to <a href="wpw_wapi_index.html#TOC">Table of Contents for this chapter</a><br>
<H4>Subject: Mouse Trap</H4><PRE>
On 19 Jun 1995 12:21:24 GMT, Jean-Pascal van der Endt <jean@kgs.twi.tudelft.nl> said in article <3s3q44$qo6@mo6.rc.tudelft.nl>:
>Hi,
>
>Sorry if this is a FAQ. I'm trying to trap mouse events on the desktop.
>I found a way to do this in the programmer's FAQ, but my program only traps the
>events when it is active. My question is: how can I get my program to trap
>events when it isn't active?
For some example code, see the URL:
http://www.csn.net/~rmashlan/win-developer-FAQ/mouse/1.htm
--
Robert Mashlan R2M Software Company Programmer for Hire
mailto:rmashlan@r2m.com http://www.csn.net/~rmashlan PGP key available
Resources for Windows Developers - http://www.csn.net/~rmashlan/windev
Windows Developers FAQ - http://www.csn.net/~rmashlan/win-developer-FAQ
<HR>
In article <3s3q44$qo6@mo6.rc.tudelft.nl>
jean@kgs.twi.tudelft.nl "Jean-Pascal van der Endt" writes:
>Hi,
>
>Sorry if this is a FAQ. I'm trying to trap mouse events on the desktop.
>I found a way to do this in the programmer's FAQ, but my program only traps the
>events when it is active. My question is: how can I get my program to trap
>events when it isn't active?
You need to install a "global hook". Take a look at the "SetWindowsHookEx"
API.
Chris
--
--------------------------------------------------------------------------
| Chris Marriott, Warrington, UK | Author of SkyMap v2 shareware |
| chris@chrism.demon.co.uk | astronomy program for Windows. |
| For more info, see http://www.winternet.com/~jasc/skymap.html |
| Author member of Association of Shareware Professionals (ASP) |
--------------------------------------------------------------------------
</PRE>
<HR><A NAME=WINAPI_MOUSE_CONTAIN>
Return to <a href="wpw_wapi_index.html#TOC">Table of Contents for this chapter</a><br>
<H4>Subject: Contain the mouse in a window</H4><PRE>
close@cs.ukans.edu (Brett H. Close) wrote:
>Howdy Folks,
>
>How can I control the position of the cursor?
>What I want is to force the mouse cursor to stay inside a particular
>window. I would think I could do this by checking the cursor pos
>in the OnMouseMove and if it goes out of the client rect then move it.
>BUT... I cant seem to move it! Is there a particular method, or should
>I just use SendMessage( WM_MOUSEMOVE ... ) and if so, what parms
>should I give to sendmessage?
>
Try ::ClipCursor(). Search your on-line Win31 functions.
--
=========================================================================
=
May the FORCE be with you...
Al Cilcius Internet: alcilcius@thirdsigma.mv.com
3rd Sigma Software, Inc. Voice: (603) 483-2183
1338 Hooksett Road FAX: (603) 483-1397
Suite 125 CompuServe: 70322,2343
Hooksett, NH 03106-1842
=========================================================================
=
</PRE>
<HR><A NAME=WINAPI_MOUSE_OUTWIN>
Return to <a href="wpw_wapi_index.html#TOC">Table of Contents for this chapter</a><br>
<H4>Subject: Getting mouse message out of the client window</H4><PRE>
>Farhana Dany (merfar@techunix.technion.ac.il) wrote:
>: Hello !
>: Should I get a message when the mouse cursor goes
>: out of my client window ?
>It's debatable whether or not you *should* get such a message, but the
>fact is that you don't get such a message. If you need to know when the
>mouse is moving out of your window, you'll need to either set a mouse
>hook or capture the mouse (keep in mind that if your window has children
>and you capture the mouse, they won't get any mouse messages).
If you don't want to "SetCapture" the mouse,
subclass the window and trap either the WM_MOUSEMOVE or WM_NCHITEST messages.
1. WM_MOUSEMOVE :
Check that the mouse coordinates are in the window's
area using PtInRect and GetClientRect
2. WM_NCHITTEST :
Check that the value returned by DefWindowProc is
HTCLIENT
David
</PRE>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -