function GetComboBoxText(mHandle: THandle; mStrings: TStrings): Boolean;
var
vItemCount: Integer;
I: Integer;
S: string;
begin
Result := False;
if not Assigned(mStrings) then Exit;
mStrings.BeginUpdate;
try
mStrings.Clear;
vItemCount := SendMessage(mHandle, CB_GETCOUNT, 0, 0);
for I := 0 to vItemCount - 1 do begin
SetLength(S, SendMessage(mHandle, CB_GETLBTEXTLEN, I, 0));
SendMessage(mHandle, CB_GETLBTEXT, I, Integer(@S[1]));
mStrings.Add(S);
end;
SetLength(S, 0);
finally
mStrings.EndUpdate;
end;
Result := True;
end; { GetComboBoxText }//Example
procedure TForm1.FormCreate(Sender: TObject);
begin
RegisterHotKey(Handle, 1, MOD_WIN, VK_F2);
end;procedure TForm1.FormDestroy(Sender: TObject);
begin
UnRegisterHotKey(Handle, 1);
end;procedure TForm1.WMHOTKEY(var Msg: TWMHOTKEY);
begin GetComboBoxText(
WindowFromPoint(Point(Mouse.CursorPos.X, Mouse.CursorPos.Y)),
MemoText.Lines);
end;
end;这段Delphi代码是我从网上找的,是用来获得Combobox的内容的,可是里面有些地方看得不太懂,我没怎么学过Delphi,比如那个SetLength就不知道怎么办,还有什么MemoText.Lines我也不懂是干什么的......,反正一些地方不太清楚,还请各位大侠帮帮忙,帮我翻译成vb6的,这我就能看懂了,只需要把主要的句子翻译一下就行了,谢谢
var
vItemCount: Integer;
I: Integer;
S: string;
begin
Result := False;
if not Assigned(mStrings) then Exit;
mStrings.BeginUpdate;
try
mStrings.Clear;
vItemCount := SendMessage(mHandle, CB_GETCOUNT, 0, 0);
for I := 0 to vItemCount - 1 do begin
SetLength(S, SendMessage(mHandle, CB_GETLBTEXTLEN, I, 0));
SendMessage(mHandle, CB_GETLBTEXT, I, Integer(@S[1]));
mStrings.Add(S);
end;
SetLength(S, 0);
finally
mStrings.EndUpdate;
end;
Result := True;
end; { GetComboBoxText }//Example
procedure TForm1.FormCreate(Sender: TObject);
begin
RegisterHotKey(Handle, 1, MOD_WIN, VK_F2);
end;procedure TForm1.FormDestroy(Sender: TObject);
begin
UnRegisterHotKey(Handle, 1);
end;procedure TForm1.WMHOTKEY(var Msg: TWMHOTKEY);
begin GetComboBoxText(
WindowFromPoint(Point(Mouse.CursorPos.X, Mouse.CursorPos.Y)),
MemoText.Lines);
end;
end;这段Delphi代码是我从网上找的,是用来获得Combobox的内容的,可是里面有些地方看得不太懂,我没怎么学过Delphi,比如那个SetLength就不知道怎么办,还有什么MemoText.Lines我也不懂是干什么的......,反正一些地方不太清楚,还请各位大侠帮帮忙,帮我翻译成vb6的,这我就能看懂了,只需要把主要的句子翻译一下就行了,谢谢
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货