Delphi

Is there a benefit in using old style `object` instead of `class` in Delphi?

假装没事ソ 提交于 2019-12-30 03:11:03
问题 In Delphi sane people use a class to define objects. In Turbo Pascal for Windows we used object and today you can still use object to create an object. The difference is that a object lives on the stack and a class lives on the heap. And of course the object is depreciated. Putting all that aside: is there a benefit to be had, speed wise by using object instead of class? I know that object is broken in Delphi 2009, but I've got a special use case 1) where speed matters and I'm trying to find

Delphi集合数据类型的应用

柔情痞子 提交于 2019-12-30 03:00:24
集合类型的一般形式为: set of 基类型 ; type 集合类型名称 = Set of 基类型; 基类型可以为: 字符型 、 布尔型 、 枚举型 和 子界型 。不能是整型、实型. 1集合中的元素是相异的。(不重复) 2集合中的元素是没有顺序的 3集合中的元素不能超过 256 个 定义集合类型 type days=set of 28..31; ch=set of 'A'..'Z'; weekday=(sun,tue,wed,thu,fri,sat); workday=set of weekday; 集合类型的变量 var ch1,ch2: ch ; wo1,wo2: workday ; d1,d2: days ; 来源: CSDN 作者: 木生火 链接: https://blog.csdn.net/msh2016/article/details/103749172

Why can't I return arbitrary array of string?

淺唱寂寞╮ 提交于 2019-12-30 02:30:32
问题 The compiler allows me to do the following: procedure MyProc(const ADynData: array of string); or procedure MyProc(const ADynData: TStringDynArray); and pass arbitrary data like so: MyProc(['Data1', 'Data2']); However, won't allow function MyFunc: TStringDynArray; .... function MyFunc: TStringDynArray; begin Result := ['Data1', 'Data2']; end; or function MyFunc: TStringDynArray; const CDynData: array[0..1] of string = ('Data1', 'Data2'); begin Result := CDynData; end; Why is this? Isn't this

How to retrieve a file from Internet via HTTP?

你。 提交于 2019-12-30 02:29:05
问题 I want to download a file from Internet and InternetReadFile seem a good and easy solution at the first glance. Actually, too good to be true. Indeed, digging a bit I have started to see that actually there are a lot of issues with it. People are complaining about all kinds of problems when using this code. Problems could appear because: the application freezes temporarily until the HTTP server responds the application freezes temporarily because the Internet connections breaks the

Best Shareware lock for Delphi Win32 [closed]

ぐ巨炮叔叔 提交于 2019-12-30 02:23:05
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . Same intro as my last question: I am re-writing and/or consolidating a bunch of my "app framework" classes (basic mainform, about box, locking routines & purchase linking, auto-update, datamodule initializer, etc) -- Basically, I have a number of small potential shareware apps that I'm wanting to get out the

Detect if Windows closing or application tries to close from system menu (WM_CLOSE)

不打扰是莪最后的温柔 提交于 2019-12-30 02:09:12
问题 I'm having Tray application. Onj FormCloseQuery I check if program should goto tray and instead of closing it I put it in tray (CanClose := False) But if Windows tries to close my application because of Windows shutdown I want not to move my app into tray but to close it. Win7 terminates my app, but XP doesn't close because my app remains in Tray. How can I detect if Windows is some "shutting down" mode or not? Thanks! 回答1: Your problems stem from the use of OnCloseQuery which is the wrong

How do I handle a back-button press in a (Delphi) Android app?

牧云@^-^@ 提交于 2019-12-30 01:55:07
问题 How can I make my Android app react to the back-button? Is there something as high-level VCL's TApplicationEvents to handle it, or do I need to dive deep into low-level Android-specific stuff here? Right now, most of the demo applications have an on-screen back button to go back to a previous screen. Pressing the psysical button always seems to quit the app, and in some situations it results in an access violation. 回答1: In the form's OnKey... events, the Key parameter is vkHardwareBack on

Scroll TTreeView while dragging over/near the edges

巧了我就是萌 提交于 2019-12-30 01:33:27
问题 I have a TTreeView that can have lots of nodes, when a lot of nodes are expanded the tree uses a lot of screen space. Now suppose I want to drag a node that is near the bottom of the TreeView to the top, I can't physically see the top part of the TreeView because the node I am selecting is at the bottom. When dragging the node to the top of the TreeView I would like the TreeView to automatically scroll with me when dragging, by default this does not seem to happen. A perfect example of this

How to create temporary file (0x100) to accelerate application

允我心安 提交于 2019-12-30 01:26:06
问题 I have seen that Windows system use temporary files to increase the performance of some tasks. Those files are marked with the 0x100 attribute when i look at them. I have got the following text from Microsoft: " By using CreateFile() with the FILE_ATTRIBUTE_TEMPORARY flag, you let the system know that the file is likely to be short lived. The temporary file is created as a normal file. The system needs to do a minimal amount of lazy writes to the file system to keep the disk structures

Delphi字符串类型的应用

霸气de小男生 提交于 2019-12-29 22:53:11
1 短字符串( Short String ) 固定长度,最大字符数个数为255, 第0个元素包含了这个字符串的长度(字符串中字符的个数). S: ShortString; { 255个字符长度,256个字节} 可以通过数组的下标来访问ShortString中的一个特定位置的字符. 2 长字符串( Long String ) 长字符串 (AnsiString)是一种动态分配的字符串,其大小只受可用内存的限制, 通过Length函数也可以获得长字符串的长度。 PS: 将一个长度大于 255 的字符串直接赋值给 string 类型的变量就会报上面所说的错误! 3 宽字符串( Wide String ) WideString被实现为2个字节存储一个字符,用WideString来处理多字节字符(比如汉字)。 var WS: WideString; WS := '新华书店'; WS[1] { 显示‘新’} 4 PChar 和 Char 字符数组 Windows 是用 C编写的,在 C 和 C++ 中没有真正的字符串数据类型,都是通过以 Null 结尾( 0)的字符数组来实现。 Pascal 字符串与 Windows兼容,需求 PChar 类型。 var Text: string; Caption: string; begin Text := 'This is a test.'; Caption