// Helper method which will invoke the MouseOverItem event. private void HandleMouseOverItem() { // cbSize must be set before calling GetComboBoxInfo. COMBOBOXINFO pcbi = new COMBOBOXINFO(); pcbi.cbSize = Marshal.SizeOf(pcbi); // Get combo box information. GetComboBoxInfo(Handle, ref pcbi); // Check for invalid pointer... just in case. if (pcbi.hwndList == IntPtr.Zero) { return; } // Current position of cursor. POINT pt = Cursor.Position; /* LBItemFromPt will return the Index of the Item on success. ** The documentation states that this function will return zero ** if it fails. That is not true though. It will return 0 for the ** first item in the list box. This function returns -1 on error! */ int retVal = LBItemFromPt(pcbi.hwndList, pt, false); if (retVal == -1) { return; } // Invoke the event. MouseOverItem?.Invoke(this, new MouseOverEventArgs(retVal)); }
public ClientInfoForm() { InitializeComponent(); CboClientName.HandleCreated += (s, e) => { COMBOBOXINFO combo = new COMBOBOXINFO(); combo.cbSize = Marshal.SizeOf(combo); GetComboBoxInfo(CboClientName.Handle, out combo); hwnd1 = combo.hwndList; init1 = false; }; CboFarmName.HandleCreated += (s, e) => { COMBOBOXINFO combo = new COMBOBOXINFO(); combo.cbSize = Marshal.SizeOf(combo); GetComboBoxInfo(CboFarmName.Handle, out combo); hwnd2 = combo.hwndList; init2 = false; }; CboFruitName.HandleCreated += (s, e) => { COMBOBOXINFO combo = new COMBOBOXINFO(); combo.cbSize = Marshal.SizeOf(combo); GetComboBoxInfo(CboFruitName.Handle, out combo); hwnd3 = combo.hwndList; init3 = false; }; }
public static void Register(ComboBox combo) { Data data = new Data() { combo = combo }; Action assign = () => { COMBOBOXINFO info = new COMBOBOXINFO(); info.cbSize = Marshal.SizeOf(info); SendMessageCb(combo.Handle, 0x164, IntPtr.Zero, out info); dict[combo] = data; data.nwList = new NW(info.hwndList); }; if (!combo.IsHandleCreated) { combo.HandleCreated += delegate { assign(); } } ; else { assign(); } combo.HandleDestroyed += delegate { data.Dispose(); }; }
private static COMBOBOXINFO GetComboBoxInfo(Control control) { COMBOBOXINFO info = new COMBOBOXINFO(); info.cbSize = Marshal.SizeOf(info); GetComboBoxInfo(control.Handle, ref info); return(info); }
/// <summary> /// Gets the list control of a combo box /// </summary> /// <param name="handle">Handle of the combo box itself</param> /// <returns>A handle to the list</returns> public static IntPtr GetListHandle(IntPtr handle) { COMBOBOXINFO info; info = new COMBOBOXINFO(); info.cbSize = Marshal.SizeOf(info); return(GetComboBoxInfo(handle, ref info) ? info.hwndList : IntPtr.Zero); }
public TextWindow(ComboBox cb) { COMBOBOXINFO info = new COMBOBOXINFO(); info.cbSize = Marshal.SizeOf(info); SendMessageCb(cb.Handle, 0x164, IntPtr.Zero, out info); this.AssignHandle(info.hwndEdit); }
/// <summary> /// Retrieves ComboBox Handle /// </summary> /// <param name="CASCombo"></param> /// <returns></returns> public IntPtr CASGetHandle(ComboBox CASCombo) { COMBOBOXINFO CASCBI = new COMBOBOXINFO(); //New ComboBox Settings Object CASCBI.cbSize = System.Runtime.InteropServices.Marshal.SizeOf(CASCBI); //Call In Correct Size GetComboBoxInfo(CASCombo.Handle, ref CASCBI); //Obtain Handle return(CASCBI.hwndList); //Return Handle }
public static void SetWatermark(ComboBox comboBox, string watermarkText) { //a combobox is made up of three controls, a button, a list and textbox; //we want the textbox COMBOBOXINFO info = new COMBOBOXINFO(); info.cbSize = Marshal.SizeOf(info); GetComboBoxInfo(comboBox.Handle, ref info); SendMessage(info.hwndItem, EM_SETCUEBANNER, 0, watermarkText); }
public static COMBOBOXINFO FromComboBox(System.Windows.Forms.ComboBox cb) { if (!cb.IsHandleCreated) throw new ArgumentException("ComboBox must have its handle created.", "cb"); var cbi = new COMBOBOXINFO() { cbSize = Marshal.SizeOf(typeof(COMBOBOXINFO)) }; GetComboBoxInfo(cb.Handle, ref cbi); return cbi; }
private static COMBOBOXINFO GetComboBoxInfo(Control control) { COMBOBOXINFO info = new COMBOBOXINFO(); //a combobox is made up of three controls, a button, a list and textbox; //we want the textbox info.cbSize = Marshal.SizeOf(info); GetComboBoxInfo(control.Handle, ref info); return info; }
protected override void OnCreateControl() { base.OnCreateControl(); COMBOBOXINFO info = new COMBOBOXINFO(); info.cbSize = Marshal.SizeOf(info); GetComboBoxInfo(Handle, ref info); _ehandle = info.hwndEdit; _lhandle = info.hwndList; }
protected override void OnHandleCreated(EventArgs e) { base.OnHandleCreated(e); var x = new COMBOBOXINFO(); x.cbSize = (uint)Marshal.SizeOf(typeof(COMBOBOXINFO)); var b = User32.GetComboBoxInfo(Handle, ref x); _listBoxDefaultWndProc = NativeUtility.SetWindowProc(x.hwndList, _listBoxWndProc); }
public static void SetWatermark(ComboBox comboBox, string watermarkText) { //a combobox is made up of three controls, a button, a list and textbox; //we want the textbox COMBOBOXINFO info = new COMBOBOXINFO(); info.cbSize = Marshal.SizeOf(info); GetComboBoxInfo(comboBox.Handle, ref info); SendMessage(info.hwndItem, EM_SETCUEBANNER, 0, watermarkText); }
public Form1() { InitializeComponent(); HandleCreated += (s, e) => { COMBOBOXINFO combo = new COMBOBOXINFO(); combo.cbSize = Marshal.SizeOf(combo); GetComboBoxInfo(comboBox1.Handle, out combo); hwnd = combo.hwndList; }; }
private static COMBOBOXINFO GetComboBoxInfo(Control control) { COMBOBOXINFO info = new COMBOBOXINFO(); //a combobox is made up of three controls, a button, a list and textbox; //we want the textbox info.cbSize = Marshal.SizeOf(info); GetComboBoxInfo(control.Handle, ref info); return(info); }
private void SetupEdit() { var info = new COMBOBOXINFO(); info.cbSize = Marshal.SizeOf(info); GetComboBoxInfo(this.Handle, ref info); var style = GetWindowLong(info.hwndEdit, GWL_STYLE); style |= 1; SetWindowLong(info.hwndEdit, GWL_STYLE, style); }
protected override void OnDropDown(EventArgs e) { // Install wrapper base.OnDropDown(e); // Retrieve handle to dropdown list COMBOBOXINFO info = new COMBOBOXINFO(); info.cbSize = Marshal.SizeOf(info); SendMessageCb(this.Handle, 0x164, IntPtr.Zero, out info); mDropdown = new DropdownWindow(this); mDropdown.AssignHandle(info.hwndList); }
protected override void OnDropDown(EventArgs e) { // Install wrapper base.OnDropDown(e); // Retrieve handle to dropdown list COMBOBOXINFO info = new COMBOBOXINFO(); info.cbSize = Marshal.SizeOf(info); SendMessageCb(this.Handle, 0x164, IntPtr.Zero, out info); mDropdown = new DropdownWindow(this); mDropdown.AssignHandle(info.hwndList); }
public static void SetCueText(Control control, string text) { if (control is ComboBox) { COMBOBOXINFO info = GetComboBoxInfo(control); SendMessage(info.hwndItem, EM_SETCUEBANNER, 0, text); } else { SendMessage(control.Handle, EM_SETCUEBANNER, 0, text); } }
/// <summary> /// 设置控件的暗示信息。 /// </summary> /// <param name="owner">控件拥有者。</param> /// <param name="text">暗示信息。</param> public static void SetCueText(this Control owner, string text) { if (owner is ComboBox) { COMBOBOXINFO info = GetComboBoxInfo(owner); SendMessage(info.hwndItem, EM_SETCUEBANNER, 0, text); } else { SendMessage(owner.Handle, EM_SETCUEBANNER, 0, text); } }
private void SetupEdit() { var info = new COMBOBOXINFO(); info.cbSize = Marshal.SizeOf(info); GetComboBoxInfo(this.Handle, ref info); SetWindowPos(info.hwndEdit, IntPtr.Zero, 3, (this.Height - Font.Height) / 2, ClientRectangle.Width - buttonWidth - 3, ClientRectangle.Height - Font.Height - 4, SWP_NOZORDER); }
/// <summary> /// /// </summary> public ComboBoxPlus() { this.DrawMode = DrawMode.OwnerDrawFixed; this.AddItemString = "添加新项"; this.Items.Add(AddItemString); this.HandleCreated += (s, e) => { COMBOBOXINFO combo = new COMBOBOXINFO(); combo.cbSize = Marshal.SizeOf(combo); GetComboBoxInfo(this.Handle, out combo); hwnd = combo.hwndList; init = false; }; }
public static COMBOBOXINFO FromComboBox(System.Windows.Forms.ComboBox cb) { if (!cb.IsHandleCreated) { throw new ArgumentException("ComboBox must have its handle created.", "cb"); } var cbi = new COMBOBOXINFO() { cbSize = Marshal.SizeOf(typeof(COMBOBOXINFO)) }; GetComboBoxInfo(cb.Handle, ref cbi); return(cbi); }
public static COMBOBOXINFO FromHandle(HandleRef hComboBox) { if (hComboBox.Handle == IntPtr.Zero) { throw new ArgumentException("ComboBox handle cannot be NULL.", nameof(hComboBox)); } var cbi = new COMBOBOXINFO() { cbSize = Marshal.SizeOf(typeof(COMBOBOXINFO)) }; SendMessage(hComboBox, ComboBoxMessage.CB_GETCOMBOBOXINFO, 0, ref cbi); return(cbi); }
private static string GetCueText(Control control) { var builder = new StringBuilder(); if (control is ComboBox) { var info = new COMBOBOXINFO(); info.cbSize = Marshal.SizeOf(info); GetComboBoxInfo(control.Handle, ref info); SendMessage(info.hwndItem, EM_GETCUEBANNER, 0, builder); } else { SendMessage(control.Handle, EM_GETCUEBANNER, 0, builder); } return(builder.ToString()); }
private void UpdateHint() { if (!this.IsHandleCreated) { return; } if (DropDownStyle == ComboBoxStyle.DropDownList) { this.Invalidate(); } else { var info = new COMBOBOXINFO(); info.cbSize = Marshal.SizeOf(info); GetComboBoxInfo(Handle, ref info); SendMessage(Handle, CB_SETCUEBANNER, 0, Hint); } }
public static string GetCueText(Control control) { StringBuilder builder = new StringBuilder(); if (control is ComboBox) { COMBOBOXINFO info = new COMBOBOXINFO(); //a combobox is made up of two controls, a list and textbox; //we want the textbox info.cbSize = Marshal.SizeOf(info); GetComboBoxInfo(control.Handle, ref info); SendMessage(info.hwndItem, EM_GETCUEBANNER, 0, builder); } else { SendMessage(control.Handle, EM_GETCUEBANNER, 0, builder); } return builder.ToString(); }
public static void Placeholder(Control control, string placeholder) { try { if (control is ComboBox) { COMBOBOXINFO info = GetComboBoxInfo(control); SendMessage(info.hwndItem, EM_SETCUEBANNER, 0, placeholder); } else { SendMessage(control.Handle, EM_SETCUEBANNER, 0, placeholder); } } catch (Exception) { } }
public static void Go(String s) { FoundComboHwnd = (IntPtr)0; FoundButtonHwnd = (IntPtr)0; EnumChildWindows(MonitorThread.HandledHwnd, EnumChildWindowsCallback, (IntPtr)0); COMBOBOXINFO info; info = new COMBOBOXINFO(); info.cbSize = Marshal.SizeOf(info); GetComboBoxInfo(FoundComboHwnd, ref info); String x = WindowMessageClass.GetControlText(info.hwndEdit); x = Path.GetFileNameWithoutExtension(x) + s + Path.GetExtension(x); WindowMessageClass.SetControlText(info.hwndEdit, x); WindowMessageClass.ClickControl(FoundButtonHwnd); }
public static string GetCueText(Control control) { var result = String.Empty; if (control is ComboBox) { COMBOBOXINFO info = new COMBOBOXINFO(); //a combobox is made up of two controls, a list and textbox; //we want the textbox info.cbSize = Marshal.SizeOf(info); GetComboBoxInfo(control.Handle, ref info); SendMessage(info.hwndItem, EM_GETCUEBANNER, IntPtr.Zero, result); } else { SendMessage(control.Handle, EM_GETCUEBANNER, IntPtr.Zero, result); } return(result); }
public static string GetCueText(Control control) { StringBuilder builder = new StringBuilder(); if (control is ComboBox) { COMBOBOXINFO info = new COMBOBOXINFO(); //a combobox is made up of two controls, a list and textbox; //we want the textbox info.cbSize = Marshal.SizeOf(info); GetComboBoxInfo(control.Handle, ref info); SendMessage(info.hwndItem, EM_GETCUEBANNER, 0, builder); } else { SendMessage(control.Handle, EM_GETCUEBANNER, 0, builder); } return(builder.ToString()); }
protected override void OnDropDown(EventArgs e) { // Is dropdown off the right side of the screen? Point pos = this.PointToScreen(this.Location); Screen scr = Screen.FromPoint(pos); if (scr.WorkingArea.Right < pos.X + this.DropDownWidth) { this.BeginInvoke(new Action(() => { // Retrieve handle to dropdown list COMBOBOXINFO info = new COMBOBOXINFO(); info.cbSize = Marshal.SizeOf(info); SendMessageCb(this.Handle, 0x164, IntPtr.Zero, out info); // Move the dropdown window RECT rc; GetWindowRect(info.hwndList, out rc); int x = scr.WorkingArea.Right - (rc.Right - rc.Left); SetWindowPos(info.hwndList, IntPtr.Zero, x, rc.Top, 0, 0, 5); })); } base.OnDropDown(e); }
private static extern bool GetComboBoxInfo(IntPtr hwnd, ref COMBOBOXINFO pcbi);
public static extern bool GetComboBoxInfo(IntPtr hWnd, ref COMBOBOXINFO pcbi);
public static extern int GetComboBoxInfo(IntPtr hWnd, ref COMBOBOXINFO pcbi); //Retrieve Info About Specified Combo Box
private static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, ref COMBOBOXINFO lParam);
private RECT comboButton() { int width = _oComboboxBitmap.Width / 4; COMBOBOXINFO cbi = new COMBOBOXINFO(); RECT tr = new RECT(); // get button size cbi.cbSize = Marshal.SizeOf(cbi); if (SendMessage(_hComboWnd, CB_GETCOMBOBOXINFO, 0, ref cbi) != 0) { tr = cbi.rcButton; } else { ComboBox cb = (ComboBox)Control.FromHandle(_hComboWnd); tr = new RECT(cb.ClientRectangle.Width - width, 1, width, cb.ClientRectangle.Height - 2); } return tr; }
private static extern bool GetComboBoxInfo(IntPtr hwnd, ref COMBOBOXINFO pcbi);
public static extern bool GetComboBoxInfo( IntPtr hwndCombo, ref COMBOBOXINFO info);
private static extern IntPtr SendMessageCb(IntPtr hWnd, int msg, IntPtr wp, out COMBOBOXINFO lp);
/// <summary> /// Gets the list control of a combo box /// </summary> /// <param name="handle">Handle of the combo box itself</param> /// <returns>A handle to the list</returns> public static IntPtr GetListHandle(IntPtr handle) { COMBOBOXINFO info; info = new COMBOBOXINFO(); info.cbSize = Marshal.SizeOf(info); return GetComboBoxInfo(handle, ref info) ? info.hwndList : IntPtr.Zero; }
private bool InitializeHandle(Control ctrl) { IntPtr oldTargetHandle = _targetHandle; if (ctrl is ComboBox) { _referenceControl = ctrl; COMBOBOXINFO cbInfo = new COMBOBOXINFO(); cbInfo.cbSize = Marshal.SizeOf(cbInfo); GetComboBoxInfo(((Control)ctrl).Handle, ref cbInfo); _targetHandle = cbInfo.hwndList; } else { _referenceControl = ctrl; _targetHandle = ctrl.Handle; } if ((_targetHandle != oldTargetHandle) && (_targetHandle != IntPtr.Zero)) { if (_oldWndProcPointer == IntPtr.Zero) _oldWndProcPointer = (IntPtr)GetWindowLong(_targetHandle, GWL_WNDPROC); else { if (oldTargetHandle != IntPtr.Zero) SetWindowLong(_targetHandle, GWL_WNDPROC, _oldWndProcPointer); } if (_newWndProcPointer == IntPtr.Zero) { _newWndProc = new WndProcDelegate(WndProc); _newWndProcPointer = Marshal.GetFunctionPointerForDelegate(_newWndProc); } SetWindowLong(_targetHandle, GWL_WNDPROC, _newWndProcPointer); return true; } else return false; }
internal static extern bool GetComboBoxInfo(IntPtr hWnd, ref COMBOBOXINFO pcbi);