delphi-2009

Comparing Time Values

半城伤御伤魂 提交于 2019-12-01 01:51:31
I want a method which compares the times, eg if Atime occurs earlier than Btime do something, I would use a CompareTime Function but my problem with this function is what is said in "Bold Brackets" (see below) Call CompareTime to compare the two TDateTime values specified by A and B. CompareTime returns: LessThanValue if A occurs earlier in the day than B ( even if A occurs on a later day than B ). GreaterThanValue if A occurs later in the day than B (even if A occurs on an earlier day than B ). A TDateTime values can be thought of as containing two distinct parts: the date part and the time

Pass parameters to Synchronize procedure call

无人久伴 提交于 2019-12-01 00:46:41
When creating a thread object, I want to call code from the application that needs to be synchronized. The problem is that I don't know how to call Synchronize for an application function with parameters. Say we have procedure ThreadObject.Execute; var val1,val2:integer; Star:string; begin Synchronize(funcyfunc); //how to pass val1,val2,star here? end; where funcyfunc is defined as follow procedure OtherClass.funcyfunc(param1,param2:integer;spok:string); begin letsCallFriends(spok,param1); letsCallFriends(spok,param2); end; now the odd solution to this would be to say in ThreadObject private

Implicit cast for overloaded record in Delphi as a parameter in a const array

最后都变了- 提交于 2019-11-30 22:25:57
We got rid of shortstring as part of a conversion from Delphi 7. I wanted to make it as painless as possible so we figured we could change the ShortString to some record which acted in the same way. Here's how it's declared (there's more to it, but this is the basic structure, which outlines the problem): TShortStringRec = record private FStuff: array [0..49] of Char; public class operator Implicit(AStuff: TShortStringRec): String; class operator Implicit(S1: String): TShortStringRec; end; This works well for setting strings to the record. But then there's functions like format which take as

Pass parameters to Synchronize procedure call

情到浓时终转凉″ 提交于 2019-11-30 19:11:51
问题 When creating a thread object, I want to call code from the application that needs to be synchronized. The problem is that I don't know how to call Synchronize for an application function with parameters. Say we have procedure ThreadObject.Execute; var val1,val2:integer; Star:string; begin Synchronize(funcyfunc); //how to pass val1,val2,star here? end; where funcyfunc is defined as follow procedure OtherClass.funcyfunc(param1,param2:integer;spok:string); begin letsCallFriends(spok,param1);

“ERROR MSB4040 There is no target in the project” when using msbuild+Delphi2009

蓝咒 提交于 2019-11-30 18:14:37
I'm trying to automate the build of a project in Delphi 2009. I'm using msbuild with .net 3.5 I simply call: Z:\Server>C:\WINDOWS\Microsoft.NET\Framework\v3.5\msbuild "BestSellerAppServer.g roupproj" /target:Build And get this: Build started 27/08/2009 01:15:45 p.m.. Project "Z:\Server\BestSellerAppServer.groupproj" on node 0 (Build target(s)). Project "Z:\Server\BestSellerAppServer.groupproj" (1) is building "Z:\Server\Be stSellerAppServer.dproj" (2) on node 0 (default targets). Z:\Server\BestSellerAppServer.dproj : error MSB4040: There is no target in the project. Done Building Project "Z:

Thread Error: The Handle is Invalid (6) when trying to Free a suspended thread

你离开我真会死。 提交于 2019-11-30 15:11:20
问题 In a given example I am receiving an exception when calling AThread.Free. program Project44; {$APPTYPE CONSOLE} uses SysUtils, Classes, Windows; type TMyException = class(Exception); var AThread: TThread; begin AThread := TThread.Create(True); try AThread.FreeOnTerminate := True; //I want to do some things here before starting the thread //During the setup phase some exception might occur, this exception is for simulating purpouses raise TMyException.Create('exception'); except AThread.Free;

What data does a TObject contain?

a 夏天 提交于 2019-11-30 15:07:28
问题 TObject.InstanceSize returns 8, yet TObject doesn't declare any data members. According to the implementation of TObject.ClassType, the first 4 bytes can be explained as a pointer to the object's TClass metadata. Anyone know what the other 4 bytes of overhead are there for? EDIT: Apparently this is specific to D2009. In older versions, it's only 4 bytes. 回答1: In Delphi 2009, there is the ability to have a reference to a synchronization monitor. See: class function TMonitor.GetFieldAddress

ADODataSet deleting from joined table

为君一笑 提交于 2019-11-30 14:43:15
I have a Delphi app where I display a list of games that have been played from a query like this: select g.*, gt.id, gt.descr from GAMES g inner join game_types gt on gt.id = g.game_type order by game_date DESC When I click the delete button in the DBNavigator, the joined record from the game_types table is also deleted. That's a problem because many other games can be of the same type. What do I need to do to make it so that only the game is deleted but not the game type? You need to use the Unique Table dynamic property ADOQuery1.Properties['Unique Table'].Value := 'GAMES'; From the MSDN ADO

Registering a custom Frame

眉间皱痕 提交于 2019-11-30 14:18:00
问题 In Delphi 2009, In one of my projects, I have a custom frame with some controls on it which I want to use as the base class for some other controls. I want to register this frame as an IDE wizard to be available in New Items list. When I add my newly added item (my custom frame) to a project, I expect it to: Show all the properties and events I added to the custom frame in object inspector. Derive the newly created frame from my custom frame rather than TFrame. Ok, to make it show my

Thread Error: The Handle is Invalid (6) when trying to Free a suspended thread

混江龙づ霸主 提交于 2019-11-30 13:42:07
In a given example I am receiving an exception when calling AThread.Free. program Project44; {$APPTYPE CONSOLE} uses SysUtils, Classes, Windows; type TMyException = class(Exception); var AThread: TThread; begin AThread := TThread.Create(True); try AThread.FreeOnTerminate := True; //I want to do some things here before starting the thread //During the setup phase some exception might occur, this exception is for simulating purpouses raise TMyException.Create('exception'); except AThread.Free; //Another exception here end; end. I have two questions: How should I free AThread instance of TThread