c# - Windows 7 left click on clock popup -


When a click is left on the clock in Windows 7 (probably Vista too) a popup opens the calendar and the clock (S) (Do not include dates and time adjusted window). How do I open this window myself (like in C #)?

I expected timeliness to call it, but it opens the date and time adjusted window.

To show the clock, you need to send the proper window message in the tray window. This can be done using the Windows API Function SendMessage :

 ; Using System.ComponentModel; Using System.Runtime.InteropServices; Using System.Text; Class ShowCalendar {Personal representative Bull EnumChildCallback (IntPtr hwnd, ref IntPtr lParam); [DllImport ("User32.dll")] Private static deportation bool EnumChildWindows (IntPtr hWndParent, EnumChildCallback lpEnumFunc, IntPtr lParam referee); [DllImport ("User32.dll")] Private static extern int GetClassName (IntPtr hWnd, StringBuilder lpClassName, int nMaxCount); [DllImport ("user32.dll", charset = CharSet.Auto)] Private Static Execution IntPtr SendMessage (IntPtr hWnd, UInt32 Message, IntPtr wParam, IntPtr lParam); [DllImport ("user32.dll", SetLastError = true)] Private static extern IntPtr FindWindow (string lpClassName, string lpWindowName); [DllImport ("user32.dll", SetLastError = true)] Private Static Execution IntPtr FindWindowEx (IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow); [DllImport ("user32.dll")] [Return: MarshalAs (UnmanagedType.Bool)] Private Stable Execution bool GetWindowRect (IntPtr hWnd, outside RECT lpRect); [Structure Layout (LayoutCind.Security)] Private Structure RECT {Public ANAT; Public int top; Public int right; Public int bottom; } Private static readonly string TrayWndClassName = "Shell_TrayWnd"; Private static readonly string TrayNotifyWndClassName = "TrayNotifyWnd"; Private static readonly string ClockWndClassName = "TrayClockWClass"; UIT WM_NCLBUTTONDOWN = 0x00A1 for private static reading; Private static Read only for HTCAPTION = 2; Private Static Bull EnumChildProc (IntPtr hwndChild, Referee IntPtr lParam) {StringBuilder className = new StringBuilder (128); GetClassName (hwndChild, classname, 128); If (className.ToString () == ClockWndClassName) {lParam = hwndChild; return false; } Back true; } Fixed Zero main (string [] args) {IntPtr hWndTray = FindWindow (TrayWndClassName, string.Empty); If (hWndTray == IntPtr.Zero) {new Win32Exception (); } ITPTR HWDTRNotify = SearchWindow (HWTTRA, INTTPTR.Zero, TrayNotif Vand classname, string.opti); If (hWndTrayNotify == IntPtr.Zero) {new Win32Exception (); } // Search Watch Window EnumChildCallback cb = New EnumChildCallback (EnumChildProc); IntPtr hWndClock = IntPtr.Zero; EnumChildWindows (hWndTray, CB, Referee, WWW); If (hWndClock == IntPtr.Zero) {new Win32Exception (); } // clock window status RECT rect; If (GetWindowRect (hWndClock, rect out)) {New Win32Exception (); } // Click Click, the window position in lParam is included IntPtr wParam = New Interpet (HTCAPTN); IntPtr lParam = New IntPtr (rect.Top & lt; <16 | rect.Left); Send Message (HWNTTRE, WM_NCLBTTANDDA, WPAMM, LPAMM); }}  

Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -