Quote:
Originally Posted by audiofeel
@BLACKFIRE69
Is there any way to get a list of disks in a listbox? I don't quite understand how to do this. The example with the combobox does not fit.
Code:
procedure GetDisks;
var
w: dword;
Root: string;
i, DiskType: integer;
begin
w:= GetLogicalDrives;
Root:= '#:\';
for i:= 0 to 24 do
begin
Root[1]:= Chr(Ord('A') + i);
if (W and (1 shl i)) > 0 then
if (GetDriveType(PAnsiChar(Root)) = DRIVE_FIXED) then
Edit1Combo.AddItem(Root);
end;
Edit1Combo.SetItemIndex(0);
end;
|
it's not a big deal.
Code:
var
...
mListBox : FListBox;
mListBoxItem: array of FListBoxItem;
...
procedure FMXInnoInit;
begin
...
mListBox := InitListBoxHandle;
...
end;
procedure InitializeWizard();
begin
...
FMXDesigning;
FMXForm.Show;
mListBox.SetItemIndex(2); // i-1
...
end;
procedure ListBoxOnChange(Sender: TObject);
begin
if mListBox.GetItemIndex > -1 then
WinTB1.Text('Selected Drive: [' + mListBox.GetItemText(mListBox.GetItemIndex) + ']');
end;
Code:
procedure FMXDesigning;
var
i, CDrvIdx: Integer;
ADrvLst: TArrWStr;
begin
...
if not wGetLogicalDriveList(ADrvLst, CDrvIdx) then
begin
Log('"wGetLogicalDriveList" failed!');
MsgBox('"wGetLogicalDriveList" failed!', mbError, MB_OK);
// try another way.
end;
{ ListBox }
mListBox.FCreate(FMXForm.Handle);
mListBox.SetBounds(NSX(32), NSY(53), NSX(297), NSY(249));
mListBox.OnChange(@ListBoxOnChange);
{ Items }
SetArrayLength(mListBoxItem, GetArrayLength(ADrvLst));
mListBox.BeginUpdate;
for i := 0 to GetArrayLength(ADrvLst) - 1 do
begin
mListBoxItem[i] := InitListBoxItemHandle;
mListBoxItem[i].FCreate(mListBox.Handle);
mListBoxItem[i].Text(ADrvLst[i]);
mListBox.AddItem(mListBoxItem[i].Handle);
end;
mListBox.EndUpdate;
...
end;
.