Re: Microsoft.WindowsCE.Forms.Message to get Parent Control?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Andrew Martin (andrew_f_martin_at_hotmail.com)
Date: 08/24/04


Date: 24 Aug 2004 11:59:33 -0700

andrew_f_martin@hotmail.com (Andrew Martin) wrote in message news:<867aa7dd.0408240623.761fb7e2@posting.google.com>...
> I have implemented a custom DateTimePicker control with OpenNETCF
> IMessageFilter:
>
> public bool PreFilterMessage(ref Microsoft.WindowsCE.Forms.Message m)
> { // Add MsgWindowTest.PreFilterMessage implementation
> if (m.Msg == (int)WinAPI.eWM.WM_LBUTTONDOWN)
> {
> // Get the low and high order words (X, Y coordinates)
> int x = DateTimePicker.DateTimePicker.Get_X_LParam(m.LParam.ToInt32());
> int y = DateTimePicker.DateTimePicker.Get_Y_LParam(m.LParam.ToInt32());
>
> if (this.hourRectangle.Contains(x, y))
> // The hour has focus
> }
> }
>
> I then use a numericUpDown to increment the date part that has focus.
> The issue is that I have 2 controls on my custom control - and m.Msg
> returns the X,Y for whichever control is clicked (the DateTimePicker
> which I want...and the NumericUpDown which I don't). Is there any way
> to determine the control that the X,Y belongs to from this message?
>
> Microsoft.WindowsCE.Forms.Message m
>
> m.HWnd;
> m.LParam;
> m.Msg;
> m.Result;
> m.WParam;
>
> Thanks for your help.
> -a

Rectangle rect = OpenNETCF.Win32.Win32Window.GetWindowRect(m.HWnd);
if (rect.Size == DateTimePicker.Size) // This is the one I care about

- works fine.

-a


Quantcast