Your question, your audience. Choose who sees your identity—and your question—with question security.
procedure TForm1.FileBtnClick(Sender: TObject);
var aText: string;
begin
if (TreeView1.Selected <> nil) and (TreeView1.Selected.ImageIndex = 15) then
begin
if InputQuery('File', 'Enter a file name', aText) then
AddItem(aText, 17, TreeView1.Selected);
end else
ShowMessage('Select a folder in the treeview first.');
end;
(*---------------------------------------------------*)
procedure TForm1.FolderBtnClick(Sender: TObject);
var aText: string;
aParent: TTreeNode;
begin
aParent := nil;
if TreeView1.Selected <> nil then
begin
if TreeView1.Selected.ImageIndex = 15 then
aParent := TreeView1.Selected
else
begin
ShowMessage('Select a folder first');
Exit;
end;
end;
if InputQuery('Folder', 'Enter a folder name', aText) then
AddItem(aText, 15, aParent);
end;
Example2.bmp
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
From novice to tech pro — start learning today.
Anyway, here is one kind of solutions :
procedure TForm1.FileBtnClick(Sender
var aText: string;
begin
aText := '';
if (TreeView1.Selected <> nil) and (TreeView1.Selected.ImageI
begin
InputQuery('File', 'Enter a file name', aText);
if lenght(trim(aText)) = 0 then
begin
repeat
if not (InputQuery(' WRONG FILE NAME !!! ', 'You must enter file name ', aText)) then Break;
until length(trim(aText)) > 0;
end;
if lenght(trim(aText)) > 0 then AddItem(aText, 17, TreeView1.Selected);
end;
end else
ShowMessage('Select a folder in the treeview first.');
end;
regards,
steve