Solved

Display and Close a window without user interaction

Posted on 1999-01-06
8
125 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
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
 
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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Simple Delphi Question 9 90
Intraweb download file link ? 1 134
QRReport  TQrmemo vertical stretching 1 47
RESTRequest Parameter 4 31
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

803 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