Board index » delphi » Force a control to full screen (Like 'Full Screen' function in ACDSee)

Force a control to full screen (Like 'Full Screen' function in ACDSee)

>Emulating full screen mode:

Thanks very much!
It worked just fine.

Re:Force a control to full screen (Like 'Full Screen' function in ACDSee)

I love this type of info but I didn't get it at first. I implemented it and worked on
it until I understood it. Now, I get it but hit a problem that has me confused.  I
added an event method for OnResize and a message handler for WM_MOVE & WM_[H|V]SCROLL
to display the Form, Client and Button coordinates in some static text controls. The
resize & Scroll stuff worked as expeced but the Move stuff caused some odd problems.

First, I cleared all of the Anchors on the button. When the form switches to full
screen, the button is moved slightly (roughly centered). However, when the form
reverts to its original position and size, the button is positioned outside the
original client area causing scroll bars to appear on the form.

My question is "Without anchors, what decides to reposition the controls?". The
button also moves as the form is being resized. Is this a feature of Windows or
something specific to Delphi? I thought the controls would retain their location
relative to the client origin. (But then, why would you need the anchor properties?)
Oddly, this does not happen if I remove the WM_MOVE handler. Any ideas?

Here are some results for the Button's Left & Top position (in screen coordinates)...

                Left      Top
Startup  415       373
Full        450       398
Restore 673       577

Here is the WM_MOVE message handler...

procedure TForm1.WMMove(var msg : TWMMove);
  pt : TPoint;
  Label1.Caption := Format('Form(Left: %d, Top: %d, Width: %d, Height: %d)',
                           [Left, Top, Width, Height]);
  Label2.Caption := Format('Client(Left: 0, Top: 0, Width: %d, Height: %d)',
                           [ClientWidth, ClientHeight]);
  pt := ClientToScreen(Point(Button1.Left, Button1.Top));
  Label4.Caption := Format('ClientToScreen(Button.Left: %d    Button.Top: %d)',
                           [pt.x, pt.y]);

"Peter Below (TeamB)" wrote:
> In article <>, DiSGaTE wrote:
> > I have a control in a form. I want this control being full screen when clicking
> > a button. (Like 'Full Screen' function in ACDSee) How sould I do?

> Emulating full screen mode:

>   private  // in form declaration
>     Procedure WMGetMinMaxInfo(Var msg: TWMGetMinMaxInfo);
>       message WM_GETMINMAXINFO;

> Procedure TForm1.WMGetMinMaxInfo(Var msg: TWMGetMinMaxInfo);
>   Begin
>     inherited;
>     With msg.MinMaxInfo^.ptMaxTrackSize Do Begin
>       X := GetDeviceCaps( Canvas.handle, HORZRES ) + (Width - ClientWidth);
>       Y := GetDeviceCaps( Canvas.handle, VERTRES ) + (Height - ClientHeight );
>     End;
>   End;

> procedure TForm1.Button2Click(Sender: TObject);
> Const
>   Rect: TRect = (Left:0; Top:0; Right:0; Bottom:0);
>   FullScreen: Boolean = False;
> begin
>   FullScreen := not FullScreen;
>   If FullScreen Then Begin
>     Rect := BoundsRect;
>     SetBounds(
>       Left - ClientOrigin.X,
>       Top - ClientOrigin.Y,
>       GetDeviceCaps( Canvas.handle, HORZRES ) + (Width - ClientWidth),
>       GetDeviceCaps( Canvas.handle, VERTRES ) + (Height - ClientHeight ));
>     // Label2.caption := IntToStr(GetDeviceCaps( Canvas.handle, VERTRES ));
>   End
>   Else
>     BoundsRect := Rect;
> end;

> Peter Below (TeamB)
> No e-mail responses, please, unless explicitly requested!

Other Threads