Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Little form in the lower right corner

Posted on 2004-08-14
10
Medium Priority
?
381 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
[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
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

705 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