On the new Pocket PC device, you can click and hold to confirm the operation. This is a great way to show your application what operations are being performed. However, when you use Microsoft Embedded Visual Basic
Click length and press OK. You must add this support by yourself.
First, you need to capture the window messages sent to each control (the most important is the wm_lbuttondown message ). You can achieve this by using third-party controls such as messagece. Then, you need to use the Windows CE API
Shrecognizegesture. This API processes the display of the confirmation process (a circle of red dots is displayed clockwise during the long-pressed operation) and returns the result code, used to indicate whether the user has been holding the pen for a long enough time.
'Let's take a look at the core part of the click-long confirmation code. As I mentioned, you need to declare the shrecognizegesture API: <br/> Public declare function shrecognizegesture lib "aygshell" (byval shrginfo as string) as long </P> <p> 'you also need to declare some API constants: <br/> Public const shrg_returncmd = & H1 </P> <p> Public const gn_contextmenu = 1000 </P> <p> 'Below is the function for capturing long-pressed clicks: <br/> Public Function iscontextmenugesture (byval hwnd as long, byval X as <br/> single, byval y as single) as Boolean </P> <p> dim lsshrgin Fo as string </P> <p> lsshrginfo = longtobytes (20) & longtobytes (hwnd) & _ <br/> longtobytes (x) & longtobytes (y) & _ <br/> longtobytes (shrg_returncmd) </P> <p> iscontextmenugesture = (gn_contextmenu = _ <br/> shrecognizegesture (lsshrginfo )) </P> <p> end function </P> <p> 'You can see that I am simulating a shrginfo structure by adding a member value to the string. The shrginfo structure is as follows: <br/> typedef struct tagshrgi {<br/> DWORD cbsize; <br/> hwnd hwndclient; <br/> point ptdown; <br/> DWORD dwflags; <br/>} shrginfo, * pshrginfo; <br/>
In a simulated structure (such as a string), I set the handle and coordinates of the window to the corresponding member of the structure. If the user presses the pen for a long enough time, the shrg_returncmd value of the dwflags member will notify the API to return a gn_contextmenu value.