Delphi - 我如何找出组件在“幕后”做什么?
我正在尝试编写一个来自公共组件(TDateTimePicker)的新组件后代。我的最终目标是对 TDateTimePicker 进行子类化,以便当用户输入组件时,“SelText”被设置为 DateTime 的特定部分。
目前,TDateTimePicker 的行为是在再次获得焦点时将焦点集中在最后选定的文本上。我首先想要实现的是找出(查看)当用户聚焦 TDateTimePicker 时实际执行的代码。
我可以看到 TDateTimePicker 是 TCommonCalender 的后代,而 TCommonCalender 又是 TWinControl 的后代。但我尝试在 TWinControl 中的过程上放置断点,但无法到达它们(我猜这是正确的行为,因为许多组件继承自 TWinControl)。
那么我如何知道当用户输入 TDateTimePicker 时发生了什么?运行什么代码?都隐藏了吗?我希望这可以阐明我需要做什么来覆盖默认行为以实现我的目标。
Im attempting to write a new component descendant from a common component (TDateTimePicker). My ultimate goal is to sub-class the TDateTimePicker so that when the user enters the component, the 'SelText' is set to a particular part of the DateTime.
At the moment, the behaviour of the TDateTimePicker is to focus the last selected text when it receives focus again. What i would like to acheive first, is to find out (look at) the code that actually is executed when the user focuses the TDateTimePicker.
I can see TDateTimePicker is a decendant of TCommonCalender which in turn is a decendant of TWinControl. But ive tried placing a breakpoint on procedures in TWinControl and they cannot be reached (which i guess is correct behaviour since a lot of components inherit from TWinControl).
So how do i find out what is happening when the user enters a TDateTimePicker? What code is run? Is it all hidden? I would hope this may shed some light on what i need to do to override the default bahaviour to accomplish my goal.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
TDateTimePicker
是 Windows 标准控件的包装器。 Delphi 包装器只是将消息发送到 Windows 控件,因此无需阅读太多 Delphi 代码。您必须将 TDateTimePicker 视为“黑匣子”。无论其中发生什么,它都是您不应该关心的实现细节。事实上,日期时间选择器的实现细节已经发生了变化,例如,在 Windows 7 中!
TDateTimePicker
is a wrapper around a Windows Standard Control. The Delphi wrapper simply sends messages to the Windows control, so there's not much Delphi code to read.You'll have to treat the TDateTimePicker as a "black box". Whatever happens in there, it's an implementation detail you're not supposed to care about. In fact the implementation details for the Date Time Picker have changed, for example, with Windows 7!
在“项目|选项|编译器”中,选中“使用调试 DCU”并重建应用程序。根据 Delphi 版本的不同,此复选框可以在不同的位置找到,这是针对 Delphi 2007 的。
In Project|Options|Compiler check the 'Use debug DCUs' and the rebuild the application. Depending on the Delphi version this checkbox can be found in different places, this is for Delphi 2007.