all groups > dotnet compact framework > april 2004 >
You're in the

dotnet compact framework

group:

using IFilterMessage from OpenNetCF


Re: using IFilterMessage from OpenNetCF Maarten Struys, eMVP
4/8/2004 4:19:35 PM
dotnet compact framework:
In your Main method make sure you use ApplicationEx.Run instead of
Application.Run.


--
Maarten Struys, eMVP
PTS Software bv

www.opennetcf.org | www.dotnetfordevices.com

[quoted text, click to view]

using IFilterMessage from OpenNetCF Frankenstein
4/8/2004 6:27:21 PM
Hi,

I need to catch the mouse click event wherever it occurs in the form,
irrespective on which control the mouse/stylus is clicked. I tried using
the ApplicationEx.AddMessageFilter() API from the OpenNetCF library.
However, the API does not seem to work as suggested on the site. Even the
ApplicationEx sample from the site did not run on my PocketPC emulator.

Can you please take a look at the code pasted below and tell me where I am
going wrong. Apologies, if the formatting goes astray in the post.

Regards.

------
using System;

using System.Drawing;

using System.Collections;

using System.Windows.Forms;

using System.Data;

using System.IO;

using OpenNETCF.Windows.Forms;

using Microsoft.WindowsCE.Forms;



namespace Learn

{


public class Form1 : System.Windows.Forms.Form

{

private System.Windows.Forms.ComboBox comboBox1;

private System.Windows.Forms.Button button1;

private System.Windows.Forms.MainMenu mainMenu1;

public Form1()

{

InitializeComponent();

ApplicationEx.AddMessageFilter(new MouseFilter());

}


protected override void Dispose( bool disposing )

{

base.Dispose( disposing );

}

#region Windows Form Designer generated code


private void InitializeComponent()

{

this.mainMenu1 = new System.Windows.Forms.MainMenu();

this.comboBox1 = new System.Windows.Forms.ComboBox();

this.button1 = new System.Windows.Forms.Button();


this.comboBox1.Items.Add("One");

this.comboBox1.Items.Add("Two");

this.comboBox1.Items.Add("Three");

this.comboBox1.Location = new System.Drawing.Point(24, 48);


this.button1.Location = new System.Drawing.Point(160, 128);

this.button1.Text = "button1";


this.Controls.Add(this.button1);

this.Controls.Add(this.comboBox1);

this.Menu = this.mainMenu1;

this.Text = "Form1";

}

#endregion


static void Main()

{

Application.Run(new Form1());

}

}

class MouseFilter : IMessageFilter

{

public bool PreFilterMessage(ref Microsoft.WindowsCE.Forms.Message msg)

{

switch((WinMsg)msg.Msg)

{

case WinMsg.WM_LBUTTONDOWN:

System.Windows.Forms.MessageBox.Show("Double Click!");

break;

}

return false;

}

}

}




---

Re: using IFilterMessage from OpenNetCF Frankenstein
4/8/2004 9:45:01 PM
Thank you so much, Marteen!! It worked :) You've saved me a lot of time and
effort in figuring it out.

Vijay

[quoted text, click to view]

AddThis Social Bookmark Button