Solved

"Smooth" resizing for windows...

Posted on 1998-06-20
9
416 Views
Last Modified: 2010-04-04
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?
0
Comment
Question by:Ronald112197
  • 2
  • 2
  • 2
  • +2
9 Comments
 
LVL 3

Expert Comment

by:Matvey
ID: 1354515
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
0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1354516
0
 
LVL 4

Accepted Solution

by:
BoRiS earned 50 total points
ID: 1354517
ronald

use the LockWindowUpdate API Call...

The LockWindowUpdate function disables or reenables drawing in the specified window. Only one window can be locked at a time.

like this LockWindowUpdate(Form1.Handle);

you can also trap the begin paint etc.
Check the rest out in the API help...

Later
BoRiS
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 2

Author Comment

by:Ronald112197
ID: 1354518
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!


0
 
LVL 4

Expert Comment

by:BoRiS
ID: 1354519
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

0
 
LVL 3

Expert Comment

by:Matvey
ID: 1354520
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.
0
 
LVL 2

Author Comment

by:Ronald112197
ID: 1354521
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...
0
 
LVL 6

Expert Comment

by:Holger101497
ID: 1354522
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!
0
 
LVL 6

Expert Comment

by:Holger101497
ID: 1354523
Hey Ronald!
Have you tried it? Does it work for you?
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…

839 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