Solved

Overriding Left property..

Posted on 2001-08-07
6
229 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
  • 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
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…

820 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