| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- /*******************************************************************************
- * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:NativeMethods.cs
- * 2.功能描述:
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 陈晓野 2014/09/04 1.00 新建
- *******************************************************************************/
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- using System.Security.Permissions;
- namespace Dongke.IBOSS.PRD.Basics.BaseControls
- {
- /// <summary>
- /// CodeProject.com "Simple pop-up control" "http://www.codeproject.com/cs/miscctrl/simplepopup.asp".
- /// Represents a Windows combo box control with a custom popup control attached.
- /// </summary>
- [ToolboxBitmap(typeof(System.Windows.Forms.ComboBox)), ToolboxItem(true), ToolboxItemFilter("System.Windows.Forms"), Description("Displays an editable text box with a drop-down list of permitted values.")]
- public abstract partial class PopupComboBox : DKComboBox
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="PopupControl.PopupComboBox" /> class.
- /// </summary>
- public PopupComboBox()
- {
- InitializeComponent();
- base.DropDownHeight = base.DropDownWidth = 1;
- base.IntegralHeight = false;
- }
- /// <summary>
- /// The pop-up wrapper for the dropDownControl.
- /// Made PROTECTED instead of PRIVATE so descendent classes can set its Resizable property.
- /// Note however the pop-up properties must be set after the dropDownControl is assigned, since this
- /// popup wrapper is recreated when the dropDownControl is assigned.
- /// </summary>
- protected Popup dropDown;
- private Control dropDownControl;
- /// <summary>
- /// Gets or sets the drop down control.
- /// </summary>
- /// <value>The drop down control.</value>
- public Control DropDownControl
- {
- get
- {
- return dropDownControl;
- }
- set
- {
- if (dropDownControl == value)
- return;
- dropDownControl = value;
- dropDown = new Popup(value);
- }
- }
- /// <summary>
- /// Shows the drop down.
- /// </summary>
- public virtual void ShowDropDown()
- {
- if (dropDown != null)
- {
- dropDown.Show(this);
- }
- }
- /// <summary>
- /// Hides the drop down.
- /// </summary>
- public virtual void HideDropDown()
- {
- if (dropDown != null)
- {
- dropDown.Hide();
- }
- }
- /// <summary>
- /// Processes Windows messages.
- /// </summary>
- /// <param name="m">The Windows <see cref="T:System.Windows.Forms.Message" /> to process.</param>
- [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)]
- protected override void WndProc(ref Message m)
- {
- if (m.Msg == (NativeMethods.WM_REFLECT + NativeMethods.WM_COMMAND))
- {
- if (NativeMethods.HIWORD(m.WParam) == NativeMethods.CBN_DROPDOWN)
- {
- // Blocks a redisplay when the user closes the control by clicking
- // on the combobox.
- TimeSpan TimeSpan = DateTime.Now.Subtract(dropDown.LastClosedTimeStamp);
- if (TimeSpan.TotalMilliseconds > 500)
- ShowDropDown();
- return;
- }
- }
- base.WndProc(ref m);
- }
- #region " Unused Properties "
- /// <summary>This property is not relevant for this class.</summary>
- /// <returns>This property is not relevant for this class.</returns>
- [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), EditorBrowsable(EditorBrowsableState.Never)]
- public new int DropDownWidth
- {
- get { return base.DropDownWidth; }
- set { base.DropDownWidth = value; }
- }
- /// <summary>This property is not relevant for this class.</summary>
- /// <returns>This property is not relevant for this class.</returns>
- [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), EditorBrowsable(EditorBrowsableState.Never)]
- public new int DropDownHeight
- {
- get { return base.DropDownHeight; }
- set
- {
- dropDown.Height = value;
- base.DropDownHeight = value;
- }
- }
- /// <summary>This property is not relevant for this class.</summary>
- /// <returns>This property is not relevant for this class.</returns>
- [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), EditorBrowsable(EditorBrowsableState.Never)]
- public new bool IntegralHeight
- {
- get { return base.IntegralHeight; }
- set { base.IntegralHeight = value; }
- }
- /// <summary>This property is not relevant for this class.</summary>
- /// <returns>This property is not relevant for this class.</returns>
- [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), EditorBrowsable(EditorBrowsableState.Never)]
- public new ObjectCollection Items
- {
- get { return base.Items; }
- }
- /// <summary>This property is not relevant for this class.</summary>
- /// <returns>This property is not relevant for this class.</returns>
- [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), EditorBrowsable(EditorBrowsableState.Never)]
- public new int ItemHeight
- {
- get { return base.ItemHeight; }
- set { base.ItemHeight = value; }
- }
- #endregion
- }
- }
|