C # winCE5.0 development right-click results Solution

Source: Internet
Author: User

I used VS2008 to develop the C # Language wince program. I found that the program could not be captured by the Right-click, and the Collector did not respond. I found a c ++ version on the Internet and couldn't understand it, below I will provide a solution for Implementing the Right-click effect in C #. Please optimize it a lot. First, the control ContextMenu and Timer set contextMenu1 to implement right-click in the dataGrid, and the event datagrid?mousedown presses the mouse button event. Code [csharp] public int _ x; public int _ y; private void datagrid=mousedown (object sender, MouseEventArgs e) {System. drawing. point Pt = new Point (e. x, e. y); DataGrid. hitTestInfo Ht = maid (Pt. x, Pt. y); // this. maid = new maid (Ht. row, Ht. column); // this. dataGrid1.Select (Ht. row); if (Ht. row> = 0 & Ht. column> = 0) {_ x = e. X + 2; // record the current coordinate of the mouse _ y = e. Y + 1; // same as above (priorP Previously declared oint) SHRGINFO shr = new SHRGINFO (); shr. cbSize = Marshal. sizeOf (typeof (SHRGINFO); shr. dwFlags = SHRGFLags. SHRG_RETURNCMD; shr. ptDownX = MousePosition. x-2; shr. ptDownY = MousePosition. y-8; shr. hwndClient = GetActiveWindow (); int ret = SHRecognizeGesture (ref shr); if (ret = 1000) {timer1.Enabled = true; // enable timer }}internal struct SHRGINFO {public int cbSize; public IntPtr hwndClient; Public int ptDownX; public int ptDownY; public SHRGFLags dwFlags;} [Flags] internal enum SHRGFLags {blocks = 0x00000001, shrg_policyparent = 0x00000002, SHRG_LONGDELAY = 0x00000008, SHRG_NOANIMATION = 0x00000010,} [DllImport ("aygshell")] extern private static int SHRecognizeGesture (ref SHRGINFO shr); [DllImport ("coredll. dll ", SetLastError = true)] public static extern IntPtr GetActive Window (); DataGrid. HitTestInfo I used it for the first time. After the coordinates are passed in, I can know which column is on the left and whether there is any data. I will make the following judgments to display the data. Ret = 1000 circles in exactly one [DllImport ("aygshell")] extern private static int SHRecognizeGesture (ref SHRGINFO shr); [DllImport ("coredll. dll ", SetLastError = true)] public static extern IntPtr GetActiveWindow (); enable the collector DLL interface program. MousePosition. X-2 The current mouse-2 is the control circle. It is not built in the mouse. I have adjusted it, And _ X _ Y will be used in time. Timer1 event. If the right-click menu is displayed here, because the resource is not released, an error is reported. Only the next event can be started. I wrote it in timer1_Tick, use timer1.Enabled = true to enable the event [csharp] private void timerjavastick (object sender, EventArgs e) {string pids = this. dataGrid1 [this. dataGrid1.CurrentRowIndex, 0]. toString (); if (pids! = "") {ContextMenu1.Show (dataGrid1, new Point (_ x, _ y); // The context menu timer1.Enabled = false;} appears. You need to write the control dataGrid1 this bound to contextmenu1. dataGrid1 [this. dataGrid1.CurrentRowIndex, 0]. toString (); to obtain a column in the selected row.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.