Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

"Smooth" resizing for windows...

Posted on 1998-06-20
9
Medium Priority
?
424 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 100 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

721 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