mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-09 19:08:03 +02:00
implement TCustomForm.EnsureVisible
git-svn-id: trunk@8557 -
This commit is contained in:
parent
9347949119
commit
a38ed98e25
18
ide/main.pp
18
ide/main.pp
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
------------------------------------------------------------------------------}
|
||||
|
Loading…
Reference in New Issue
Block a user