添加一个事件:OnBeforeChange 可以拦截CBN_EDITCHANGE消息,拦截到以后先进行你的处理,在交还给系统处理 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 dancemaple(枫之舞) 所说的有误CBN_EDITCHANGE其实就是onChange,是在改变之后才触发的如果只是为了得到OnChange以前的text,有一个办法声明一个变量,记录Combobox的值,每次在Onchange的最后修改它的值,那么,你每次处理onchange里得到的值就是前一个了,使用完以后再给它赋新值,明白否? 你的意思我的明白,可以行的通,我是想做一个Tcontrol,你能帮我吗? sorry,我的确说错了,多谢qiubolecn(来自差生市) 有一个麻烦的办法,但估计可行;办法是,重载任何有可能调用 Change或changed的方法比如keypress在这些方法前调用OnBeforeChange,当然onbeforechange是TNotifyEvent; qiubolecn(来自差生市) :你以前见过类似的东东吗? privete FOnChange: TNotifyEvent; Procedure: OnChange(var message: TWMOnChange) message :WM_OnChange; protected Procedure OnChange: dynamic; published property OnChange: TNotifyEvent read FOnchange write FonChange 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. 列出局域网所有计算机资源(包括机器名、共享文件夹) 请大家帮忙转化一个程序C TO DELPHI 六位数的QQ不要钱,点击马上申请! 两台远程服务器数据操作问题?在线等 急!!! 如何删除指定数量得计录 用SQL语言 VarArrayCreate语句编译无法通过的问题,急! DELPHI新手一个关于BDE Administrator的小问题,在线等待! 请问各位大虾,BDE怎么调用ACCESE建的库 线上等 mscomm问题,紧急! 通过什么方法将数据集的记录的图片与记录同步显示出来? 新来,问一个csdn的使用问题 求教Delephi有没有debug编译和release编译啊?
声明一个变量,记录Combobox的值,每次在Onchange的最后修改它的值,
那么,你每次处理onchange里得到的值就是前一个了,使用完以后再给它赋新值,明白否?
办法是,重载任何有可能调用 Change或changed的方法
比如keypress在这些方法前调用OnBeforeChange,当然onbeforechange是TNotifyEvent;
你以前见过类似的东东吗?
FOnChange: TNotifyEvent;
Procedure: OnChange(var message: TWMOnChange) message :WM_OnChange;
protected
Procedure OnChange: dynamic;
published
property OnChange: TNotifyEvent read FOnchange write FonChange
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.