Solved

Little form in the lower right corner

Posted on 2004-08-14
10
345 Views
Last Modified: 2010-04-05
Hey there
What I have is two forms
Form1 and Form2
Form1 has a button that opens Form2, now what I need, is Form2 to be positioned in the lower right corder(just above the date and time).
This needs to work on all different screen resoultions as well....


So basically when it comes down to it, position From2 in the lower right corner of the screen - on any resoultion.

Cheers
NIck
0
Comment
Question by:wildzero
  • 8
  • 2
10 Comments
 
LVL 12

Expert Comment

by:esoftbg
ID: 11803321
//........ Project :

program Q_21094171;
uses
  Forms,
  Unit1_Q_21094171 in 'Unit1_Q_21094171.pas' {Form1},
  Unit2_Q_21094171 in 'Unit2_Q_21094171.pas' {Form2};

{$R *.res}

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.CreateForm(TForm2, Form2);
  Application.Run;
end.

//........ Unit1:

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private   { Private declarations }
  public    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses
  Unit2;

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  Form2.Show;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  Form2.Hide;
end;

end.

//........ Form1:

object Form1: TForm1
  Left = 200
  Top = 112
  BorderIcons = [biSystemMenu, biMinimize]
  BorderStyle = bsSingle
  Caption = 'Form1'
  ClientHeight = 94
  ClientWidth = 184
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  Position = poDefaultPosOnly
  PixelsPerInch = 96
  TextHeight = 13
  object Button1: TButton
    Left = 16
    Top = 10
    Width = 96
    Height = 25
    Caption = 'Show Form2'
    TabOrder = 0
    OnClick = Button1Click
  end
  object Button2: TButton
    Left = 16
    Top = 48
    Width = 96
    Height = 25
    Caption = 'Hide Form2'
    TabOrder = 1
    OnClick = Button2Click
  end
end

//........ Unit2:

unit Unit2;

interface

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

type
  TForm2 = class(TForm)
    Edit1: TEdit;
    procedure FormShow(Sender: TObject);
  private  { Private declarations }
  public   { Public declarations }
  end;

var
  Form2: TForm2;

implementation

{$R *.dfm}

procedure TForm2.FormShow(Sender: TObject);
begin
  Top := Screen.Height - Height - 32;
  Left := Screen.Width - Width;
end;

end.

//........ Form2:

object Form2: TForm2
  Left = 192
  Top = 128
  BorderIcons = [biSystemMenu, biMinimize]
  BorderStyle = bsNone
  Caption = 'Form2'
  ClientHeight = 30
  ClientWidth = 120
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  OnShow = FormShow
  PixelsPerInch = 96
  TextHeight = 13
  object Edit1: TEdit
    Left = 2
    Top = 4
    Width = 112
    Height = 21
    ReadOnly = True
    TabOrder = 0
    Text = 'I am above the clock'
  end
end
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 11803322
//........ Project :

program Q_21094171;
uses
  Forms,
  Unit1 in 'Unit1.pas' {Form1},
  Unit2 in 'Unit2.pas' {Form2};

{$R *.res}

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.CreateForm(TForm2, Form2);
  Application.Run;
end.
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 11803359
procedure TForm2.FormShow(Sender: TObject);
var
  R:      TRect;
begin
  Memo.Clear;
  SystemParametersInfo(SPI_GETWORKAREA, 0, @R, 0);
  Memo.Lines.Add('Work area is the portion of the screen not obscured by the taskbar');
  Memo.Lines.Add('Left=' + IntToStr(R.Left));
  Memo.Lines.Add('Top=' + IntToStr(R.Top));
  Memo.Lines.Add('Right=' + IntToStr(R.Right));
  Memo.Lines.Add('Bottom=' + IntToStr(R.Bottom));
  Top := R.Bottom - Height;
  Left := R.Right - Width;
end;

//........

object Form2: TForm2
  Left = 193
  Top = 107
  BorderIcons = [biSystemMenu, biMinimize]
  BorderStyle = bsNone
  Caption = 'Form2'
  ClientHeight = 126
  ClientWidth = 120
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  OnShow = FormShow
  PixelsPerInch = 96
  TextHeight = 13
  object Memo: TMemo
    Left = 2
    Top = 2
    Width = 112
    Height = 120
    ReadOnly = True
    TabOrder = 0
  end
end

emil
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 10

Author Comment

by:wildzero
ID: 11803387
Hey there,

Thanks for the speedy reply.
I see the code Top := Screen.Height - Height - 32;
but - what happens if they have re-sized there task bar 'two lines high'?
0
 
LVL 12

Accepted Solution

by:
esoftbg earned 250 total points
ID: 11803412
What about the next code ?

procedure TForm2.FormShow(Sender: TObject);
var
  R:      TRect;
begin
  Memo.Clear;
  SystemParametersInfo(SPI_GETWORKAREA, 0, @R, 0);
  Memo.Lines.Add('Work area is the portion of the screen not obscured by the taskbar');
  Memo.Lines.Add('Left=' + IntToStr(R.Left));
  Memo.Lines.Add('Top=' + IntToStr(R.Top));
  Memo.Lines.Add('Right=' + IntToStr(R.Right));
  Memo.Lines.Add('Bottom=' + IntToStr(R.Bottom));
  Top := R.Bottom - Height;
  Left := R.Right - Width;
end;

procedure TForm2.TimerTimer(Sender: TObject);
begin
  FormShow(Self);
end;
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 11803444
procedure TForm2.FormShow(Sender: TObject);
var
  B:      Boolean;
  L:      Integer;
  T:      Integer;
  R:      TRect;
begin
  B := False;
  SystemParametersInfo(SPI_GETWORKAREA, 0, @R, 0);
  T := R.Bottom - Height;
  L := R.Right - Width;
  if (T<>Top) then
  begin
    B := True;
    Top := T;
  end;
  if (L<>Left) then
  begin
    B := True;
    Left := L;
  end;
  if B then
  begin
    Memo.Clear;
    Memo.Lines.Add('Work area is the portion of the screen not obscured by the taskbar');
    Memo.Lines.Add('Left=' + IntToStr(R.Left));
    Memo.Lines.Add('Top=' + IntToStr(R.Top));
    Memo.Lines.Add('Right=' + IntToStr(R.Right));
    Memo.Lines.Add('Bottom=' + IntToStr(R.Bottom));
  end;
end;

procedure TForm2.TimerTimer(Sender: TObject);
begin
  FormShow(Self);
end;
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 11803460
If the Timer.Interval is 2000, then every 2 seconds Form2 corrects itself position if needed !!!!
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 11803480
download the example from :
page:        http://www.geocities.com/esoftbg/
  link:        Q_21094171.zip
0
 
LVL 10

Author Comment

by:wildzero
ID: 11804949
Thats great :)
many thanks
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 11805064
Hi wildzero, you are welcome !
Glad to be in help !
Best regards,
emil      :~))
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
Delphi 2 59
Unique identifier on a terminal server (rdp) 4 53
Moving (cutting/pasting) controls in a TTabbedNotebook... 7 34
Tvertscrollbox like a whatsapp layout 5 27
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

770 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