Solved

Make the user required to enter text in a InputQuery,part2

Posted on 2009-07-16
2
238 Views
Last Modified: 2012-05-07
I have asked this question twice but did not get a good solution.
And I think its because I didn´t tell it right. So this time i do it with
pictures. And I hope someone can help me. And it is possible because
the pictures I have posted comes from another application.

Step1: The user presses the Folder-button on the toolbar to create a Folder-node in the treeview.
Step2: The input-appears. The user must give the node a name, so he-she must put at least 1 character in it.
Step3: Because when he doesn´t a message appears.
Step4: After pressing the OK-button of the message. The input-query is still waiting for input.
           (unless you press the Cancel-button afcourse)
           In other words: its not possible to give the treenode no name.

I have put in the CODE-SECTION the File and Folder procedures.
The only thing that´s wrong with these procedures is in step 4.
When the user press the OK-button of the message the input-query
dissapear too.

I really hope someone can help me this time.

Thank you in advanced.

Peter Kiers

procedure TForm1.FileBtnClick(Sender: TObject);

var aText: string;

begin

  aText := '';

  if (TreeView1.Selected <> nil) and (TreeView1.Selected.ImageIndex = 15) then

  begin

     if InputQuery('New Item', 'New Item Name:', aText) then

        begin

        if length(trim(aText)) > 0 then  AddItem(aText, 17, TreeView1.Selected)

        else MessageBox(0, 'You must enter an item name.', 'Error', MB_OK + MB_ICONEXCLAMATION);

     end;  

  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('New Folder', 'New Folder Name:', aText) then

      begin

      if length(trim(aText)) > 0 then  AddItem(aText, 15, aParent)

      else MessageBox(0, 'You must enter a folder name.', 'Error', MB_OK + MB_ICONEXCLAMATION);

  end;

end;

Open in new window

Stap1.jpg
Stap2.jpg
Stap3.jpg
Stap4.jpg
0
Comment
Question by:peterkiers
2 Comments
 
LVL 14

Accepted Solution

by:
SteveBay earned 500 total points
ID: 24871870
The problem is that ImputQuery doe not have any validation built into it. In order to have a Modal prompt dialog stay up while you are displaying the validation message you will need to create your own Imput dialog and put the validation there. In the case of InputQuery you can only perform validation aftrer it has return from it's modal state and given you a result.
0
 
LVL 1

Author Comment

by:peterkiers
ID: 24871990
Ok I understand now. Thanks for the info.

Greetings,
peter Kiers
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now