有用的 Delphi 代码模板

发布于 2024-07-21 05:41:42 字数 183 浏览 8 评论 0原文

我用 Delphi 编程已经两年多了,我大概只有 5 个自定义模板,我觉得我应该有更多。

如果有人有任何特别有用的东西,那么在 stackoverflow 上有一个很好的存储库就太好了。

我不在乎您使用的是 Delphi 2009 语法还是 Delphi 7,但如果您要生成的代码仅适用于特定版本,请注明这一点。

I've been programming in Delphi for a little over two years now, and I've only got maybe 5 custom templates, I feel as though I should have more.

If anyone has any particularly useful ones it would be great to have a nice repository of them here on stackoverflow.

I don't care whether you use the Delphi 2009 syntax or Delphi 7, but if the code you'd be generating only works on a particular version, please mention that.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

陌路终见情 2024-07-28 05:41:43

我做了一些节省了我很多时间的事情。 其中一些使财产申报不再单调。 然后我做了一些创建类型安全的枚举器、对象列表和存储桶列表。 我可能也应该为收藏做一个,但还没有。

这些都可以在我的博客上找到。

I did a couple that saved me lots of time. A few of those took the monotone out of property declarations. Then I did some to create type-safe enumerators, object lists and bucket lists. I probably should do one for collections too, but haven't yet.

These are all available on my blog.

淡水深流 2024-07-28 05:41:42

这里有一些有用的,包括一些基于 CodeRush 的。 这些是实时模板,因此它们可以在 Delphi 2006 及更高版本中使用。

http://delphi.wikia.com/wiki/Delphi_Live_Templates

There are a handful of useful ones here, including a few based on CodeRush. These are the live templates, so they work in Delphi 2006 and up.

http://delphi.wikia.com/wiki/Delphi_Live_Templates

七色彩虹 2024-07-28 05:41:42

非常方便的输出调试字符串以及格式


名称:
消耗臭氧层物质
描述:
输出带有格式的调试字符串
代码:

OutputDebugString(PAnsiChar(format('|',[])));

另外,如果我想将其保留在代码中:

名称:
道兹
描述:
使用 ifdef debug 输出调试字符串
代码:

{$IFDEF DEBUG}   
   OutputDebugString(PAnsiChar(format('|',[])));   
{$ENDIF}

Very handy output debug string plus formatting


Name:
ods
Description:
Output Debug String with Format
Code:

OutputDebugString(PAnsiChar(format('|',[])));

also, if I want to leave it in the code:

Name:
dods
Description:
Output Debug String with ifdef debug
Code:

{$IFDEF DEBUG}   
   OutputDebugString(PAnsiChar(format('|',[])));   
{$ENDIF}
淡看悲欢离合 2024-07-28 05:41:42

这个非常方便,因为当我按下 ctrl-j 时它总是首先出现(所以我的快捷键是 ctrl-j Enter)


名称:
//*
描述:
评论专线
代码:

//******************************************************************************  

我用它来启动有关方法的文档。 它肯定比敲击 78 次“*”要好。

This one is pretty handy because it always shows up first when I hit ctrl-j (so my shortcut is ctrl-j enter)


Name:
//*
Description:
Comment Line
Code:

//******************************************************************************  

I use it to start documentation around methods. It sure beats hitting '*' 78 times.

那支青花 2024-07-28 05:41:42

如果您在数据集上做了很多工作,那么这些会很方便。

姓名:
fbn

描述:
数据集字段按名称

|DataSet|.FieldByName( '|Field|' )|end|

名称:
pbn

描述:
数据集参数按名称

|DataSet|.ParamByName( 'P_|Param|' )|end|

If you do a lot of work on datasets these are handy.

Name:
fbn

Description:
DataSet FieldByName

|DataSet|.FieldByName( '|Field|' )|end|

Name:
pbn

Description:
DataSet ParamByName

|DataSet|.ParamByName( 'P_|Param|' )|end|
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文