Link to home
Start Free TrialLog in
Avatar of Ronald112197
Ronald112197Flag for Germany

asked on

"Smooth" resizing for windows...

How do I "nicely" reposition all the controls in a window when it is resized?
I do have everything I need in the "onResize" handler, but depending on the Windows-settings, the window is constantly redrawn while being resized (i.e. for each pixel). That caused significant flickering and doesn't look nice at all!

Another problem is that I need to set a "minimum window size" - I currently do this by setting ClientHeight to a certain value if it is too small (IF ClientHeight<x THEN ClientHeight:=x;). This as well works but looks ugly, because Windows first resizes the window to the smaller size before my program resets it. The mouse being above the lower window border, the border jumps forth and back between the mouse position and my required minimum size.

Any good ideas?
Avatar of Matvey
Matvey

The seccond problem can be solved by a component in the RX lib: http://rx.unionjv.ru, that limits the window bounds.

The first problem:

Try not setting all the values one by one like Height:=...; width:=...; but using SetBounds.

Drop comments...
or bosism@netvision.net.il
ASKER CERTIFIED SOLUTION
Avatar of BoRiS
BoRiS

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ronald112197

ASKER

Boris: That only answers the first part of my question, not the second part. Where would I find information about LockWindowUpdate? I can't find it in the help files :-( How do I unlock it? (I would guess UnlockWindowUpdate, but that's not found)

Matvey: Netscape can't locate http://rx.unionjv.ru !

ronit: I paid 20 points to see the PAQ you suggested but I don't really see how that relates to this question. It's only 3 comments - would have been really nice of you to copy them and post them here!


ronald

the lockwindowupdate is an API call it's in the win32 help file...as for unlocking it, it works by passing the lockwindowupdate with no parameters etc...

As for your secound question use the redrawWindow Api call also available in the win32 help file(you could use the redrawWindow for both question as well)

Later
BoRiS

Maybe you can't access it for some reason, but the address I posted exists. Other homepage: http://rx.demo.ru, you can also download it from any Torry's page mirror, for example: http://bes.trendline.co.il/torry/vcl/packs/rxlib.zip

-Enjoy

Smooth resizing: I think TForm.SetBounds should be working smooth enough.
The problem with TForm.Setbounds is that it is not called while the window is being resized with the mouse! I'm not sure if it's called when the user releases the mouse... might be...
Hello Ronald!

I have some good news about limiting the size of the window:
This is copied from Delphi Technical information and tells you how to do it. They agree with you: Doing it in OnResize works, but doesn't look as good :-)))

==================
When you want to control how much your users can resize your
form, you can control that by setting the MinMax values.  (If
you use the resize method to limit the size, it will work, but
it won't look quite as good.)

Note:  To make it so that the user cannot change the form's
size at all, make the min and max sizes the same values.

This is an example of how to declare and use the wm_GetMinMaxInfo
windows message in your applications.

unit MinMax;

interface

uses
  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  Forms, Dialogs;

type
  TForm1 = class(TForm)
  private
    { Private declarations }
    procedure WMGetMinMaxInfo(var MSG: Tmessage); message WM_GetMinMaxInfo;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.WMGetMinMaxInfo(var MSG: Tmessage);
Begin
  inherited;
  with PMinMaxInfo(MSG.lparam)^ do
  begin
    with ptMinTrackSize do
    begin
      X := 300;
      Y := 150;
    end;
    with ptMaxTrackSize do
    begin
      X := 350;
      Y := 250;
    end;
  end;
end;

end.
==============
Good luck! This one should work great!
Hey Ronald!
Have you tried it? Does it work for you?