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

A

Andrew Martin

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
 
A

Andrew Martin

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top