简体   繁体   中英

Unexpected mouse click event occurs .NET Compact Framework 3.5

I am new to c# .NET Compact Framework 3.5.

I am trying to prevent mouse events from eager users to queue up. This sometimes leads to unintended clicks.

What is the best way to ignore queued mouse messages on the .NET Compact Framework platform? Sadly, the code has to run on the UI thread.

I have tried: 1. Disable window and Application.DoEvents(); then Enabled window --> it did not work. 2. I read a lot about PeekMessage() --> but could not figure out.

please recommend me resource which i can learn.

Thank you so much.

Thank Google and others, I used PeekMessage()..I will post a code (may it will help some one.)

    private const uint PM_REMOVE = 0x1;
    private const uint WM_MOUSEFIRST = 0x0200;
    private const uint WM_MOUSELAST = 0x0209;
    private const uint WM_QUIT = 0x0012;
    private struct Message
    {
        long hwnd;
        long message;
        long wParam;
        long lParam;
        long time;
        Point pt;
    }
    #if WindowsCE
    [DllImport("coredll.dll")]
    #else
    [DllImport("Kernel32.dll")]
    #endif
private extern static bool PeekMessage(out Message Msg, IntPtr hWnd, uint wMsgFilterMin, uint wMsgFilterMax, uint wRemoveMsg);
  public void ClearMouseClickQueue()
        {  Message msg;
    while (PeekMessage(out msg, IntPtr.Zero, WM_MOUSEFIRST,WM_MOUSELAST, 1) != false){ }} 

That it was...cool right...

Another option to disable touch input is to use TouchRegisterWindow and TouchUnregisterWindow with a small window (element). That can be used to disable all clicks in a current dialog without having to disable all elements one by one.

Details at http://www.hjgode.de/wp/2012/09/24/windows-mobile-disable-touch-input/

Something like this

class MyForm : Form
{
    private bool _processing;

    private void OnMousedown(....) // really depends on what you use, 
        // Click/doubleclick/Up/down - concept is the same
    {
        if (_processing)
            return;
        _processing = true;
        // do something 
        . . . . . . 

        _processing = false;
     }
. . . . . 

you may need to do it on each control event

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM