Solved

Custom control size change notification?

Posted on 1998-07-10
1
172 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
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
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…

762 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

22 Experts available now in Live!

Get 1:1 Help Now