// will ensure that the toolTip window was created public void CreateToolTipHandle() { if (tipWindow == null || tipWindow.Handle == IntPtr.Zero) { NativeMethods.INITCOMMONCONTROLSEX icc = new NativeMethods.INITCOMMONCONTROLSEX { dwICC = NativeMethods.ICC_TAB_CLASSES }; icc.dwSize = Marshal.SizeOf(icc); SafeNativeMethods.InitCommonControlsEx(icc); CreateParams cparams = new CreateParams { Parent = dataGrid.Handle, ClassName = NativeMethods.TOOLTIPS_CLASS, Style = NativeMethods.TTS_ALWAYSTIP }; tipWindow = new NativeWindow(); tipWindow.CreateHandle(cparams); User32.SendMessageW(tipWindow, User32.WindowMessage.TTM_SETMAXTIPWIDTH, IntPtr.Zero, (IntPtr)SystemInformation.MaxWindowTrackSize.Width); User32.SetWindowPos( new HandleRef(tipWindow, tipWindow.Handle), User32.HWND_NOTOPMOST, flags: User32.SWP.NOSIZE | User32.SWP.NOMOVE | User32.SWP.NOACTIVATE); User32.SendMessageW(tipWindow, User32.WindowMessage.TTM_SETDELAYTIME, (IntPtr)ComCtl32.TTDT.INITIAL, (IntPtr)0); } }
/// <include file='doc\TrackBar.uex' path='docs/doc[@for="TrackBar.CreateHandle"]/*' /> /// <devdoc> /// </devdoc> /// <internalonly/> protected override void CreateHandle() { if (!RecreatingHandle) { NativeMethods.INITCOMMONCONTROLSEX icc = new NativeMethods.INITCOMMONCONTROLSEX(); icc.dwICC = NativeMethods.ICC_BAR_CLASSES; SafeNativeMethods.InitCommonControlsEx(icc); } base.CreateHandle(); }
protected override void CreateHandle() { if (!this.RecreatingHandle) { NativeMethods.INITCOMMONCONTROLSEX init = new NativeMethods.INITCOMMONCONTROLSEX(); init.Size = Marshal.SizeOf(typeof(NativeMethods.INITCOMMONCONTROLSEX)); init.Flags = NativeMethods.ICC_BAR_CLASSES | NativeMethods.ICC_COOL_CLASSES; NativeMethods.InitCommonControlsEx(init); } base.CreateHandle(); }
/// <include file='doc\TrackBar.uex' path='docs/doc[@for="TrackBar.CreateHandle"]/*' /> /// <devdoc> /// </devdoc> /// <internalonly/> protected override void CreateHandle() { if (!RecreatingHandle) { IntPtr userCookie = UnsafeNativeMethods.ThemingScope.Activate(); try { NativeMethods.INITCOMMONCONTROLSEX icc = new NativeMethods.INITCOMMONCONTROLSEX(); icc.dwICC = NativeMethods.ICC_BAR_CLASSES; SafeNativeMethods.InitCommonControlsEx(icc); } finally { UnsafeNativeMethods.ThemingScope.Deactivate(userCookie); } } base.CreateHandle(); }
/// <include file='doc\ToolTip.uex' path='docs/doc[@for="ToolTip.CreateHandle"]/*' /> /// <devdoc> /// Creates the handle for the control. /// </devdoc> /// <internalonly/> private void CreateHandle() { if (GetHandleCreated()) { return; } NativeMethods.INITCOMMONCONTROLSEX icc = new NativeMethods.INITCOMMONCONTROLSEX(); icc.dwICC = NativeMethods.ICC_TAB_CLASSES; SafeNativeMethods.InitCommonControlsEx(icc); window.CreateHandle(CreateParams); SafeNativeMethods.SetWindowPos(new HandleRef(this, Handle), NativeMethods.HWND_TOPMOST, 0, 0, 0, 0, NativeMethods.SWP_NOMOVE | NativeMethods.SWP_NOSIZE | NativeMethods.SWP_NOACTIVATE); // Setting the max width has the added benefit of enabling multiline // tool tips! // UnsafeNativeMethods.SendMessage(new HandleRef(this, Handle), NativeMethods.TTM_SETMAXTIPWIDTH, 0, SystemInformation.MaxWindowTrackSize.Width); Debug.Assert(NativeMethods.TTDT_AUTOMATIC == 0, "TTDT_AUTOMATIC != 0"); if (auto) { SetDelayTime(NativeMethods.TTDT_AUTOMATIC, delayTimes[NativeMethods.TTDT_AUTOMATIC]); delayTimes[NativeMethods.TTDT_AUTOPOP] = GetDelayTime(NativeMethods.TTDT_AUTOPOP); delayTimes[NativeMethods.TTDT_INITIAL] = GetDelayTime(NativeMethods.TTDT_INITIAL); delayTimes[NativeMethods.TTDT_RESHOW] = GetDelayTime(NativeMethods.TTDT_RESHOW); } else { for (int i = 1; i < delayTimes.Length; i++) { if (delayTimes[i] >= 1) { SetDelayTime(i, delayTimes[i]); } } } // Set active status // UnsafeNativeMethods.SendMessage(new HandleRef(this, Handle), NativeMethods.TTM_ACTIVATE, (active == true) ? 1 : 0, 0); }
// will ensure that the toolTip window was created public void CreateToolTipHandle() { if (tipWindow == null || tipWindow.Handle == IntPtr.Zero) { NativeMethods.INITCOMMONCONTROLSEX icc = new NativeMethods.INITCOMMONCONTROLSEX(); icc.dwICC = NativeMethods.ICC_TAB_CLASSES; icc.dwSize = Marshal.SizeOf(icc); SafeNativeMethods.InitCommonControlsEx(icc); CreateParams cparams = new CreateParams(); cparams.Parent = dataGrid.Handle; cparams.ClassName = NativeMethods.TOOLTIPS_CLASS; cparams.Style = NativeMethods.TTS_ALWAYSTIP; tipWindow = new NativeWindow(); tipWindow.CreateHandle(cparams); UnsafeNativeMethods.SendMessage(new HandleRef(tipWindow, tipWindow.Handle), NativeMethods.TTM_SETMAXTIPWIDTH, 0, SystemInformation.MaxWindowTrackSize.Width); SafeNativeMethods.SetWindowPos(new HandleRef(tipWindow, tipWindow.Handle), NativeMethods.HWND_NOTOPMOST, 0, 0, 0, 0, NativeMethods.SWP_NOSIZE | NativeMethods.SWP_NOMOVE | NativeMethods.SWP_NOACTIVATE); UnsafeNativeMethods.SendMessage(new HandleRef(tipWindow, tipWindow.Handle), NativeMethods.TTM_SETDELAYTIME, NativeMethods.TTDT_INITIAL, 0); } }
/// <include file='doc\ToolBar.uex' path='docs/doc[@for="ToolBar.CreateHandle"]/*' /> /// <devdoc> /// </devdoc> /// <internalonly/> protected override void CreateHandle() { if (!RecreatingHandle) { IntPtr userCookie = UnsafeNativeMethods.ThemingScope.Activate(); try { NativeMethods.INITCOMMONCONTROLSEX icc = new NativeMethods.INITCOMMONCONTROLSEX(); icc.dwICC = NativeMethods.ICC_BAR_CLASSES; SafeNativeMethods.InitCommonControlsEx(icc); } finally { UnsafeNativeMethods.ThemingScope.Deactivate(userCookie); } } base.CreateHandle(); }
/// <include file='doc\DateTimePicker.uex' path='docs/doc[@for="DateTimePicker.CreateHandle"]/*' /> /// <devdoc> /// Creates the physical window handle. /// </devdoc> protected override void CreateHandle() { if (!RecreatingHandle) { IntPtr userCookie = UnsafeNativeMethods.ThemingScope.Activate(); try { NativeMethods.INITCOMMONCONTROLSEX icc = new NativeMethods.INITCOMMONCONTROLSEX(); icc.dwICC = NativeMethods.ICC_DATE_CLASSES; SafeNativeMethods.InitCommonControlsEx(icc); } finally { UnsafeNativeMethods.ThemingScope.Deactivate(userCookie); } } creationTime = DateTime.Now; base.CreateHandle(); if (userHasSetValue && validTime) { /* * Make sure any changes to this code * get propagated to setValue */ int gdt = NativeMethods.GDT_VALID; NativeMethods.SYSTEMTIME sys = DateTimePicker.DateTimeToSysTime(Value); UnsafeNativeMethods.SendMessage(new HandleRef(this, Handle), NativeMethods.DTM_SETSYSTEMTIME, gdt, sys); } else if (!validTime) { int gdt = NativeMethods.GDT_NONE; NativeMethods.SYSTEMTIME sys = null; UnsafeNativeMethods.SendMessage(new HandleRef(this, Handle), NativeMethods.DTM_SETSYSTEMTIME, gdt, sys); } if (format == DateTimePickerFormat.Custom) { SendMessage(NativeMethods.DTM_SETFORMAT, 0, customFormat); } UpdateUpDown(); SetAllControlColors(); SetControlCalendarFont(); SetRange(); }
/// <include file='doc\ListView.uex' path='docs/doc[@for="ListView.CreateHandle"]/*' /> /// <devdoc> /// </devdoc> /// <internalonly/> protected override void CreateHandle() { if (!RecreatingHandle) { IntPtr userCookie = UnsafeNativeMethods.ThemingScope.Activate(); try { NativeMethods.INITCOMMONCONTROLSEX icc = new NativeMethods.INITCOMMONCONTROLSEX(); icc.dwICC = NativeMethods.ICC_LISTVIEW_CLASSES; SafeNativeMethods.InitCommonControlsEx(icc); } finally { UnsafeNativeMethods.ThemingScope.Deactivate(userCookie); } } base.CreateHandle(); // image location if (this.BackgroundImage != null) SetBackgroundImage(); }
public static extern bool InitCommonControlsEx(NativeMethods.INITCOMMONCONTROLSEX icc);
/// <include file='doc\ToolTip.uex' path='docs/doc[@for="ToolTip.CreateHandle"]/*' /> /// <devdoc> /// Creates the handle for the control. /// </devdoc> /// <internalonly/> private void CreateHandle() { if (GetHandleCreated()) { return; } IntPtr userCookie = UnsafeNativeMethods.ThemingScope.Activate(); try { NativeMethods.INITCOMMONCONTROLSEX icc = new NativeMethods.INITCOMMONCONTROLSEX(); icc.dwICC = NativeMethods.ICC_TAB_CLASSES; SafeNativeMethods.InitCommonControlsEx(icc); CreateParams cp = CreateParams; // Avoid reentrant call to CreateHandle (VSWhidbey 570764) if (GetHandleCreated()) { return; } window.CreateHandle(cp); } finally { UnsafeNativeMethods.ThemingScope.Deactivate(userCookie); } // If in ownerDraw mode, we don't want the default border. if (ownerDraw) { int style = unchecked((int)((long)UnsafeNativeMethods.GetWindowLong(new HandleRef(this, Handle), NativeMethods.GWL_STYLE))); style &= ~NativeMethods.WS_BORDER; UnsafeNativeMethods.SetWindowLong(new HandleRef(this, Handle), NativeMethods.GWL_STYLE, new HandleRef(null, (IntPtr)style)); } // Setting the max width has the added benefit of enabling multiline // tool tips! // UnsafeNativeMethods.SendMessage(new HandleRef(this, Handle), NativeMethods.TTM_SETMAXTIPWIDTH, 0, SystemInformation.MaxWindowTrackSize.Width); Debug.Assert(NativeMethods.TTDT_AUTOMATIC == 0, "TTDT_AUTOMATIC != 0"); if (auto) { SetDelayTime(NativeMethods.TTDT_AUTOMATIC, delayTimes[NativeMethods.TTDT_AUTOMATIC]); delayTimes[NativeMethods.TTDT_AUTOPOP] = GetDelayTime(NativeMethods.TTDT_AUTOPOP); delayTimes[NativeMethods.TTDT_INITIAL] = GetDelayTime(NativeMethods.TTDT_INITIAL); delayTimes[NativeMethods.TTDT_RESHOW] = GetDelayTime(NativeMethods.TTDT_RESHOW); } else { for (int i=1; i < delayTimes.Length; i++) { if (delayTimes[i] >= 1) { SetDelayTime(i, delayTimes[i]); } } } // Set active status // UnsafeNativeMethods.SendMessage(new HandleRef(this, Handle), NativeMethods.TTM_ACTIVATE, (active == true) ? 1 : 0, 0); if (BackColor != SystemColors.Info) { UnsafeNativeMethods.SendMessage(new HandleRef(this, Handle), NativeMethods.TTM_SETTIPBKCOLOR, ColorTranslator.ToWin32(BackColor), 0); } if (ForeColor != SystemColors.InfoText) { UnsafeNativeMethods.SendMessage(new HandleRef(this, Handle), NativeMethods.TTM_SETTIPTEXTCOLOR, ColorTranslator.ToWin32(ForeColor), 0); } if (toolTipIcon > 0 || !String.IsNullOrEmpty(toolTipTitle)) { // If the title is null/empty, the icon won't display. string title = !String.IsNullOrEmpty(toolTipTitle) ? toolTipTitle : " "; UnsafeNativeMethods.SendMessage(new HandleRef(this, Handle), NativeMethods.TTM_SETTITLE, (int)toolTipIcon, title); } }
/// <include file='doc\ErrorProvider.uex' path='docs/doc[@for="ErrorProvider.ErrorWindow.EnsureCreated"]/*' /> /// <devdoc> /// Make sure the error window is created, and the tooltip window is created. /// </devdoc> bool EnsureCreated() { if (Handle == IntPtr.Zero) { if (!parent.IsHandleCreated) { return false; } CreateParams cparams = new CreateParams(); cparams.Caption = String.Empty; cparams.Style = NativeMethods.WS_VISIBLE | NativeMethods.WS_CHILD; cparams.ClassStyle = NativeMethods.CS_DBLCLKS; cparams.X = 0; cparams.Y = 0; cparams.Width = 0; cparams.Height = 0; cparams.Parent = parent.Handle; CreateHandle(cparams); NativeMethods.INITCOMMONCONTROLSEX icc = new NativeMethods.INITCOMMONCONTROLSEX(); icc.dwICC = NativeMethods.ICC_TAB_CLASSES; icc.dwSize = Marshal.SizeOf(icc); SafeNativeMethods.InitCommonControlsEx(icc); cparams = new CreateParams(); cparams.Parent = Handle; cparams.ClassName = NativeMethods.TOOLTIPS_CLASS; cparams.Style = NativeMethods.TTS_ALWAYSTIP; tipWindow = new NativeWindow(); tipWindow.CreateHandle(cparams); UnsafeNativeMethods.SendMessage(new HandleRef(tipWindow, tipWindow.Handle), NativeMethods.TTM_SETMAXTIPWIDTH, 0, SystemInformation.MaxWindowTrackSize.Width); SafeNativeMethods.SetWindowPos(new HandleRef(tipWindow, tipWindow.Handle), NativeMethods.HWND_TOP, 0, 0, 0, 0, NativeMethods.SWP_NOSIZE | NativeMethods.SWP_NOMOVE | NativeMethods.SWP_NOACTIVATE); UnsafeNativeMethods.SendMessage(new HandleRef(tipWindow, tipWindow.Handle), NativeMethods.TTM_SETDELAYTIME, NativeMethods.TTDT_INITIAL, 0); } return true; }