protected override void WndProc(ref Message m) { base.WndProc(ref m); if ((m.Msg == (WM_REFLECT | WM_NOTIFY)) || m.Msg == WM_NOTIFY) { STRUCT_NMHDR hdr = (STRUCT_NMHDR)(Marshal.PtrToStructure(m.LParam, typeof(STRUCT_NMHDR))); if (hdr.code == EN_OBJECTPOSITIONS) { m.Result = (IntPtr)(-1); } if (hdr.code == EN_REQUESTRESIZE) { STRUCT_REQRESIZE rrs = (STRUCT_REQRESIZE)(Marshal.PtrToStructure(m.LParam, typeof(STRUCT_REQRESIZE))); Control from = Control.FromHandle(rrs.nmhdr.hwndFrom); if (from == null) { return; } if (!(from is RichTextBox2)) { return; } RichTextBox2 rtb2 = (RichTextBox2)from; rtb2.native_rect = new Size(rrs.rc.right - rrs.rc.left, rrs.rc.bottom - rrs.rc.top); } } }
public Size GetCleverSize() { if (native == null) { throw new Exception("Not clever enough!"); } native_rect = Size.Empty; SendMessage(this.Handle, EM_REQUESTRESIZE, (IntPtr)0, (IntPtr)0); STRUCT_NMHDR foo = new STRUCT_NMHDR(); foo.code = EN_OBJECTPOSITIONS; IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(foo)); Marshal.StructureToPtr(foo, ptr, false); SendMessage(native.Handle, WM_NOTIFY, (IntPtr)0, ptr); if (native_rect == Size.Empty) { throw new Exception("Cleverness failed"); } return(native_rect); }
public Size GetCleverSize() { if (native == null) throw new Exception("Not clever enough!"); native_rect = Size.Empty; SendMessage(this.Handle, EM_REQUESTRESIZE, (IntPtr)0, (IntPtr)0); STRUCT_NMHDR foo=new STRUCT_NMHDR(); foo.code = EN_OBJECTPOSITIONS; IntPtr ptr=Marshal.AllocHGlobal(Marshal.SizeOf(foo)); Marshal.StructureToPtr(foo, ptr, false); SendMessage(native.Handle,WM_NOTIFY,(IntPtr)0,ptr); if (native_rect == Size.Empty) throw new Exception("Cleverness failed"); return native_rect; }