アプリケーションプールのリストを取得し、コンボボックスにアプリプールの名前を入力しています。問題は、OnDropDown
イベントが呼び出されると、コンボボックスがほんの一瞬開いてからすぐに閉じることです。「ドロップダウン」されたままにはなりません。コンボボックスにすべてのアプリプールが表示されます。これが私のコードです:
function GetApplicationPoolList() : TArrayOfString;
var
i, nExitCode: Integer;
sFileLines: TArrayOfString;
sTempFileName, sListAppPoolCmd: String;
begin
sListAppPoolCmd := ExpandConstant('{sys}') + '\inetsrv\appcmd list apppool /text:name';
sTempFileName := ExpandConstant('{tmp}') + '\appPoolList.txt';
if not ExecAppCmd(Format('%s > %s',[sListAppPoolCmd, sTempFileName]), nExitCode) then begin
MsgBox('Could not get app pools', mbError, MB_OK);
end else begin
LoadStringsFromFile(sTempFileName, sFileLines);
end
Result := sFileLines;
end;
// ==============================================
procedure OnAppPoolComboBoxDropDown(Sender: TObject);
var
sAppPoolList: TArrayOfString;
i: Integer;
begin
// Clear existing
appPoolComboBox.Items.Clear;
// Populate the combo box with the application pools
sAppPoolList := GetApplicationPoolList;
For i := 0 to GetArrayLength (sAppPoolList) - 1 do
begin
// ComboBox with Application Pool Names
appPoolComboBox.Items.Add(sAppPoolList[i]);
end;
appPoolComboBox.ItemIndex := 0;
end;
function ExecAppCmd(params :String; nExitCode: Integer) :Boolean;
var
execSuccessfully :Boolean;
resultCode :Integer;
begin
execSuccessfully := Exec('cmd.exe', '/c ' + '' + ' ' + params, '', SW_HIDE, ewWaitUntilTerminated, resultCode);
nExitCode := resultCode;
Result := execSuccessfully and (resultCode = 0);
end;
ここで何が起こっているのかわかりません。アドバイスをいただければ幸いです。
編集:ExecAppCmd
問題のようです、コメントアウトするとコンボボックスが正常に動作します...理由はわかりませんが
ドロップダウンが閉じるのは、アプリケーションの起動時にコンボボックスのフォーカスが一時的に失われたためと考えられます。
ドロップダウンでアプリケーションを呼び出すことは、時間がかかり、ユーザーエクスペリエンスを損なうため、悪い習慣だと思います。fromのように、以前にコンボボックスにデータを入力しCurPageChanged
ます。
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加