Solved

Overriding Left property..

Posted on 2001-08-07
6
225 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
Comment Utility
listening . . .
0
 
LVL 4

Expert Comment

by:fva
Comment Utility
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
Comment Utility
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 4

Expert Comment

by:fva
Comment Utility
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
Comment Utility
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
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

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

6 Experts available now in Live!

Get 1:1 Help Now