Solved

"Smooth" resizing for windows...

Posted on 1998-06-20
9
414 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

776 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