delphi-2009

Why doesn't THashedStringList ignore duplicates?

白昼怎懂夜的黑 提交于 2020-01-14 08:09:31
问题 I have the following code: var sl: THashedStringList; begin sl:= THashedStringList.Create; sl.Duplicates := dupIgnore; sl.Add('12345'); sl.Add('12345'); sl.Add('12345'); sl.Add('12345'); sl.Add('12345'); sl.Add('12345'); sl.Add('12345'); ShowMessage(IntToSTr(sl.Count)); end; But when I see sl.Count , it gives me 7. What is the bug in this? 回答1: You need to set the Sorted property to TRUE in order to have the list ignore duplicates. The property is inherited from TStringList , and if you look

Why doesn't THashedStringList ignore duplicates?

你离开我真会死。 提交于 2020-01-14 08:08:06
问题 I have the following code: var sl: THashedStringList; begin sl:= THashedStringList.Create; sl.Duplicates := dupIgnore; sl.Add('12345'); sl.Add('12345'); sl.Add('12345'); sl.Add('12345'); sl.Add('12345'); sl.Add('12345'); sl.Add('12345'); ShowMessage(IntToSTr(sl.Count)); end; But when I see sl.Count , it gives me 7. What is the bug in this? 回答1: You need to set the Sorted property to TRUE in order to have the list ignore duplicates. The property is inherited from TStringList , and if you look

How do I send and handle message between TService parent thread and child thread?

我的梦境 提交于 2020-01-13 06:47:10
问题 I am using Delphi 2010 to create a Windows service that will monitor several registry keys, and perform an action when a change occurs. I am using RegMonitorThread from delphi.about.com, and my issue is that my main service thread never receives the message that is sent from the TRegMonitorThread. type TMyService = class(TService) procedure ServiceExecute(Sender: TService); procedure ServiceShutdown(Sender: TService); procedure ServiceStart(Sender: TService; var Started: Boolean); private

Generics: What's a “CONSTRUCTOR constraint”?

霸气de小男生 提交于 2020-01-11 01:40:27
问题 I made a custom TObjectList descendant designed to hold subclasses of a base object class. It looks something like this: interface TMyDataList<T: TBaseDatafile> = class(TObjectList<TBaseDatafile>) public constructor Create; procedure upload(db: TDataSet); end; implementation constructor TMyDataList<T>.Create; begin inherited Create(true); self.Add(T.Create); end; I want each new list to start out with one blank object in it. It's pretty simple, right? But the compiler doesn't like it. It says

How to track down tricky memory leak with fastMM?

霸气de小男生 提交于 2020-01-10 02:55:47
问题 After upgrading a project from Delphi 2007 to Delphi 2009 I'm getting an Unknown memory leak, so far I've been tryin to track it down using fastMM, here is what fastMM stack trace reports: A memory block has been leaked. The size is: 20 This block was allocated by thread 0x111C, and the stack trace (return addresses) at the time was: 40339E [System.pas][System][@GetMem][3412] 534873 [crtl][_malloc] 56D1C4 [canex.cpp][MidasLib][DllGetDataSnapClassObject][3918] 56D316 [canex.cpp][MidasLib]

Menu Accelerator Keys Not Showing Up (Delphi 2009)

浪尽此生 提交于 2020-01-09 10:09:19
问题 I've tried my best and cannot figure out what happened here. It worked fine in Delphi 4. After upgrading to Delphi 2009, I don't know if this is the way it is supposed to work, or if it's a problem: This is what my program's menu looks like in Design Mode under Delphi 2009: Notice that every word in the Main Menu and the File submenu have one letter underlined. It is supposed to be like this. This underlined letter is called the Accelerator Key and is standard in Windows applications so that

Menu Accelerator Keys Not Showing Up (Delphi 2009)

拈花ヽ惹草 提交于 2020-01-09 10:09:15
问题 I've tried my best and cannot figure out what happened here. It worked fine in Delphi 4. After upgrading to Delphi 2009, I don't know if this is the way it is supposed to work, or if it's a problem: This is what my program's menu looks like in Design Mode under Delphi 2009: Notice that every word in the Main Menu and the File submenu have one letter underlined. It is supposed to be like this. This underlined letter is called the Accelerator Key and is standard in Windows applications so that

Strange memory overwrite problem in instance of my class

99封情书 提交于 2020-01-04 06:20:21
问题 This problem is related to this question, which I've asked earlier. The code provided by @RRUZ is working but it seems that not quite correctly or I am doing something wrong. After executing GetSharedFiles strange thing is happening in instance of TMyObject . The field FMyEvent which was (and it should be) nil points to some random data. What I've discovered just 5 minutes ago is that if I turn off the optimization in compiler options it works fine after rebuild. So maybe this is some

Delphi 2009 using MSBuild in RAD Studio Command Prompt F1026 File not found

一个人想着一个人 提交于 2020-01-04 02:11:52
问题 I have been struggling to get the MSBuild to successfully build my .dproj file for the last few days on a build machine. First, I needed the EnvOptions.proj file from the developer's machine, which got me clear of the missing system.pas file, but now I am getting a compile error for a missing .dcu C:\Program Files\CodeGear\RAD Studio\6.0\Bin\CodeGear.Delphi.Targets(123,3): error : myproject.dpr(17) Fatal: F1026 File not found: 'mymissing.dcu' Now the path to "mymissing.dcu" is included in the

How can i create a new instance of a class?

…衆ロ難τιáo~ 提交于 2020-01-03 03:13:08
问题 i have a list of class instances of various kinds. i need to be able to create a new instance of a class without knowing for sure what to create. all the objects involved have the same ancestor. the actual copying of the object's member variables is easy...it's the creation of the new object where i have a problem. admittedly i could do something like this: case MyObjectTypeInstance.MyTypeEnum of obj1: Result:=TObjectType1.Create; obj2: Result:=TObjectType2.Create; obj3: Result:=TObjectType3