?
Solved

Display and Close a window without user interaction

Posted on 1999-01-06
8
Medium Priority
?
132 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
8 Comments
 
LVL 8

Accepted Solution

by:
ZifNab earned 80 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

649 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