在一次对ini文件操作时;由于笔误;将代码敲错;于是combobox的change事件的代码成了下面这个;
procedure TForm1.ComboBox1Change(Sender: TObject);
var INIfile: TINIfile;
begin
INIfile := Tinifile.Create(extractfilepath(application.ExeName) + '1.ini');
inifile.ReadSection(combobox1.Text,combobox1.Items);
end;这时出现了一点意外;就是往combobox1中输入的东西全部变成了反序排列的;
譬如输入【张类】变成了【类张】;
相应的【123】..【321】
【zaq】..【qaz】哪位朋友给点提示;为什么会这样;先谢谢了;
procedure TForm1.ComboBox1Change(Sender: TObject);
var INIfile: TINIfile;
begin
INIfile := Tinifile.Create(extractfilepath(application.ExeName) + '1.ini');
inifile.ReadSection(combobox1.Text,combobox1.Items);
end;这时出现了一点意外;就是往combobox1中输入的东西全部变成了反序排列的;
譬如输入【张类】变成了【类张】;
相应的【123】..【321】
【zaq】..【qaz】哪位朋友给点提示;为什么会这样;先谢谢了;
解决方案 »
- delphi 如何读取电流表的值?
- BSTR长度问题
- 小弟原创的一东东:桌面整合播放器,欢迎下载.
- 我想判断combobox为空是,清除edit1.TEXT,可是不行
- AppServer 注册!
- 通过程序来更改本机的工作级名称!高手高高手一定要相助啊(附源码)
- 大家好!如何把一个文本重新整理排列?
- 请问下多层MIDAS开发中,为何应用服务器运行久了,客户端的socket的connction会很久,而初启动时不会
- 尝试写个Delphi的简单小框架,欢迎大家多提意见!
- hank,俺终于忍痛改结构了!你可有收到$130?嘻嘻,顺便再问个简单问题。。。
- 这个sql怎么写??
- Delphi里面有没有什么查找窗口的好方法??(急!等)
procedure TIniFile.ReadSection(const Section: string; Strings: TStrings);
const
BufSize = 16384;
var
Buffer, P: PChar;
begin
GetMem(Buffer, BufSize);
try
Strings.BeginUpdate;
try
Strings.Clear;//////////////////////////////////原因是因为这句
if GetPrivateProfileString(PChar(Section), nil, nil, Buffer, BufSize,
PChar(FFileName)) <> 0 then
……
不信的话可以这样看看Procedure TForm1.ComboBox1Change(Sender: TObject);
begin
Combobox1.Items.Clear;
end;是不是效果是一样的?那我们就看这个Clearprocedure TCustomComboBoxStrings.Clear;
var
S: string;
begin
S := ComboBox.Text;
SendMessage(ComboBox.Handle, CB_RESETCONTENT, 0, 0);
ComboBox.Text := S;
ComboBox.Update;
end;
看到他是先保存原来的text,
然后发一个重置消息,
然后再还原text
所以光标就跑到在前面了其实最后就是这样啦Procedure TForm1.ComboBox1Change(Sender: TObject);
var
S: string;
begin
S := ComboBox1.Text;
SendMessage(ComboBox1.Handle, CB_RESETCONTENT, 0, 0);
ComboBox1.Text := S;
end;
wParam = 0; // not used; must be zero
lParam = 0; // not used; must be zero
ParametersThis message has no parameters. Return ValuesThis message always returns CB_OKAY. ResIf you create the combo box with an owner-drawn style but without the CBS_HASSTRINGS style, the owner of the combo box receives a WM_DELETEITEM message for each item in the combo box.