Solved

Overriding Left property..

Posted on 2001-08-07
6
230 Views
Last Modified: 2010-04-06
In the question
http://www.experts-exchange.com/jsp/qShow.jsp?qid=20164439
The problem of being notified when the left property is changed is raised. In particular, when placing the component in the form, I would like to have an event happen or an overriden Setleft procedure. I hope experts will try to answer that question..
0
Comment
Question by:karouri
[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
  • 4
6 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6359379
listening . . .
0
 
LVL 4

Expert Comment

by:fva
ID: 6359576
If you take a look at the VCL code you will notice lots of references to the Left property of all kinds of derivatives to TControl/TWinControl and that means you are not safe by just overriding SetLeft without making it virtual in the first place (in TControl).
Since the design of VCL does not allow for overriding properly the SetLeft (as a virtual method) I guess you're stuck. The quick hack would be to take the VCL source, change the definition of SetLeft in TControl to be a protected virtual method and then derive it to your pleasure. Of course, it has the drawback of a fully "custom" VCL which might cause you all kind of other problems and it might be a little tricky to get it compiled.

F.
0
 
LVL 4

Accepted Solution

by:
fva earned 300 total points
ID: 6359616
And yet I might be wrong.

Suggestion 1:
Capture the WM_WINDOWPOSCHANGED message. This one should be sent by Windows when the pos changes and it _is_ sent by VCL to self when SetBounds is called, but with fake params.

Suggestion 2:
Override SetBounds itself (which is virtual already in TControl) and devise your own logic to detect the wanted change.

F.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:fva
ID: 6359647
If you think any of the above is worth and you need further details, please say so.

F.
0
 
LVL 3

Author Comment

by:karouri
ID: 6360346
Actually both of your suggestions are sensible.
I have tested SetBounds overriding and it works, so I give you the points, though it is much more probable that I will capture the message in my work.
I have refrained from using SetBounds in the past because it does not allow you to modify Left or Top, while OnConstrainedResize is not conerned with Left and Top to modify them. The amazing thing is all you need is to pass your own values to inherited SetBounds..Sometimes one just,umm, oversee things;)
* Just to know, Can one modify the values of the WINDOWPOS record passed in the message to change Left or Top?

btw, I increased the points a little because it was very important to me and, well I have some points to spare
0
 
LVL 4

Expert Comment

by:fva
ID: 6360408
Thanks.

You should use WM_WINDOWPOSCHANGING to adjust the values. By the time WM_WINDOWPOSCHANGED comes in I think it would be too late to require a change.

F.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

739 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