Solved

Display and Close a window without user interaction

Posted on 1999-01-06
8
124 Views
Last Modified: 2010-04-04
Hi experts,

I want to display some information in a window at the moment when a savefile dialogue appears on the screen. As soon as the savefile dialogue dissapears from the screen- after I typed in the filename-
the window with the displayed information should dissapear AUTOMATICALLY from the screen, too.  Automatically means: No additional user interaction is required, I don't want to click on a "Ok" button" or "close" button or something like that. (The information I want to display is the number of blanks found in a text file)

Have you suggestions how this could be done in Delphi 3.0 ?
(not the counting of blanks in a file, but this stuff with displaying and deleting a window without user interaction...)

With kind regards

Mathes

0
Comment
Question by:mathes
  • 4
  • 2
  • 2
8 Comments
 
LVL 8

Accepted Solution

by:
ZifNab earned 20 total points
ID: 1354899
Hi mathes,

what about :

form1.Show
call dialog (if dialog.Execute then ...)
form1.Close (or Hide, or ...)

Regards, Zif.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1354900
hi mathes,

create a second Form (Your InformationForm), then you can use this code.

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    SaveDialog1: TSaveDialog;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    procedure SaveDialog1Show(Sender: TObject);
    procedure SaveDialog1Close(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

uses Unit2;

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
  savedialog1.Execute;
end;

procedure TForm1.SaveDialog1Show(Sender: TObject);
begin
  {Fill Your InformationForm with Information
    Form2.Edit1.text := Someinformation ...}
  form2.show; {Display your InformationForm}
end;

procedure TForm1.SaveDialog1Close(Sender: TObject);
begin
  form2.close; {Close your InformationForm}
end;

end.

meikl

0
 

Author Comment

by:mathes
ID: 1354901
Hi experts,

I want to display some information in a window at the moment when a savefile dialogue appears on the screen. As soon as the savefile dialogue dissapears from the screen- after I typed in the filename-
the window with the displayed information should dissapear AUTOMATICALLY from the screen, too.  Automatically means: No additional user interaction is required, I don't want to click on a "Ok" button" or "close"button or something like that.

Have you suggestions how this could be done in Delphi 3.0 ?

With kind regards

Mathes

ZifNab
                                                            Date: Wednesday, January 06 1999 - 05:01AM PST

    Hi mathes,

    what about :

    form1.Show
    call dialog (if dialog.Execute then ...)
    form1.Close (or Hide, or ...)

    Regards, Zif.







Question History:


                                            Proposed Answer
      From: ZifNab
                                                         Date: Wednesday, January 06 1999 - 05:01AM PST


                                             Text above...









                                               Comment
      From: kretzschmar
                                                          Date: Wednesday, January 06 1999 - 05:14AM PST

      hi mathes,

      create a second Form (Your InformationForm), then you can use this code.

-------------------------

      unit Unit1;

      interface

      uses
        Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
        StdCtrls;

      type
        TForm1 = class(TForm)
          SaveDialog1: TSaveDialog;
          Button1: TButton;
          procedure Button1Click(Sender: TObject);
          procedure SaveDialog1Show(Sender: TObject);
          procedure SaveDialog1Close(Sender: TObject);
        private
          { Private-Deklarationen }
        public
          { Public-Deklarationen }
        end;

      var
        Form1: TForm1;

      implementation

      uses Unit2;

      {$R *.DFM}

      procedure TForm1.Button1Click(Sender: TObject);
      begin
        savedialog1.Execute;
      end;

      procedure TForm1.SaveDialog1Show(Sender: TObject);
      begin
        {Fill Your InformationForm with Information
          Form2.Edit1.text := Someinformation ...}
        form2.show; {Display your InformationForm}
      end;

      procedure TForm1.SaveDialog1Close(Sender: TObject);
      begin
        form2.close; {Close your InformationForm}
      end;

      end.
 
Hi experts,

thank you for your comment,

Zifnab: I am afraid you suppose that the dialogue and the displayed information are both in the same form.
I can not implement this, because on the form with the dialogue control I don't have any free space to
display something.

kretzschmar: This comes very close to what I am looking for. However when I tried your code, the second form
with the information never shows up in my screen. I want that the dialog and infoscreen both show up together.

Can you please have a look at my source code and tell me, what I am doing wrong here?

With kind regards

Mathes

-------------------
   unit mainform;

      interface

      uses
        Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
        StdCtrls;

      type
        TForm1 = class(TForm)
          SaveDialog1: TSaveDialog;
          Button1: TButton;
          procedure Button1Click(Sender: TObject);
          procedure SaveDialog1Show(Sender: TObject);
          procedure SaveDialog1Close(Sender: TObject);
        private
          { Private-Deklarationen }
        public
          { Public-Deklarationen }
        end;

      var
        Form1: TForm1;

      implementation

      uses Unit2;

      {$R *.DFM}

      procedure TForm1.Button1Click(Sender: TObject);
      begin
        savedialog1.Execute;
      end;

      procedure TForm1.SaveDialog1Show(Sender: TObject);
      begin
        //Fill Your InformationForm with Information
          //Form2.Edit1.text := Someinformation
        form2.show; //Display your InformationForm
      end;

      procedure TForm1.SaveDialog1Close(Sender: TObject);
      begin
        form2.close; {Close your InformationForm}
      end;

      end.

------------------
unit infoscreen;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm2 = class(TForm)
    info: TLabel;
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form2: TForm2;

implementation

{$R *.DFM}

end.
------------------
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1354902
mathes? I am afraid you suppose that the dialogue and the displayed information are both in the same form. I can not implement this, because on the form with the dialogue control I don't have any free space to display something. Nope I don't assume this...

unit main

use form2


begin
 form2.Show
 dialog
 form2.Close
end;

neither form2, form1 (main) or dialog are on the same form...

In fact it's the same as what you do in the dialog events.... Except I call show/close not in the events, but before the dialog exists or after the dialog has existed...

zif.
0
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.

 
LVL 8

Expert Comment

by:ZifNab
ID: 1354903
here you can see the difference in both methods, both give what you want :

form2 (my method)
form3 (kretzschmar method)

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    OpenDialog1: TOpenDialog;
    procedure Button1Click(Sender: TObject);
    procedure OpenDialog1Show(Sender: TObject);
    procedure OpenDialog1Close(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses Unit2, Unit3;

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
 form2.show;
 opendialog1.Execute;
 form2.close;
end;

procedure TForm1.OpenDialog1Show(Sender: TObject);
begin
 form3.Show;
end;

procedure TForm1.OpenDialog1Close(Sender: TObject);
begin
 form3.close;
end;

end.



0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1354904
it can be that in your code, the message form is smaller then the dialog form... and that there position is the same... then the dialog will 'hide' your smaller form.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1354905
hi mathes,

both solutions have the same effect, and zif could be right that the dialog is over your information form.

set the position of your Information form before show like

 form2.left := 10; {or any other position }
 form2.show;

meikl
0
 

Author Comment

by:mathes
ID: 1354906
Hi experts,

thank you for your help

with form2.left:=10, everything works very well.

Mathes
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

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

910 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

25 Experts available now in Live!

Get 1:1 Help Now