delphi-2009

How to start building a searchable garbage collector in Delphi (2009-2010)

浪子不回头ぞ 提交于 2019-12-07 02:26:58
问题 I'm looking for a way to control all business objects I create in my applications written in Delphi. As an article on Embarcadero's EDN (http://edn.embarcadero.com/article/28217) states, there are basically three ways to do this. I'm mostly interested in the last one, using interfaces. That way, when the business object is no longer being referenced anywhere in the application, it will be dispose of memory wise (I'll get back on this part later). When creating a new business object, it would

How to get a tree view item by the hit test when RTL layout is used?

梦想的初衷 提交于 2019-12-07 01:27:31
问题 Description: Having a tree view in right-to-left reading mode (RTL), how to get node that was clicked knowing just the click coordinates ? Here is an interposed class, that makes the tree view to use the RTL display and that contains a click handler in which you can see the problem: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ComCtrls, CommCtrl; type TTreeView = class(ComCtrls.TTreeView) protected procedure CNNotify(var Msg:

Abstract Class in Delphi

戏子无情 提交于 2019-12-06 17:48:06
问题 I am using a component suite which has many abstract classes. Now I want to apply polymorphism but I am getting Error Abstract Class when I create my object. Should I override all methods which are virtual even if I don't need it? Are there any workaround or solution? 回答1: In order to make an instance of a class, you need to override all methods that are declared as virtual abstract. Even if you don't use them. If you really want a work around, you can use empty methods. But I won't recommend

Which dbExpress ServerCharSet do I need for utf8 data in MySQL 5?

喜你入骨 提交于 2019-12-06 16:02:46
We tried ServerCharSet=utf8 and ServerCharSet=UTF8 , based on information found in newsgroups - but still, special characters / Umlauts do not appear correctly in the client data. We use Delphi 2009 and the built-in dbExpress driver. Field data is retrieved using AsWideString. you have to set up a client charset. Simple " SET NAMES utf8 " query, executed right after connect, will do the trick 来源: https://stackoverflow.com/questions/3598593/which-dbexpress-servercharset-do-i-need-for-utf8-data-in-mysql-5

How can I detect if a Delphi class has a virtual constructor?

情到浓时终转凉″ 提交于 2019-12-06 14:10:38
For example, is there a way to find out that this class has a virtual constructor (at runtime)? TMyClass = class(TObject) MyStrings: TStrings; constructor Create; virtual; end; For example, in this code I would like to test if the class referenced by Clazz has a virtual constructor: procedure Test; var Clazz: TClass; Instance: TObject; begin Clazz := TMyClass; Instance := Clazz.Create; end; Is there a simple solution, for example using RTTI, which works in Delphi 6 to 2009? Mason Wheeler Looking through the TypInfo unit, it doesn't look like there's any way to tell if a method is virtual using

Delphi Pascal - Using SetFilePointerEx and GetFileSizeEx, Getting Physical Media exact size when reading as a file

扶醉桌前 提交于 2019-12-06 13:33:49
I do not know how to use any API that is not in the RTL. I have been using SetFilePointer and GetFileSize to read a Physical Disk into a buffer and dump it to a file, something like this in a loop does the job for flash memory cards under 2GB: SetFilePointer(PD,0,nil,FILE_BEGIN); SetLength(Buffer,512); ReadFile(PD,Buffer[0],512,BytesReturned,nil); However GetFileSize has a limit at 2GB and so does SetFilePointer. I have absolutley no idea how to delcare an external API, I have looked at the RTL and googled for many examples and have found no correct answer. I tried this function GetFileSizeEx

convert function to delphi 2009/2010 (unicode)

喜你入骨 提交于 2019-12-06 12:25:15
问题 I'm slowly converting my existing code into Delphi 2010 and read several of the articles on Embarcaedro web site as well as Marco Cantú whitepaper. There are still some things I haven't understood, so here are two functions to exemplify my question: function RemoveSpace(InStr: string): string; var Ans : string; I : Word; L : Word; TestChar: string[1]; begin Ans := ''; L := Length(InStr); if L > 0 then begin for I := 1 to L do begin TestChar := Copy(InStr, I, 1); if TestChar <> ' ' then Ans :=

Delphi Generic constraints problem

扶醉桌前 提交于 2019-12-06 11:00:49
问题 I am trying to create a generic list class for use with tiOPF (an Object Persistence Framework for delphi @ www.tiopf.com). Specifically I am trying to take an existing generic class (TtiObjectList) and make a generic version that uses TtiObject descenants. I have limited scope for altering the base classes as they need to compile under D7 - D2009 and Free Pascal. I need to descend from TtiObjectList to keep the existing persistence mechanisms working. // base class type TtiObjectList = class

How to create a console application that does not terminate?

半腔热情 提交于 2019-12-06 10:54:56
问题 In C++,a console application can have a message handler in its Winmain procedure.Like this: int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { HWND hwnd; MSG msg; #ifdef _DEBUG CreateConsole("Title"); #endif hwnd = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, DlgProc); PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE); while(msg.message != WM_QUIT) { if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if(IsDialogMessage(hwnd, &msg)) continue;

.NET component in DELPHI 2009

别等时光非礼了梦想. 提交于 2019-12-06 09:59:08
问题 Could you please tell me if .NET component can be used with Delphi 2009 and, if so, could you please send me some example code. Thanks in advance. 回答1: Not in delphi for Win32. You can use Delphi PRISM for this. You can also check CrossTalk or Hydra 回答2: There are several ways of doing it and traditional COM/Interop is just one way to do it. Another way is to use the already existing infrastructure that is built into the CLR to support COM/Interop and mixed-mode C++/CLI. The CLR has excellent