Win7 has some cool features that are not available in XP and Vista systems, such as window group preview, quick hidden desktop icons, shaking other windows … … how these cool features are Designed? How do personal software we develop use these features to surprise users?
In the "Minority Report", Tomang directly used two fingers to operate the program on the touch screen, which was awkward. This feature is also supported by Win 7. As long as there is a touch device, we can also use both hands to play the computer on Win7. Two-finger touch such as zoom, two-finger zoom, two-finger flip and other effects can be implemented in Win 7.
Two kinds of touch gestures commonly used by Win7
1. Zoom gestures
Zoom gestures are used to zoom in or out of the interface, often in programs such as browsing pictures and reading articles. Used. The gesture of the two-finger zoom is shown in Figure 1: The two fingers are placed together in the form, one pointing up and one pointing down, this is zooming in, the two fingers are placed on the form separately, and the two points are sliding in the middle, then Zoom out.
The program needs to recognize this gesture. The first step is to get a message from the finger to the screen. In the second step, the distance is calculated according to the coordinates of the two fingers, and the distance between the two fingers is compared according to an empirical value to obtain that the two fingers are separated or the two fingers are close together. In the third step, the coordinates of the finger point can be captured in real time according to a timer to calculate the moving direction and the speed, and further, whether the two fingers are reverse sliding or opposite sliding can be determined.
2. Pan gestures
Pan gestures are often used for navigation. For example, in an image viewer, use the pan left gesture to navigate to the previous one and the pan pan gesture to navigate to the next image. The pan gesture is shown in Figure 2: both fingers slide to the left or to the right. How to distinguish whether the user wants to change the position of the picture or turn the page? The acceleration must be used here.
You can capture the finger coordinates in real time in a timer, calculate the velocity and acceleration, and compare it with the acceleration through an empirical value. When the acceleration is relatively large, it can be considered as turning pages, otherwise it is dragging. move. Of course, this is not enough. When dragging, you need to further judge whether you reach the program boundary. If you reach the boundary, it is also considered to be page turning. For the processing of turning pages, moving to the left or reaching the left border is considered to be the previous page.
Two-finger touch API reveals
The core of two-finger touch is to put the original touch data into the motion model to calculate the user's gesture. The raw touch data can be obtained from the WM_TOUCH message. The zoom and pan gestures are recognized by WM_TOUCH.
Step 1: Check Multi-Touch Hardware
Use the GetSystemMetrics API here to get the hardware ready:
BYTE digitizerStatus = (BYTE)GetSystemMetrics(SM_DIGITIZER); If ((digitizerStatus & (0x80 + 0x40)) == 0){ //Do not detect multi-touch device or device is not ready } //Check that the device supports several touch points, need to pay attention to the current Win 7 pair 2 touch points are better supported BYTE nInputs = (BYTE)GetSystemMetrics(SM_MAXIMUMTOUCHES);
Step 2: Switch to the original touch message
By default, Win 7 provides WM_GESTURE by default. (gesture) message. This gesture is a gesture that the system recognizes based on the original touch data. The RegisterTouchWindow API function allows the system to return the WM_TOUCH original touch input message. The core code:
RegisterTouchWindow(hWnd, 0)) //hwnd is the current window Handle.
Step 3: Get the raw touch data
Get the original touch data using the GetTouchInputInfo API, core code:
GetTouchInputInfo((HTOUCHINPUT)lParam, numInputs, ti, sizeof( TOUCHINPUT))) numInputs is a pre-declared variable for storing several touch points. If 5 fingers are simultaneously sliding on the screen, then numInputs is 5. Ti is a TOUCHINPUT structure that contains the X and Y coordinates of the contact, the time of occurrence, and the type of touch (similar to mouse press, mouse movement, mouse release, etc.).
for(unsigned int i=0; i<numInputs; ++i){ //Loop according to the touch input point if (ti[i].dwFlags & TOUCHEVENTF_DOWN){ OnTouchDownHandler(hWnd, ti[i ]); //handed over to the contact press function processing }else if (ti[i].dwFlags & TOUCHEVENTF_MOVE) { OnTouchMoveHandler (hWnd, ti[i]); //handed over to the contact move function processing }else if (ti[i].dwFlags & TOUCHEVENTF_UP){ OnTouchUpHandler(hWnd, ti[i]);} //Handed to contact release function processing }
Here the contact is pressed, moved, released, etc. The function is actually a motion simulation model. In the model, we generate several motion curves for the trajectory of the contact, and calculate the azimuth, velocity, normal acceleration, tangential acceleration, etc. of each point to identify Make a specific gesture.
Tip: The easiest way to get multi-touch support is to use Win 7's gesture recognition function, mainly using the following API: GetSystemMetrics, used to check if multi-touch hardware devices exist and are ready . GetGestureInfo for getting gesture types and related data
Windows 7 is Microsofts latest desktop client operating system, a new system based on the advantages
win10 new file or folder prompts need administrator rights What
1. First, press the win+R shortcut on the win7 computer keyboard to open the computers running windo
XP system Microsoft has stopped maintenance and update, and the current domestic market share of XP
Should Windows 7 natively support ARM processors?
Win7 IE browser crash was accidentally closed webpage recovery tips
Enhance the security of confidential data through Windows disk settings
Modify the default startup location of Windows 7 Explorer
Win7 system how to set the Opera browser as the default browser
How to turn off win7 smart sorting function
Easily solve the telnet command failure failure under win7
How does the Win7 system make reading more comfortable?
Change the hosts file in Windows
Win7 system disables the Thinkpad touchpad so that we can operate the computer.
Win8 how to set the mouse click to open the folder method
Cancel screen saver and wallpaper to make win7 run faster
The latest five new highlights of Windows 7 system
Teach you to quickly add Win8.1 startup items
Remove the win8 system desktop icon lock method
Ubuntu can't input Chinese using QT. What should I do?
How to mount ntfs file system partition under linux
Win10 Xbox Music and One Drive Cloud Drive will open the user private song function