[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Custom control size change notification?

Posted on 1998-07-10
1
Medium Priority
?
181 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
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

649 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