可以拦截CBN_EDITCHANGE消息,拦截到以后先进行你的处理,在交还给系统处理

解决方案 »

  1.   

    dancemaple(枫之舞) 所说的有误CBN_EDITCHANGE其实就是onChange,是在改变之后才触发的如果只是为了得到OnChange以前的text,有一个办法
    声明一个变量,记录Combobox的值,每次在Onchange的最后修改它的值,
    那么,你每次处理onchange里得到的值就是前一个了,使用完以后再给它赋新值,明白否?
      

  2.   

    你的意思我的明白,可以行的通,我是想做一个Tcontrol,你能帮我吗?
      

  3.   

    sorry,我的确说错了,多谢qiubolecn(来自差生市)
      

  4.   

    有一个麻烦的办法,但估计可行;
    办法是,重载任何有可能调用 Change或changed的方法
    比如keypress在这些方法前调用OnBeforeChange,当然onbeforechange是TNotifyEvent;
      

  5.   

    qiubolecn(来自差生市) :
    你以前见过类似的东东吗?
      

  6.   

    privete
        FOnChange: TNotifyEvent;
        Procedure: OnChange(var message: TWMOnChange) message :WM_OnChange;
     protected
        Procedure OnChange: dynamic;   
     published
       property      OnChange: TNotifyEvent read FOnchange write FonChange
      

  7.   

    unit ComboBoxEx;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls;type
      TCustomComboBoxEx = class(TComboBox)
      private
        { Private declarations }
        FOnBeforeChange: TNotifyEvent;
      protected
        { Protected declarations }
        procedure KeyPress(var Key: Char); override;
        procedure ProcessBeforeChange;
      public
        { Public declarations }
      published
        { Published declarations }
        property OnChange;
        property OnClick;
        property OnContextPopup;
        property OnDblClick;
        property OnDragDrop;
        property OnDragOver;
        property OnDrawItem;
        property OnDropDown;
        property OnEndDock;
        property OnEndDrag;
        property OnEnter;
        property OnExit;
        property OnKeyDown;
        property OnKeyUp;
        property OnMeasureItem;
        property OnStartDock;
        property OnStartDrag;
        property OnBeforeChange: TNotifyEvent read FOnBeforeChange write FOnBeforeChange;
      end;procedure Register;implementationprocedure Register;
    begin
      RegisterComponents('MyComponents', [TCustomComboBoxEx]);
    end;procedure TCustomComboBoxEx.KeyPress(var Key: Char);
    begin
      ProcessBeforeChange;
      inherited;
    end;procedure TCustomComboBoxEx.ProcessBeforeChange;
    begin
      if Assigned(FOnBeforeChange) then
        FOnBeforeChange(Self);
    end;end.