开发者

Someway to override Delphi default procedures at Design Time?

Someway to override Delphi default procedures at Design Time ?

I need to override the InstanceSize at design time, I did it run开发者_StackOverflow中文版time using FastCode method:

FastcodeAddressPatch(FastcodeGetAddress(@SInstanceSize), @TWinControl.RfInstanceSize);

But, is there some way to do it at Design time ?

Tks in advice


"Design time" is really just "run time," but in the context of the IDE instead of the context of your program. Put your code in a design-time package and load it in the IDE. The IDE will call all the Register procedures in your package's units, at which time you can run whatever code you need.

  1. Make a new package project (.dpk file).
  2. Set project preferences so it's a design-time package.
  3. Add a new, blank unit to it.
  4. Add a procedure to the interface section named Register. It must have a capital R and the rest lowercase.
  5. Implement that procedure however you want (such as by putting your call to FastcodeAddressPatch there).
  6. Compile and install the package.

I'm a little wary about what it looks like you're trying to do in step 5, but I'll let you work that out for yourself.


If by "at design-time" you mean "change the way your components behave while in the Form Designer", that's something you really shouldn't be trying to do. The Form Designer is part of the IDE, which is all Delphi code being run in BDS.exe. If you alter TObject under the Form Designer, you alter it for the entire IDE, with potentially disastrous results.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜