protected override void WndProc(ref Microsoft.WindowsCE.Forms.Message m) { if (m.Msg == (int)WM.NOTIFY) { //marshal notification data into NMHDR struct NMHDR hdr = (NMHDR)Marshal.PtrToStructure(m.LParam, typeof(NMHDR)); if (hdr.hwndFrom == parent.Handle) { switch (hdr.code) { //definite selection case (int)MCN.SELECT: //copy date range SystemTime stStart = new SystemTime(); Marshal.Copy((IntPtr)((int)m.LParam + 12), stStart.ToByteArray(), 0, stStart.ToByteArray().Length); SystemTime stEnd = new SystemTime(); Marshal.Copy((IntPtr)((int)m.LParam + 28), stEnd.ToByteArray(), 0, stEnd.ToByteArray().Length); //raise datechanged event parent.OnDateSelected(new DateRangeEventArgs(stStart.ToDateTime(), stEnd.ToDateTime())); break; } } } base.WndProc(ref m); }
} //OnKeyDown() /// <summary> /// Capture messages for the list view control. /// </summary> /// <param name="message"></param> protected override void WndProc(ref Message message) { const int WM_NOTIFY = 0x004E; const int HDN_FIRST = (0 - 300); const int HDN_BEGINTRACKA = (HDN_FIRST - 6); const int HDN_BEGINTRACKW = (HDN_FIRST - 26); bool callBase = true; switch (message.Msg) { case WM_NOTIFY: NMHDR nmhdr = (NMHDR)message.GetLParam(typeof(NMHDR)); switch (nmhdr.code) { case HDN_BEGINTRACKA: //Process both ANSI and case HDN_BEGINTRACKW: //UNICODE versions of the message. if (locked) { //Discard the begin tracking to prevent dragging of the //column headers. message.Result = (IntPtr)1; callBase = false; } //if break; } //switch break; } //switch if (callBase) { // pass messages on to the base control for processing base.WndProc(ref message); } //if } //WndProc()
protected virtual bool ShellViewController_MessageCaptured(ref Message msg) { switch (msg.Msg) { case WM.MOUSEACTIVATE: int res = (int)msg.Result; bool ret = OnMouseActivate(ref res); msg.Result = (IntPtr)res; return(ret); case WM.NOTIFY: NMHDR nmhdr = (NMHDR)Marshal.PtrToStructure(msg.LParam, typeof(NMHDR)); return(OnShellViewNotify(nmhdr, ref msg)); // The DropTarget isn't registered until some time after the window is // created. These messages don't fire that often, and always seem // to fire around the time the DropTarget is registered, but they're // just guesses. The smart way to do this is to set an API hook on // RegisterDragDrop. TODO. case WM.SHOWWINDOW: if (msg.WParam != IntPtr.Zero && dropTargetPassthrough == null) { HookDropTarget(); } break; case WM.WINDOWPOSCHANGING: if (QTUtility.IsXP && dropTargetPassthrough == null) { HookDropTarget(); } break; } return(false); }
protected override void WndProc(ref Message m) { switch (m.Msg) { case 0x0F: // WM_PAINT this.isInWmPaintMsg = true; base.WndProc(ref m); this.isInWmPaintMsg = false; break; case 0x204E: // WM_REFLECT_NOTIFY NMHDR nmhdr = (NMHDR)m.GetLParam(typeof(NMHDR)); if (nmhdr.code == -12) { // NM_CUSTOMDRAW if (this.isInWmPaintMsg) { base.WndProc(ref m); } } else { base.WndProc(ref m); } break; default: base.WndProc(ref m); break; } }
protected override void WndProc(ref Message m) { if (m.Msg == WM_LBUTTONDBLCLK) { if (SuperMouseDoubleClick != null) { SuperMouseDoubleClick(HitTest(PointToClient(MousePosition)).Node, EventArgs.Empty); return; } } // Workaround for Microsoft's NullReferenceException bug of TreeView in custom draw mode // http://www.beta.microsoft.com/VisualStudio/feedback/details/553204/treeview-nullreferenceexception-with-drawmode-ownerdraw-xxx else if (m.Msg == 0x204E && DrawMode != TreeViewDrawMode.Normal && !Created) { // WM_REFLECT + WM_NOTIFY NMHDR lParam = (NMHDR)Marshal.PtrToStructure(m.LParam, typeof(NMHDR)); // at this time, the base WndProc will call CustomDraw which would fail if (lParam.code == -12) { return; } } base.WndProc(ref m); }
protected override void WndProc(ref Microsoft.WindowsCE.Forms.Message m) { if (m.Msg == (int)WM.NOTIFY) { //marshal notification data into NMHDR struct NMHDR hdr = (NMHDR)Marshal.PtrToStructure(m.LParam, typeof(NMHDR)); if (hdr.hwndFrom == parent.Handle) { switch (hdr.code) { //definite selection case (int)DTN.DROPDOWN: //raise dropdown event parent.OnDropDown(EventArgs.Empty); break; case (int)DTN.CLOSEUP: //raise closeup event parent.OnCloseUp(EventArgs.Empty); break; } } } base.WndProc(ref m); }
protected override void WndProc(ref Message m) { base.WndProc(ref m); switch (m.Msg) { case (int)Msg.WM_PAINT: PaintBackground(); break; case (int)Msg.WM_NOTIFY: case (int)((int)Msg.WM_NOTIFY + (int)Msg.WM_REFLECT): { NMHDR note = (NMHDR)m.GetLParam(typeof(NMHDR)); switch (note.code) { case (int)RebarNotifications.RBN_HEIGHTCHANGE: UpdateSize(); break; case (int)RebarNotifications.RBN_CHEVRONPUSHED: NotifyChevronPushed(ref m); break; case (int)RebarNotifications.RBN_CHILDSIZE: NotifyChildSize(); break; case (int)NotificationMessages.NM_NCHITTEST: break; } } break; } }
protected override void WndProc(ref Message m) { switch (m.Msg) { case WM_VSCROLL: case WM_HSCROLL: case WM_SIZE: EndEditing(false, Keys.None); break; case WM_NOTIFY: NMHDR h = (NMHDR)Marshal.PtrToStructure(m.LParam, typeof(NMHDR)); switch (h.code) { case HDN_BEGINDRAG: case HDN_ITEMCHANGINGA: case HDN_ITEMCHANGINGW: EndEditing(false, Keys.None); break; } break; } base.WndProc(ref m); }
protected override void WndProc(ref Message m) { if (m.Msg == (WM_REFLECT + WM_NOTIFY)) { NMHDR hdr = (NMHDR)(Marshal.PtrToStructure(m.LParam, typeof(NMHDR))); if (hdr.code == TCN_SELCHANGING) { TabPage tp = TestTab(PointToClient(Cursor.Position)); if (tp != null) { TabPageChangeEventArgs e = new TabPageChangeEventArgs(SelectedTab, tp); if (SelectedIndexChanging != null) { SelectedIndexChanging(this, e); } if (e.Cancel || tp.Enabled == false) { m.Result = new IntPtr(1); return; } } } } base.WndProc(ref m); }
protected override void WndProc(ref Message m) { if (m.Msg == 0x204e) { NMHDR nmhdr = (NMHDR)Marshal.PtrToStructure(m.LParam, typeof(NMHDR)); if (nmhdr.code == -552) { TabPage nextTab = this.TestTab(base.PointToClient(Cursor.Position)); if (nextTab != null) { TabPageChangeEventArgs e = new TabPageChangeEventArgs(base.SelectedTab, nextTab); if (this.SelectedIndexChanging != null) { this.SelectedIndexChanging(this, e); } if (e.Cancel || !nextTab.Enabled) { m.Result = new IntPtr(1); return; } } } } base.WndProc(ref m); }
protected override void WndProc(ref Message msg) { switch (msg.Msg) { // Look for WM_VSCROLL,WM_HSCROLL or WM_SIZE messages. case WM_VSCROLL: case WM_HSCROLL: case WM_SIZE: EndEditing(false); break; case WM_NOTIFY: // Look for WM_NOTIFY of events that might also change the // editor's position/size: Column reordering or resizing NMHDR h = (NMHDR)Marshal.PtrToStructure(msg.LParam, typeof(NMHDR)); if (h.code == HDN_BEGINDRAG || h.code == HDN_ITEMCHANGINGA || h.code == HDN_ITEMCHANGINGW) { EndEditing(false); } break; } base.WndProc(ref msg); }
private bool ParentControl_MessageCaptured(ref Message msg) { if (msg.Msg == WM.NOTIFY) { NMHDR nmhdr = (NMHDR)Marshal.PtrToStructure(msg.LParam, typeof(NMHDR)); switch (nmhdr.code) { case -2: /* NM_CLICK */ if ((Control.ModifierKeys & Keys.Control) != 0) { Point pt = Control.MousePosition; PInvoke.ScreenToClient(nmhdr.hwndFrom, ref pt); HandleClick(pt); fPreventSelChange = true; PInvoke.PostMessage(nmhdr.hwndFrom, WM.USER, IntPtr.Zero, IntPtr.Zero); return(true); } break; case -450: /* TVN_SELECTIONCHANGING */ if (fPreventSelChange) { msg.Result = (IntPtr)1; return(true); } break; } } return(false); }
/// <summary> /// This member overrides <see cref="Control.WndProc"/>. /// </summary> /// <param name="m"></param> protected override void WndProc(ref Message m) { switch (m.Msg) { case Win32.NativeMethods.WM_NOTIFY: if (_isNull) { NMHDR nm = (NMHDR)m.GetLParam(typeof(NMHDR)); Console.WriteLine(nm.Code); if (nm.Code == -746 || nm.Code == -722 || nm.Code == -949) // DTN_CLOSEUP || DTN_? { SetToDateTimeValue(); OnValueChanged(EventArgs.Empty); } } break; case Win32.NativeMethods.WM_ERASEBKGND: var g = Graphics.FromHdc(m.WParam); g.FillRectangle(_backgroundBrush, ClientRectangle); g.Dispose(); return; } base.WndProc(ref m); }
protected override void WndProc(ref Message m) { if (m.Msg == ((0x0400 + 0x1c00) + 0x004E) /* OCM_NOTIFY */) { NMHDR hdr = (NMHDR)m.GetLParam(typeof(NMHDR)); if (hdr.code == (0 - 12) /* NM_CUSTOMDRAW */) { m.Result = (IntPtr)OnCustomDraw((NMLVCUSTOMDRAW)m.GetLParam(typeof(NMLVCUSTOMDRAW))); return; } } else if (m.Msg == 0x000F /* WM_PAINT */) { RECT rect = new RECT(); if (Util.GetUpdateRect(Handle, out rect, false)) { UpdateInfo(new Rectangle(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top)); } } base.WndProc(ref m); }
protected override void WndProc(ref Message m) { // For always selected // Swallow mouse messages that are not in the client area if (m.Msg >= 0x201 && m.Msg <= 0x209) { Point pos = new Point(m.LParam.ToInt32() & 0xffff, m.LParam.ToInt32() >> 16); var hit = this.HitTest(pos); switch (hit.Location) { case ListViewHitTestLocations.AboveClientArea: case ListViewHitTestLocations.BelowClientArea: case ListViewHitTestLocations.LeftOfClientArea: case ListViewHitTestLocations.RightOfClientArea: case ListViewHitTestLocations.None: return; } } // Flickering text in listview switch (m.Msg) { case 0x0F: // WM_PAINTs this.isInWmPaintMsg = true; base.WndProc(ref m); this.isInWmPaintMsg = false; // top index //if (nmhdr2.code == -181 && !this.TopItem.Equals(lastTopItem)) if (!this.TopItem.Equals(lastTopItem)) { OnTopItemChanged(EventArgs.Empty); lastTopItem = this.TopItem; } // ----------- break; case 0x204E: // WM_REFLECT_NOTIFY NMHDR nmhdr = (NMHDR)m.GetLParam(typeof(NMHDR)); if (nmhdr.code == -12) // NM_CUSTOMDRAW { if (this.isInWmPaintMsg) { base.WndProc(ref m); } } else { base.WndProc(ref m); } break; default: base.WndProc(ref m); break; } }
protected override void WndProc(ref Message message) { base.WndProc(ref message); switch (message.Msg) { case (int)Msg.WM_ERASEBKGND: IntPtr hDC = (IntPtr)message.WParam; PaintBackground(hDC); break; // Notification messages come from the header case (int)Msg.WM_NOTIFY: NMHDR nm1 = (NMHDR)message.GetLParam(typeof(NMHDR)); switch (nm1.code) { case (int)NotificationMessages.NM_CUSTOMDRAW: Debug.Write("CUSTOM DRAWING"); Debug.WriteLine(counter++); NotifyHeaderCustomDraw(ref message); break; case (int)HeaderControlNotifications.HDN_BEGINTRACKW: Tracking = true; break; case (int)HeaderControlNotifications.HDN_ENDTRACKW: Tracking = false; break; default: break; } break; // Reflected Messages come from the list itself case (int)ReflectedMessages.OCM_NOTIFY: NMHDR nm2 = (NMHDR)message.GetLParam(typeof(NMHDR)); switch (nm2.code) { case (int)NotificationMessages.NM_CUSTOMDRAW: NotifyListCustomDraw(ref message); break; case (int)ListViewNotifications.LVN_GETDISPINFOW: Debug.WriteLine("List View GetDispInfo Notifications"); break; default: break; } break; // Default default: break; } }
protected override void OnNotifyMessage(ref Microsoft.WindowsCE.Forms.Message m) { if (m.Msg == 0x004E) { NMHDR nh = (NMHDR)Marshal.PtrToStructure(m.LParam, typeof(OpenNETCF.Win32.NMHDR)); } base.OnNotifyMessage(ref m); }
/// <summary> /// Message notification for InkX /// </summary> /// <param name="m"></param> protected override void OnNotifyMessage(ref Microsoft.WindowsCE.Forms.Message m) { if (!OpenNETCF.Windows.Forms.StaticMethods.IsDesignMode(this)) { //I wonder what was intended here... NMHDR nh = (NMHDR)Marshal.PtrToStructure(m.LParam, typeof(OpenNETCF.Win32.NMHDR)); base.OnNotifyMessage(ref m); } }
protected override void WndProc(ref Message m) { switch (m.Msg) { case WM_RBUTTONUP: if (MouseUpEx != null) { Point p = new Point(m.LParam.ToInt32()); MouseUpEx(this, new MouseEventArgs(MouseButtons.Right, 1, p.X, p.Y, 0)); } base.WndProc(ref m); break; case WM_LBUTTONDBLCLK: if (DoubleClickEx != null) { Point p = new Point(m.LParam.ToInt32()); DoubleClickEx(this, new MouseEventArgs(MouseButtons.Left, 1, p.X, p.Y, 0)); } base.WndProc(ref m); break; case 0x0F: // WM_PAINT this.isInWmPaintMsg = true; base.WndProc(ref m); this.isInWmPaintMsg = false; break; case 0x204E: // WM_REFLECT_NOTIFY NMHDR nmhdr = (NMHDR)m.GetLParam(typeof(NMHDR)); if (nmhdr.code == -12) // NM_CUSTOMDRAW { if (this.isInWmPaintMsg) { base.WndProc(ref m); } } else { base.WndProc(ref m); } break; default: base.WndProc(ref m); break; } //if (m.Msg == WM_RBUTTONUP){ // if (MouseUpEx != null) { // Point p = new Point(m.LParam.ToInt32()); // MouseUpEx(this, new MouseEventArgs(MouseButtons.Right, 1, p.X, p.Y, 0)); // } //} //base.WndProc(ref m); }
protected virtual bool OnShellViewNotify(NMHDR nmhdr, ref Message msg) { if (nmhdr.hwndFrom != ListViewController.Handle) { if (nmhdr.code == -12 /*NM_CUSTOMDRAW*/ && nmhdr.idFrom == IntPtr.Zero) { ResetTrackMouseEvent(); } } return(false); }
protected override void OnNotifyMessage(Message m) { if (m.Msg == WM_NOTIFY) { NMHDR n = (NMHDR)Marshal.PtrToStructure(m.LParam, typeof(NMHDR)); if (n.code == TTN_NEEDTEXT) { NeedText(); } } }
/// <summary> /// Used to change the UDTP.Value on Closeup(Without this code Closeup only changes the base.Value) /// </summary> /// <param name="e"></param> protected override void WndProc(ref Message m) { if (m.Msg == 0x4e) { NMHDR nm = (NMHDR)m.GetLParam(typeof(NMHDR)); if (nm.Code == -746 || nm.Code == -722) { this.Value = base.Value;//propagate change form base to UTDP } } base.WndProc(ref m); }
/// <summary> /// /// </summary> /// <param name="m"></param> protected override void WndProc(ref System.Windows.Forms.Message m) { switch (m.Msg) { case WM_NOTIFY: { base.WndProc(ref m); NMHDR nm1 = ( NMHDR )m.GetLParam(typeof(NMHDR)); switch (nm1.code) { case ( int )NotificationMessages.NM_CUSTOMDRAW: { m.Result = ( IntPtr )CustomDrawReturnFlags.CDRF_DODEFAULT; NMCUSTOMDRAW nmcd = ( NMCUSTOMDRAW )m.GetLParam(typeof(NMCUSTOMDRAW)); switch (nmcd.dwDrawStage) { case ( int )CustomDrawDrawStateFlags.CDDS_PREPAINT: CddsPrePaint(ref m); break; case ( int )CustomDrawDrawStateFlags.CDDS_POSTPAINT: CddsPostPaint(ref m); break; case ( int )CustomDrawDrawStateFlags.CDDS_ITEMPREPAINT: CddsItemPrePaint(ref m); break; case ( int )CustomDrawDrawStateFlags.CDDS_ITEMPOSTPAINT: CddsItemPostPaint(ref m); break; case ( int )CustomDrawDrawStateFlags.CDDS_SUBITEMPREPAINT: CddsSubItemPrePaint(ref m); break; case ( int )CustomDrawDrawStateFlags.CDDS_SUBITEMPOSTPAINT: CddsSubItemPostPaint(ref m); break; } } break; } } break; default: base.WndProc(ref m); break; } }
private void ServerSettingForm_KeyDown(object sender, KeyEventArgs e) { if ((e.KeyCode == System.Windows.Forms.Keys.Up)) { // Up if (currentMultilineBox != null) { int index = currentMultilineBox.Text.IndexOf('\r'); if ((index != -1) && (currentMultilineBox.SelectionStart > index)) { return; } } FocusPrevControl(); e.Handled = true; } if ((e.KeyCode == System.Windows.Forms.Keys.Down)) { if (currentMultilineBox != null) { int index = currentMultilineBox.Text.LastIndexOf('\r'); if ((index != -1) && (currentMultilineBox.SelectionStart < index)) { return; } } // Down FocusNextControl(); e.Handled = true; } if ((e.KeyCode == System.Windows.Forms.Keys.Left)) { // Left } if ((e.KeyCode == System.Windows.Forms.Keys.Right)) { // Right } if ((e.KeyCode == System.Windows.Forms.Keys.Enter)) { // Enter if (sender is ComboBox) { NMHDR data = new NMHDR(); data.hwndFrom = this.Handle; data.code = DTN_DROPDOWN; data.idFrom = 0; IntPtr ptr = IntPtr.Zero; Marshal.StructureToPtr(data, ptr, false); SendMessage((sender as ComboBox).Handle, WM_NOTIFY, 0, ptr); } } }
protected override void WndProc(ref Message m) { if (m.Msg == 0x204E) { NMHDR hdr = (NMHDR)m.GetLParam(typeof(NMHDR)); if (hdr.code == NM_CUSTOMDRAW) { m.Result = (IntPtr)0; return; } } base.WndProc(ref m); }
protected override void WndProc(ref Message m) { if (((nativeUpDown != null) && (m.Msg == WM.NOTIFY)) && (ValueChanged != null)) { NMHDR nmhdr = (NMHDR)Marshal.PtrToStructure(m.LParam, typeof(NMHDR)); if ((nmhdr.code == -722) && (nmhdr.hwndFrom == nativeUpDown.Handle)) { NMUPDOWN nmupdown = (NMUPDOWN)Marshal.PtrToStructure(m.LParam, typeof(NMUPDOWN)); ValueChanged(this, new QEventArgs((nmupdown.iDelta < 0) ? ArrowDirection.Right : ArrowDirection.Left)); } } base.WndProc(ref m); }
protected override void WndProc(ref Message m) { if (m.Msg == OCM_NOTIFY) { NMHDR nm = (NMHDR)m.GetLParam(typeof(NMHDR)); if (nm.code == LVN_ITEMCHANGING) { NMLISTVIEW nmlv = (NMLISTVIEW)m.GetLParam(typeof(NMLISTVIEW)); ItemStateChanging(ref m, ref nmlv); } } base.WndProc(ref m); }
protected override void WndProc(ref Message m) { if (m.Msg == Constantes.WM_REFLECT_NOTIFY) { NMHDR hdr = (NMHDR)m.GetLParam(typeof(NMHDR)); if (hdr.code == Constantes.NM_CUSTOMDRAW) { m.Result = (IntPtr)0; return; } } base.WndProc(ref m); }
protected override void WndProc(ref Message m) { if (m.Msg == 0x204e) { NMHDR hdr = (NMHDR)m.GetLParam(typeof(NMHDR)); if (hdr.code == -759) { NMDATETIMECHANGE dt = (NMDATETIMECHANGE)m.GetLParam(typeof(NMDATETIMECHANGE)); this.Value = new DateTime(dt.st.wYear, dt.st.wMonth, 1); return; } } base.WndProc(ref m); }
/// <summary> /// This member overrides <see cref="Control.WndProc"/>. /// </summary> /// <param name="m"></param> protected override void WndProc(ref Message m) { if (_isNull) { if (m.Msg == 0x4e) // WM_NOTIFY { NMHDR nm = (NMHDR)m.GetLParam(typeof(NMHDR)); if (nm.Code == -746 || nm.Code == -722) // DTN_CLOSEUP || DTN_? { SetToDateTimeValue(); } } } base.WndProc(ref m); }
public static extern int RtlMoveMemory(ref NMHDR destination, IntPtr source, int length);
/// <summary> /// WM_NOTIFYを通知します。 /// 対象アプリケーション内部で実行する必要があります。 /// </summary> /// <param name="handle">ハンドル。</param> /// <param name="code">通知コード。</param> /// <param name="header">ヘッダ。</param> internal static void InitNotify(IntPtr handle, int code, ref NMHDR header) { header.code = code; header.hwndFrom = handle; header.idFrom = new IntPtr(NativeMethods.GetDlgCtrlID(handle)); }
internal void RefreshRebar() { try { SuspendLayout(); tabControl1.SuspendLayout(); IOleCommandTarget bandObjectSite = BandObjectSite as IOleCommandTarget; if(bandObjectSite != null) { Guid pguidCmdGroup = ExplorerGUIDs.CGID_DeskBand; bandObjectSite.Exec(ref pguidCmdGroup, 0, 0, IntPtr.Zero, IntPtr.Zero); if(!QTUtility.IsXP) { IntPtr windowLongPtr = PInvoke.GetWindowLongPtr(ReBarHandle, -8); NMHDR structure = new NMHDR(); structure.hwndFrom = ReBarHandle; structure.idFrom = (IntPtr)0xa005; structure.code = -831; IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(structure)); Marshal.StructureToPtr(structure, ptr, false); PInvoke.SendMessage(windowLongPtr, 0x4e, (IntPtr)0xa005, ptr); Marshal.FreeHGlobal(ptr); } else { RECT rect; PInvoke.GetWindowRect(ExplorerHandle, out rect); int num = (rect.Height << 0x10) | rect.Width; PInvoke.SendMessage(ExplorerHandle, 5, IntPtr.Zero, (IntPtr)num); } } } catch(COMException exception) { QTUtility2.MakeErrorLog(exception, null); } finally { tabControl1.ResumeLayout(); ResumeLayout(); } }
private extern static int RtlMoveMemory(ref NMHDR Destination, IntPtr Source, int Length);
private void ProcessCustomDraw(ref Message m, ref NMHDR nmhdr) { if (nmhdr.hwndFrom == this.LVHandle) { #region Starting User32.SendMessage(this.LVHandle, 296, User32.MAKELONG(1, 1), 0); var nmlvcd = (User32.NMLVCUSTOMDRAW)m.GetLParam(typeof(User32.NMLVCUSTOMDRAW)); var index = (Int32)nmlvcd.nmcd.dwItemSpec; var hdc = nmlvcd.nmcd.hdc; var sho = Items.Count > index ? Items[index] : null; Color? textColor = null; if (sho != null && this.LVItemsColorCodes != null && this.LVItemsColorCodes.Count > 0 && !String.IsNullOrEmpty(sho.Extension)) { var extItemsAvailable = this.LVItemsColorCodes.Where(c => c.ExtensionList.Contains(sho.Extension)).Count() > 0; if (extItemsAvailable) { var color = this.LVItemsColorCodes.SingleOrDefault(c => c.ExtensionList.ToLowerInvariant().Contains(sho.Extension)).TextColor; textColor = Color.FromArgb(color.A, color.R, color.G, color.B); } } #endregion Starting switch (nmlvcd.nmcd.dwDrawStage) { case CustomDraw.CDDS_PREPAINT: #region Case m.Result = (IntPtr)(CustomDraw.CDRF_NOTIFYITEMDRAW | CustomDraw.CDRF_NOTIFYPOSTPAINT | 0x40); break; #endregion Case case CustomDraw.CDDS_POSTPAINT: #region Case m.Result = (IntPtr)CustomDraw.CDRF_SKIPDEFAULT; break; #endregion Case case CustomDraw.CDDS_ITEMPREPAINT: #region Case if (nmlvcd.clrTextBk != 0) { if ((nmlvcd.nmcd.uItemState & CDIS.DROPHILITED) == CDIS.DROPHILITED && index != _LastDropHighLightedItemIndex) { nmlvcd.nmcd.uItemState = CDIS.DEFAULT; Marshal.StructureToPtr(nmlvcd, m.LParam, false); } if (index == _LastDropHighLightedItemIndex) { nmlvcd.nmcd.uItemState |= CDIS.DROPHILITED; Marshal.StructureToPtr(nmlvcd, m.LParam, false); } if (textColor == null) { m.Result = (IntPtr)(CustomDraw.CDRF_NOTIFYPOSTPAINT | CustomDraw.CDRF_NOTIFYSUBITEMDRAW | 0x40); } else { nmlvcd.clrText = (UInt32)ColorTranslator.ToWin32(textColor.Value); Marshal.StructureToPtr(nmlvcd, m.LParam, false); m.Result = (IntPtr)(CustomDraw.CDRF_NEWFONT | CustomDraw.CDRF_NOTIFYPOSTPAINT | CustomDraw.CDRF_NOTIFYSUBITEMDRAW); } } else { m.Result = (IntPtr)(CustomDraw.CDRF_SKIPDEFAULT); } break; #endregion Case case CustomDraw.CDDS_ITEMPREPAINT | CustomDraw.CDDS_SUBITEM: #region Case if (textColor == null) { m.Result = (IntPtr)CustomDraw.CDRF_DODEFAULT; } else { nmlvcd.clrText = (UInt32)ColorTranslator.ToWin32(textColor.Value); Marshal.StructureToPtr(nmlvcd, m.LParam, false); m.Result = (IntPtr)CustomDraw.CDRF_NEWFONT; } break; #endregion Case case CustomDraw.CDDS_ITEMPOSTPAINT: this.ProcessCustomDrawPostPaint(ref m, nmlvcd, index, hdc, sho, textColor); break; } } }
private extern static int SendMessage(IntPtr hWnd, int msg, IntPtr wParam, ref NMHDR lParam);
/// <summary> /// message pump /// </summary> /// <param name="m">message struct</param> protected override void WndProc(ref Message m) { TOOLINFO tI = new TOOLINFO(0); RECT tR = new RECT(); Size sZ = new Size(); Point pT = new Point(); DrawEventArgs dR; switch (m.Msg) { // window painting case WM_PAINT: PAINTSTRUCT tPaint = new PAINTSTRUCT(); string sT = String.Empty; string sC = String.Empty; if (_eCustomStyle != TipStyle.Default) { if (!_bPainting) { _bPainting = true; // start painting engine BeginPaint(m.HWnd, ref tPaint); dR = getEventParams(); if (Draw != null) { dR.Hdc = tPaint.hdc; Draw(this, dR); } else { drawTip(dR.Bounds, dR.Caption, dR.Title, tPaint.hdc, dR.ParentWnd); } // done EndPaint(m.HWnd, ref tPaint); _bPainting = false; } else { base.DefWndProc(ref m); } } else { // call the old proc base.WndProc(ref m); } break; case (WM_NOTIFY | WM_REFLECT): NMHDR nM = new NMHDR(0); RtlMoveMemory(ref nM, m.LParam, Marshal.SizeOf(nM)); if (nM.hwndFrom == _hTipWnd) { switch (nM.code) { //case TTN_GETDISPINFOA: <- not working //case TTN_GETDISPINFOW: // break; case TTN_SHOW: Point tp = new Point(); SendMessage(_hTipWnd, TTM_GETCURRENTTOOL, 0, ref tI); _hParentWnd = tI.hwnd; //// SIZE //// // tip size set globally if ((_oSize.Width != 0) || (_oSize.Height != 0)) { tR.Left = 0; tR.Top = 0; tR.Bottom = _oSize.Height; tR.Right = _oSize.Width; SendMessage(_hTipWnd, TTM_ADJUSTRECT, 1, ref tR); SetWindowPos(_hTipWnd, HWND_TOP, 0, 0, tR.Right, tR.Bottom, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOOWNERZORDER); m.Result = RETURN_TRUE; } else { // tip size set individually tI.uId = _hTipWnd; // get tool parent SendMessage(_hTipWnd, TTM_GETCURRENTTOOL, 0, ref tI); if (tI.hwnd != IntPtr.Zero) { // test the dictionary if (_dSize.ContainsKey(tI.hwnd)) { sZ = _dSize[tI.hwnd]; // size tip if ((sZ.Width != 0) || (sZ.Height != 0)) { tR.Left = 0; tR.Top = 0; tR.Bottom = sZ.Height; tR.Right = sZ.Width; SendMessage(_hTipWnd, TTM_ADJUSTRECT, 1, ref tR); SetWindowPos(_hTipWnd, HWND_TOP, 0, 0, tR.Right, tR.Bottom, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOOWNERZORDER); m.Result = RETURN_TRUE; } } // calculate size else if (_eCustomStyle != TipStyle.Default) { StringFormat sF = new StringFormat(); sF.Alignment = StringAlignment.Near; sF.LineAlignment = StringAlignment.Near; Rectangle rDmn = new Rectangle(4, sZ.Height, (tR.Right - tR.Left), (tR.Bottom - tR.Top)); calcTipSize(ref rDmn, tI.hwnd, _oTipFont, _dCaption[tI.hwnd], sF); sF.Dispose(); SetWindowPos(_hTipWnd, HWND_TOP, 0, 0, rDmn.Width + 8, rDmn.Height + sZ.Height + 8, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOOWNERZORDER); m.Result = RETURN_TRUE; } } } //// POSITION //// if (_ePosition != TipPosition.AutoPosition) { if (tI.hwnd != IntPtr.Zero) { GetCursorPos(ref tp); GetWindowRect(_hTipWnd, ref tR); // offset for global size if ((_oSize.Width != 0) || (_oSize.Height != 0)) { tR.Bottom = tR.Top + _oSize.Height; tR.Right = tR.Left + _oSize.Width; } // offset for tp size mod else if (_dSize.ContainsKey(tI.hwnd)) { sZ = _dSize[tI.hwnd]; tR.Bottom = tR.Top + sZ.Height; tR.Right = tR.Left + sZ.Width; } int iX = 0; int iY = 0; if ((_bShowAlways) || (_bClickable)) { iX = 12; iY = 12; } else { iX = 20; iY = 20; } switch (_ePosition) { case TipPosition.BottomCenter: tp.Y += iX; tp.X -= ((tR.Right - tR.Left) / 2); break; case TipPosition.BottomLeft: tp.Y += iX; tp.X -= ((tR.Right - tR.Left) - 4); break; case TipPosition.BottomRight: tp.Y += iX; tp.X += 12; break; case TipPosition.LeftCenter: tp.Y -= ((tR.Bottom - tR.Top) / 2); tp.X -= ((tR.Right - tR.Left) + 4); break; case TipPosition.RightCenter: tp.Y -= ((tR.Bottom - tR.Top) / 2); tp.X += 20; break; case TipPosition.TopCenter: tp.Y -= ((tR.Bottom - tR.Top) + 4); tp.X -= ((tR.Right - tR.Left) / 2); break; case TipPosition.TopLeft: tp.Y -= ((tR.Bottom - tR.Top) + 4); tp.X -= ((tR.Right - tR.Left) + 4); break; case TipPosition.TopRight: tp.Y -= ((tR.Bottom - tR.Top) + 4); break; } SetWindowPos(_hTipWnd, HWND_TOP, tp.X, tp.Y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOOWNERZORDER); } m.Result = RETURN_TRUE; } if (PopUp != null) PopUp(); tipCapture(); break; case TTN_POP: if (Pop != null) Pop(); //base.WndProc(ref m); break; //case NM_CUSTOMDRAW: //NMTTCUSTOMDRAW nC = new NMTTCUSTOMDRAW(); //<- can't get this to work.. //RtlMoveMemory(ref nC, m.LParam, Marshal.SizeOf(nC)); // break; default: base.WndProc(ref m); break; } } break; // mouse events case WM_MOUSEMOVE: if (m.HWnd == _hTipWnd) { if (MouseMove != null) { GetCursorPos(ref pT); MouseMove(pT); } if (_bClickable) m.Result = RETURN_TRUE; else base.WndProc(ref m); trackMouse(m.HWnd); } if ((!_bShowAlways) && (!_bClickable)) base.WndProc(ref m); break; case WM_MOUSELEAVE: if ((_bShowAlways) || (_bClickable)) { if (IsVisible()) { Hide(); } } base.WndProc(ref m); break; case WM_LBUTTONDOWN: if (m.HWnd == _hTipWnd) { if (LeftButtonDown != null) { dR = getEventParams(); dR.Hdc = GetDC(_hTipWnd); LeftButtonDown(this, dR); ReleaseDC(_hTipWnd, dR.Hdc); } if (_bClickable) m.Result = RETURN_TRUE; else base.WndProc(ref m); } break; case WM_LBUTTONUP: if (m.HWnd == _hTipWnd) { if (LeftButtonUp != null) { dR = getEventParams(); dR.Hdc = GetDC(_hTipWnd); LeftButtonUp(this, dR); ReleaseDC(_hTipWnd, dR.Hdc); } if (_bCloseButton) { if (closeButtonHitTest()) { Hide(); } else { base.WndProc(ref m); } } else if (_bClickable) { m.Result = RETURN_TRUE; } else { base.WndProc(ref m); } } break; case WM_LBUTTONDBLCLK: if (m.HWnd == _hTipWnd) { if (LeftButtonDblClick != null) { dR = getEventParams(); dR.Hdc = GetDC(_hTipWnd); LeftButtonDblClick(this, dR); ReleaseDC(_hTipWnd, dR.Hdc); } if (_bClickable) m.Result = RETURN_TRUE; else base.WndProc(ref m); } break; case WM_MBUTTONDOWN: if (m.HWnd == _hTipWnd) { if (MiddleButtonDown != null) { dR = getEventParams(); dR.Hdc = GetDC(_hTipWnd); MiddleButtonDown(this, dR); ReleaseDC(_hTipWnd, dR.Hdc); } if (_bClickable) m.Result = RETURN_TRUE; else base.WndProc(ref m); } break; case WM_MBUTTONUP: if (m.HWnd == _hTipWnd) { if (MiddleButtonUp != null) { dR = getEventParams(); dR.Hdc = GetDC(_hTipWnd); MiddleButtonUp(this, dR); ReleaseDC(_hTipWnd, dR.Hdc); } if (_bClickable) m.Result = RETURN_TRUE; else base.WndProc(ref m); } break; case WM_MBUTTONDBLCLK: if (m.HWnd == _hTipWnd) { if (MiddleButtonDblClick != null) { dR = getEventParams(); dR.Hdc = GetDC(_hTipWnd); MiddleButtonDblClick(this, dR); ReleaseDC(_hTipWnd, dR.Hdc); } if (_bClickable) m.Result = RETURN_TRUE; else base.WndProc(ref m); } break; case WM_RBUTTONDOWN: if (m.HWnd == _hTipWnd) { if (RightButtonDown != null) { dR = getEventParams(); dR.Hdc = GetDC(_hTipWnd); RightButtonDown(this, dR); ReleaseDC(_hTipWnd, dR.Hdc); } if (_bClickable) m.Result = RETURN_TRUE; else base.WndProc(ref m); } break; case WM_RBUTTONUP: if (m.HWnd == _hTipWnd) { if (RightButtonUp != null) { dR = getEventParams(); dR.Hdc = GetDC(_hTipWnd); RightButtonDown(this, dR); ReleaseDC(_hTipWnd, dR.Hdc); } if (_bClickable) m.Result = RETURN_TRUE; else base.WndProc(ref m); } break; case WM_RBUTTONDBLCLK: if (m.HWnd == _hTipWnd) { if (RightButtonUp != null) { dR = getEventParams(); dR.Hdc = GetDC(_hTipWnd); RightButtonDblClick(this, dR); ReleaseDC(_hTipWnd, dR.Hdc); } if (_bClickable) m.Result = RETURN_TRUE; else base.WndProc(ref m); } break; case WM_MOUSEWHEEL: if (m.HWnd == _hTipWnd) { if (MouseWheel != null) { MouseWheel(); } } break; case WM_TIMER: switch (m.WParam.ToInt32()) { case HOVER_SIGNALED: if (IsVisible()) { if ((_bShowAlways) || (_bClickable)) { GetWindowRect(_hTipWnd, ref tR); GetCursorPos(ref pT); if (PtInRect(ref tR, pT)) m.Result = RETURN_TRUE; else base.WndProc(ref m); } else { base.WndProc(ref m); } } else { base.WndProc(ref m); } break; case FADER_SIGNALED: //<-vista only if (IsVisible()) { if ((_bShowAlways) || (_bClickable)) { GetWindowRect(_hTipWnd, ref tR); GetCursorPos(ref pT); if (PtInRect(ref tR, pT)) m.Result = RETURN_TRUE; else base.WndProc(ref m); } else if (_eCustomStyle != TipStyle.Default) { if (!_bTimerActive) { startFadeTimer(); m.Result = RETURN_TRUE; } else { m.Result = RETURN_TRUE; } } else { base.WndProc(ref m); } } break; case TIMER_FADE: _iSafeTimer += 1; if (_iSafeTimer > (_iFadeDelay / 50)) stopFadeTimer(); else tipFade(); break; default: base.WndProc(ref m); break; } break; case WM_SETFOCUS: if (!_bCanFocus) { if (_hParentWnd != IntPtr.Zero) SetFocus(_hParentWnd); if (_bClickable) { if (closeButtonHitTest()) SendMessage(_hTipWnd, WM_LBUTTONUP, 0, 0); } } else { base.WndProc(ref m); } break; case WM_STYLECHANGED: if (_eCustomStyle == TipStyle.Default) SendMessage(_hTipWnd, TTM_SETTIPBKCOLOR, ColorTranslator.ToWin32(Color.LightYellow), 0); //<-added for xp base.WndProc(ref m); break; /*case WM_NCPAINT: break; case WM_DESTROY: break; case WM_ACTIVATEAPP: break; case WM_ACTIVATE: break; case WM_KILLFOCUS: break; case WM_IME_NOTIFY: break; case WM_IME_SETCONTEXT: break; case WM_NCACTIVATE: break; case WM_STYLECHANGING: break; case WM_WINDOWPOSCHANGING: break; case WM_WINDOWPOSCHANGED: break; case WM_NCCALCSIZE: break; // undocumented? case 0x410: // effects show/timer break; case 0x418: // format break; case 0x421: // title break; case 0x407: //show/timer break;*/ default: //Debug.Print(m.Msg.ToString()); base.WndProc(ref m); break; } }
internal NMTTDISPINFO(int flags) { this.hdr = new NMHDR(0); this.lpszText = IntPtr.Zero; this.szText = IntPtr.Zero; this.hinst = IntPtr.Zero; this.uFlags = 0; this.lParam = IntPtr.Zero; }
internal static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, ref NMHDR lParam);
public static extern int SendMessage(IntPtr hWnd, int msg, IntPtr wParam, ref NMHDR lParam);
internal void RefreshHeight() { const int DBID_BANDINFOCHANGED = 0; const int OLECMDEXECOPT_DODEFAULT = 0; const int RBN_HEIGHTCHANGE = -831; const int GWL_HWNDPARENT = -8; try { tabbar.SuspendLayout(); if(bandObjectSite != null) { Guid pguidCmdGroup = ExplorerGUIDs.CGID_DeskBand; bandObjectSite.Exec(ref pguidCmdGroup, DBID_BANDINFOCHANGED, OLECMDEXECOPT_DODEFAULT, IntPtr.Zero, IntPtr.Zero); if(QTUtility.IsXP) { RECT rect; PInvoke.GetWindowRect(ExplorerHandle, out rect); int num = (rect.Height << 0x10) | rect.Width; PInvoke.SendMessage(ExplorerHandle, 5, IntPtr.Zero, (IntPtr)num); } else { IntPtr windowLongPtr = PInvoke.GetWindowLongPtr(Handle, GWL_HWNDPARENT); NMHDR structure = new NMHDR { hwndFrom = Handle, idFrom = (IntPtr)40965, // magic id code = RBN_HEIGHTCHANGE }; PInvoke.SendMessage(windowLongPtr, WM.NOTIFY, structure.idFrom, ref structure); } } } catch(COMException exception) { QTUtility2.MakeErrorLog(exception); } finally { tabbar.ResumeLayout(); } }