Solved

Display and Close a window without user interaction

Posted on 1999-01-06
8
121 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 8

Expert Comment

by:ZifNab
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Hi experts,

thank you for your help

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

Mathes
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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 video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

763 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

9 Experts available now in Live!

Get 1:1 Help Now