Solved

Display and Close a window without user interaction

Posted on 1999-01-06
8
128 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 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
LAN or WAN ? 11 117
Adoquery sql  left join does not work 25 116
PHP preg_replace code convert to Delphi 14 96
Using MMsystem To change audio input 1 36
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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

738 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