Solved

"Smooth" resizing for windows...

Posted on 1998-06-20
9
411 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

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…
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…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now