Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Capturing common control notification messages

3 views
Skip to first unread message

John Hynes

unread,
Dec 12, 2002, 7:41:49 AM12/12/02
to
Hi,

I am creating a Smart Device Application (in C#) that has a DateTimePicker
control on a windows form. I have managed to create the control and can use
it, but have no way of intercepting the WM_NOTIFY messages sent when the
user changes the date. Does anyone know how to do this. The help suggests
using the MessageWindow class but there is no way of setting the HWND of
this class.

Thanks
John

Lion Shi

unread,
Dec 16, 2002, 4:59:30 AM12/16/02
to
Hello John,

You may use a local message hook (global hook is not supported by .NET) to
hook all messages of the current thread and perform your own process. This
is a sample code about how to set a hook in C#:

//Sample code of get message hook
public class Win32Hook
{

[DllImport("kernel32")]
public static extern int GetCurrentThreadId();

[DllImport( "user32",
CharSet=CharSet.Auto,CallingConvention=CallingConvention.StdCall)]
public static extern int SetWindowsHookEx(
HookType idHook,
GetMsgProc lpfn,
int hmod,
int dwThreadId);

public enum HookType
{
WH_GETMESSAGE = 3
}

public delegate int GetMsgProc(int nCode, int wParam, int lParam);

public void SetHook()
{
// set the message hook
SetWindowsHookEx(HookType.WH_GETMESSAGE,
new GetMsgProc(this. MyGetMsgProc),
0,
GetCurrentThreadId());
}

public int MyGetMsgProc (int nCode, int wParam, int lParam)
{
//Perform your process
return 0;
}
}

Win32Hook hook = new Win32Hook();
hook.SetHook();

I hope this helps you.

Best regards,

Lion Shi [MSFT]
MCSE, MCSD
Microsoft Support Engineer

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. 2001 Microsoft Corporation. All rights
reserved.
--------------------
From: "John Hynes" <jo...@hynes.plus.com>
Newsgroups: microsoft.public.dotnet.languages.csharp
Subject: Capturing common control notification messages
Lines: 16
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2720.3000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
Message-ID: <9u%J9.589$h43.91887@stones>
Date: Thu, 12 Dec 2002 12:41:49 -0000
NNTP-Posting-Host: 212.159.127.5
X-Complaints-To: ab...@plus.net.uk
X-Trace: stones 1039696901 212.159.127.5 (Thu, 12 Dec 2002 12:41:41 GMT)
NNTP-Posting-Date: Thu, 12 Dec 2002 12:41:41 GMT
Organization: Customer of PlusNet
Path:
cpmsftngxa06!tkmsftngp01!newsfeed00.sul.t-online.de!t-online.de!nautilus.eus
c.inter.net!eusc.inter.net!mephistopheles.news.clara.net!news.clara.net!land
lord!stones.POSTED!not-for-mail
Xref: cpmsftngxa06 microsoft.public.dotnet.languages.csharp:115979
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp

John Hynes

unread,
Dec 17, 2002, 4:40:50 AM12/17/02
to
Thanks, but unfortunately SetWindowsHookEx isn't supported on CE so this
won't work.
John

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

0 new messages