A apus Unregistered / Unconfirmed GUEST, unregistred user! 2002-09-12 #1 注意: 还没有select,只是光标移动到! 头次提问,请多关照,分提高不了,最多了。
W wumeng Unregistered / Unconfirmed GUEST, unregistred user! 2002-09-12 #2 >>combobox的光标到某个item的事件. 没有这个事件。
W wumeng Unregistered / Unconfirmed GUEST, unregistred user! 2002-09-13 #4 >> 还没有select,只是光标移动到! 你想在这个事件中作什么?也许其它的事件可以代替这个事件。
A apus Unregistered / Unconfirmed GUEST, unregistred user! 2002-09-19 #9 那位大侠做过类似的工作,我知道没有,但有没有里斯的vcl控件. 谁可提供线索.[blue][/blue]
独 独帅 Unregistered / Unconfirmed GUEST, unregistred user! 2002-09-23 #11 SendMessage(ComboBox1.Handle, CB_GETCURSEL, 0, 0)的返回值就是。
X xeen Unregistered / Unconfirmed GUEST, unregistred user! 2002-09-26 #13 TCombobox没有这个事件,你可以改从它继承写一个新的控件: 截获 CB_SETCURSEL 消息就可以。
独 独帅 Unregistered / Unconfirmed GUEST, unregistred user! 2002-09-27 #14 {******************************************************************************* 发表新控件:TComBoBoxCS; 功能:添加事件:OnSelChange(),触发时间是TComBoBoxCS的光标在item之间移动的时候. 添加属性:CurSelItem,可以获得光标位于哪个item上 -1为没有,0为第一条item,1为第二条item,依此类推... 欢迎使用、修改、完善,欢迎交流(9on9@sina.com) ********************************************************************************} unit ComBoBoxCS; interface uses Windows, SysUtils, Classes, Controls, StdCtrls, Messages, Forms; type TComBoBoxCS = class(TComboBox) private { Private declarations } FOnSelChange: TNotifyEvent; FCurSelItem: Integer; protected { Protected declarations } procedure WndProc(var Message: TMessage); override; procedure SelChange; public { Public declarations } published { Published declarations } property OnSelChange: TNotifyEvent read FOnSelChange write FOnSelChange; property CurSelItem: Integer read FCurSelItem; end; procedure Register; implementation procedure Register; begin RegisterComponents('Mr.Nono', [TComBoBoxCS]); end; { TComBoBoxCS } procedure TComBoBoxCS.SelChange; begin if Assigned(FOnSelChange) then FOnSelChange(Self); end; procedure TComBoBoxCS.WndProc(var Message: TMessage); begin inherited WndProc(Message); case Message.Msg of WM_CTLCOLORLISTBOX: begin FCurSelItem := SendMessage(Handle, CB_GETCURSEL, 0, 0); SelChange; end; end; end; end.
{******************************************************************************* 发表新控件:TComBoBoxCS; 功能:添加事件:OnSelChange(),触发时间是TComBoBoxCS的光标在item之间移动的时候. 添加属性:CurSelItem,可以获得光标位于哪个item上 -1为没有,0为第一条item,1为第二条item,依此类推... 欢迎使用、修改、完善,欢迎交流(9on9@sina.com) ********************************************************************************} unit ComBoBoxCS; interface uses Windows, SysUtils, Classes, Controls, StdCtrls, Messages, Forms; type TComBoBoxCS = class(TComboBox) private { Private declarations } FOnSelChange: TNotifyEvent; FCurSelItem: Integer; protected { Protected declarations } procedure WndProc(var Message: TMessage); override; procedure SelChange; public { Public declarations } published { Published declarations } property OnSelChange: TNotifyEvent read FOnSelChange write FOnSelChange; property CurSelItem: Integer read FCurSelItem; end; procedure Register; implementation procedure Register; begin RegisterComponents('Mr.Nono', [TComBoBoxCS]); end; { TComBoBoxCS } procedure TComBoBoxCS.SelChange; begin if Assigned(FOnSelChange) then FOnSelChange(Self); end; procedure TComBoBoxCS.WndProc(var Message: TMessage); begin inherited WndProc(Message); case Message.Msg of WM_CTLCOLORLISTBOX: begin FCurSelItem := SendMessage(Handle, CB_GETCURSEL, 0, 0); SelChange; end; end; end; end.
A apus Unregistered / Unconfirmed GUEST, unregistred user! 2002-09-29 #15 独帅Sir: 你是否测试了代码? 似乎有问题? 另:你是否太喜欢CS?
A apus Unregistered / Unconfirmed GUEST, unregistred user! 2002-09-29 #16 独帅Sir: 或者我的测试方法不对,你可否告知怎么测试。
独 独帅 Unregistered / Unconfirmed GUEST, unregistred user! 2002-09-30 #17 //当光标在items中移动时,就会触发OnSelChange事件,这时候你可以通过访问其CurSelItemunit属性 //来获取当前光标的位置(索引) //CS:Cursor Select,随便起的名字,本想叫ComBoBoxEX,可是已经有了[]。 //与那个游戏CS没有任何关系,说实话,我不喜欢CS,也从来没有玩过。 //看看下面的程序是不是你要的: Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComBoBoxCS; type TForm1 = class(TForm) ComBoBoxCS1: TComBoBoxCS; procedure ComBoBoxCS1SelChange(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.ComBoBoxCS1SelChange(Sender: TObject); begin Caption := IntToStr(ComBoBoxCS1.CurSelItem); end; end.
//当光标在items中移动时,就会触发OnSelChange事件,这时候你可以通过访问其CurSelItemunit属性 //来获取当前光标的位置(索引) //CS:Cursor Select,随便起的名字,本想叫ComBoBoxEX,可是已经有了[]。 //与那个游戏CS没有任何关系,说实话,我不喜欢CS,也从来没有玩过。 //看看下面的程序是不是你要的: Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComBoBoxCS; type TForm1 = class(TForm) ComBoBoxCS1: TComBoBoxCS; procedure ComBoBoxCS1SelChange(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.ComBoBoxCS1SelChange(Sender: TObject); begin Caption := IntToStr(ComBoBoxCS1.CurSelItem); end; end.
A apus Unregistered / Unconfirmed GUEST, unregistred user! 2002-09-30 #18 独帅Sir: 你的这句话: //当光标在items中移动时,就会触发OnSelChange事件, 似乎和我想的有点出入。 当选中item时会触发OnSelChange事件,但是当光标在items间移动时似乎并不触发。 请测试。 谢谢,希望你继续。
独帅Sir: 你的这句话: //当光标在items中移动时,就会触发OnSelChange事件, 似乎和我想的有点出入。 当选中item时会触发OnSelChange事件,但是当光标在items间移动时似乎并不触发。 请测试。 谢谢,希望你继续。
影 影 子 Unregistered / Unconfirmed GUEST, unregistred user! 2002-09-30 #19 Style设置为csOwnerDrawFixed或者csOwnerDrawVariable, OnDrawItem事件中的Index就是你要的值。
独 独帅 Unregistered / Unconfirmed GUEST, unregistred user! 2002-09-30 #20 to: apus //但是当光标在items间移动时似乎并不触发 我上面的程序在运行时,当光标在items间移动时,窗口的标题栏应该是当前光标所在的item的索引值, 请问你是如何测试的呢?还是我没看懂你的问题? 请你做一个最简单的测试程序发到我的信箱好吗?最好把可执行程序给我发过来,放假后就只能在网吧 上网了。
to: apus //但是当光标在items间移动时似乎并不触发 我上面的程序在运行时,当光标在items间移动时,窗口的标题栏应该是当前光标所在的item的索引值, 请问你是如何测试的呢?还是我没看懂你的问题? 请你做一个最简单的测试程序发到我的信箱好吗?最好把可执行程序给我发过来,放假后就只能在网吧 上网了。