?
Solved

Custom control size change notification?

Posted on 1998-07-10
1
Medium Priority
?
180 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 400 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

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.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses
Course of the Month10 days, 6 hours left to enroll

765 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