Solved

Custom control size change notification?

Posted on 1998-07-10
1
179 Views
Last Modified: 2010-04-04
I am writing a descendant of TCustomControl and my control needs notification when it is resized (at design and run time), what is the easiest way of doing this?
0
Comment
Question by:khenr29j
[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
1 Comment
 
LVL 6

Accepted Solution

by:
Holger101497 earned 100 total points
ID: 1357672
You need to override SetBounds which is called when the size changes (also when assignments to Height, Width, Left, Top are made).
You can do whatever you want before calling the inherited method, even specify different behavior for design mode and runtime...


Here's an example from the Delphi FAQs that shows how to prevent a form from resizing. It should solve your problem as well...:

================ Delphi FAQ:
Preventing Components from Resizing

            Question:

            How can I prevent resizing of my component at design-time?

            Answer:

            Have your constructor  set the default size of the object.
            Override the SetBounds method, and then check the
            component state. If it is in design mode (csDesigning in
            ComponentState) simply pass the default values for width
            and heights to the inherited SetBounds, otherwise you
            pass the parameters unchanged.

            Example:

            procedure TVu.SetBounds(ALeft : integer;
                                    ATop : integer;
                                    AWidth : integer;
                                    AHeight : integer);
            begin
              if csdesigning in componentstate then begin
                AWidth := 50;
                AHeight := 50;
                inherited;
              end;

well, that's the whole sample code... My guess yould be there's an "end" missing after AHeight:=50; but it's also possible that you want to specify other non-standard behavior for runtime-resizing before calling the inherited function...
Good luck!
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

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…
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…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

696 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