implement TCustomForm.EnsureVisible

git-svn-id: trunk@8557 -
This commit is contained in:
micha 2006-01-18 20:21:15 +00:00
parent 9347949119
commit a38ed98e25
3 changed files with 25 additions and 15 deletions

View File

@ -2782,22 +2782,10 @@ begin
end;
Procedure TMainIDE.mnuViewMessagesClick(Sender: TObject);
var
newLeft, newTop: integer;
Begin
begin
// it was already visible, but user does not see it, try to move in view
if MessagesView.Visible then
begin
newLeft := MessagesView.Left;
newTop := MessagesView.Top;
if newLeft + (MessagesView.Width div 2) > Screen.Width then
newLeft := 0;
if newTop + (MessagesView.Height div 2) > Screen.Height then
newTop := Screen.Height - MessagesView.Height - 25;
MessagesView.SetBounds(newLeft, newTop, MessagesView.Width, MessagesView.Height);
end;
MessagesView.ShowOnTop;
End;
MessagesView.EnsureVisible;
end;
Procedure TMainIDE.mnuViewSearchResultsClick(Sender: TObject);
Begin

View File

@ -478,6 +478,7 @@ type
procedure Hide;
procedure Show;
procedure ShowOnTop;
procedure EnsureVisible(AMoveToTop: boolean = true);
function NeedParentForAutoSize: Boolean; override;
function WantChildKey(Child : TControl;
var Message : TLMessage): Boolean; virtual;

View File

@ -701,6 +701,27 @@ begin
end;
end;
procedure TCustomForm.EnsureVisible(AMoveToTop: boolean = true);
var
newLeft, newTop: integer;
begin
newLeft := Left;
newTop := Top;
if newLeft + (Width div 2) > Screen.Width then
newLeft := Screen.Width - Width;
if newLeft < 0 then
newLeft := 0;
if newTop + (Height div 2) + 24 > Screen.Height then
newTop := Screen.Height - Height - 24;
if newTop < 0 then
newTop := 0;
SetBounds(newLeft, newTop, Width, Height);
if AMoveToTop then
ShowOnTop
else
Show;
end;
{------------------------------------------------------------------------------
function TCustomForm.FormUpdating: boolean;
------------------------------------------------------------------------------}