Solved

Little form in the lower right corner

Posted on 2004-08-14
10
372 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
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 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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month10 days, 4 hours left to enroll

623 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