John's profileJohn Stewien's Road To S...BlogListsNetworkMore Tools Help

John Stewien's Road To Somewhere Else

Programming in WPF (.NET 3.0) and moving to Taiwan

List of John Stewien's recent entries

Loading...Loading...
11/21/2009

Handling all mouse movements at the Main Form level in C#

In a C# WinForms application, mouse movement events always go to the child control that the mouse moves over. Sometimes you might want to track mouse movements at the Form level instead of handling them at the child control level. To do this you need to handle the raw windows messages at the application level. Here’s the source code for doing this:

      public partial class MainForm : Form

      {

            [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)]

            public class TestMessageFilter : IMessageFilter

            {

                  const int WM_MOUSEMOVE = 0x200;

                  static int count = 0;

                  public bool PreFilterMessage(ref Message m)

                  {

                        // Blocks all the messages relating to the left mouse button.

                        if (m.Msg == WM_MOUSEMOVE)

                        {

                              System.Diagnostics.Trace.WriteLine("Mouse Moved " + (++count).ToString());

                              return true;

                        }

                        return false;

                  }

            }

 

            public MainForm()

            {

                  InitializeComponent();

                  Application.AddMessageFilter(new TestMessageFilter());

            }

 

The WM_MOUSEMOVE constant is from C/C++ programming and is part of the Win32 API. It’s declared in Winuser.h which can be found in the Windows SDK if you have Visual C++ installed.

10/5/2009

A long overdue update

It’s been nearly 2 months since I updated my blog. I’ve been busy with work, and I’ve been using facebook for one line updates.

I’ve got a few projects on the go that have some big potential. There’s some R&D and collaboration to be done first so I’m going to be in Australia for a while by the looks, so this week I’m renting an apartment in Adelaide for Jasmine, Violet, and myself to live in for the next 6 months. Sort of follows a loose idea I had about spending June-August in the Northern Hemisphere, and Dec-Feb in the Southern. I like summer.

8/16/2009

3C Kid

In Taiwan they call IT stuff “3C”

IMG_0021

8/7/2009

My Birthday Photos

For my birthday we went on a outing to Taipei.

It was hot in the morning, Violet was feeling the heat:

IMG_0010

We had all you can eat lunch at fancy restaurant. Cost AU$18 for the 3 of us. We got a discount because it was my birthday. Below Violet is eating some egg and fish pudding.
IMG_0041

At the end of the meal Violet enjoyed getting her dessert which was a milk pudding:
IMG_0045

After lunch we went to a shopping complex called Miramar. We started off walking around the shops:

IMG_0055

Things escalated when we got to the floor with all the childrens toys with many toys within reach for children to try out. As I dragged Violet away from one thing I ended up pacifying her outbursts with something more intriguing, with each iteration getting more and more exciting for her until we ended up in a gaming arcade where she rode some rides:
IMG_0051

After all that we went to a micro-brewery on the roof where they served freshly brewed German style black beer with no preservatives. Also on the roof is a Ferris Wheel:

IMG_0064

We went of the Ferris Wheel. Here's the view of Taipei from near the top:

IMG_0091

The following collection of shots are of us riding the Ferris Wheel:
 
IMG_0093 

Violet got more interested in looking out once we reached the top:
 
IMG_0088 

IMG_0075
IMG_0074
IMG_0066 

The sun was going down, you can see it here just above the mountain:

IMG_0086

After that we went on the Carousel:

IMG_0103
 
IMG_0110

8/6/2009

Violet the Alarm Clock

This is how Violet wakes me up in the morning: