Sorry...I forgot to updatethe constant value to the correct value...replace
the definition of the WM_TIMECHANGE constant with:
private const int WM_TIMECHAGE = 0x001E;
Also, the declaration for WM_TIMECHANGE is located within user32.h
Thanks! Robert Gruen
Microsoft, VB.NET
This posting is provided "AS IS", with no warranties, and confers no rights.
--------------------
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| From: (e-mail address removed) (Robert Gruen [MSFT])
| Organization: Microsoft
| Date: Mon, 03 Nov 2003 15:39:22 GMT
| Subject: RE: Windows Hooks.
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
|
| Meghansh,
|
| This shouldn't be too hard for you to accomplish. All you have to do is
| override the WndProc method and listen for the message that you're
| interested in. Here's a link that will show you how to hook the message
| pump:
|
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
| frlrfsystemwindowsformsnativewindowclasswndproctopic.asp. After you do
| that just put some code in that handles the message your interested in.
| From your posting I'm assuming its: WM_TIMECHANGE.
|
| So, for you you'd want to do something like:
|
| public class Form1: System.Windows.Forms.Form
| {
|
| // Constant value was found in the "windows.h" header file.
| private const int WM_TIMECHANGE = 0x001C;
|
|
[System.Security.Permissions.PermissionSet(System.Security.Permissions.Secur
| ityAction.Demand, Name="FullTrust")]
| protected override void WndProc(ref Message m){
| // Listen for operating system messages
|
| switch (m.Msg){
| case WM_TIMECHANGE:
| // Insert your code here to do what you want when the
| system time has changed.
| break;
| }
| base.WndProc(ref m);
| }
| }
|
|
| Thanks! Robert Gruen
| Microsoft, VB.NET
|
| This posting is provided "AS IS", with no warranties, and confers no
rights.
|
| --------------------
| | Content-Class: urn:content-classes:message
| | From: "Meghansh" <
[email protected]>
| | Sender: "Meghansh" <
[email protected]>
| | Subject: Windows Hooks.
| | Date: Mon, 3 Nov 2003 05:52:32 -0800
| | Lines: 10
| | Message-ID: <
[email protected]>
| | MIME-Version: 1.0
| | Content-Type: text/plain;
| | charset="iso-8859-1"
| | Content-Transfer-Encoding: 7bit
| | X-Newsreader: Microsoft CDO for Windows 2000
| | X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| | Thread-Index: AcOiEbp6PEMrUhTpSvGVIih4MS5Oxw==
| | Newsgroups: microsoft.public.dotnet.framework.windowsforms
| | Path: cpmsftngxa06.phx.gbl
| | Xref: cpmsftngxa06.phx.gbl
| microsoft.public.dotnet.framework.windowsforms:55767
| | NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| | X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
| |
| | Hello All,
| | Can some one tell me how I can write code to notify my
| | running application that there is a change in system time?
| | Read somewhere that it could be done thru Hooks, but I've
| | no idea which messages to listen in C# for this..
| |
| | Any help would be appreciated.
| |
| | Thanks,
| | Meghansh.
| |
|