delphi-xe2

Can I detect the build target in a build event?

烈酒焚心 提交于 2019-12-06 05:05:59
问题 I would like to detect the build target, i.e. make or build , in a build event. I have pre-build event that compiles a number of C files into objects (.obj) which are then included in one of my Pascal files. At the moment the C files are compiled every time the pre-build event runs. I would like to be able to skip this stage if the build target is make and if the objects are up-to-date. Being able to skip this stage would give me significant reductions in compile time whilst in edit/compile

Multi-threading Delphi synchronization using Critical Sections between a Timer and other threads

只谈情不闲聊 提交于 2019-12-06 03:13:21
问题 It is a problem of synchronization. I made a simplification for my problem so I have a VCL Timer and a few threads. The threads are trying to write things in two bitmaps, and the timer is trying to draw the bitmaps into Images(TImage). Here is a modification of my code to be easier to understand(this paste code is very vague). //------------------------------------------------------------------------------ Procedure TMyForm.Add(iX,iY,iNr:integer); begin EnterCriticalSection(csCriticalSection)

Using conditionals in project's main unit - IDE destroys code

依然范特西╮ 提交于 2019-12-06 02:11:00
I'm building a windows service application which has a configuration to compile it as a basic windows application. The main project file for the exe includes conditionals which determine whether the project is being compiled as a service application or as a windows forms application. The problem is, when I do something which makes the project code change, the code gets destroyed and broken. For example, a line which says Application.Initialize; becomes AppliApplication.Initialize; and the line which has {$R *.RES} gets cut down to S} , and most of my conditionals get deleted. I'm wondering if

Conditionally compile units for FMX or VCL

☆樱花仙子☆ 提交于 2019-12-06 01:27:25
问题 I want to have a different list of units in the uses clause depending on compiling for FMX or VCL. In the code below I try to test FireMonkeyVersion which works in an FMX project ( label1.Text is 'FMX'). When I move the $IF statement into the uses clause I get an error message ( [dcc32 Error] fmx_text.pas(7): E2026 Constant expression expected ). Is there any way to get the desired conditional compilation? unit fmx_text; interface uses System.SysUtils, System.Types, System.UITypes, System

How to apply a vcl style hook to a particular component of a form?

旧城冷巷雨未停 提交于 2019-12-06 01:08:31
I'm using the vcl style hook of the answer to this question close button of a tabsheet not supporting vcl styles and is working fine, but the close button is draw in all the TPageControl components of my app. And I want add this option (draw the close button) to only a particular form. The question is : how I can apply this hook or any vcl style hook just to the TPageControl of a specific form? You can use a interposer class for the TPageControl component check this sample type TPageControl = class(Vcl.ComCtrls.TPageControl); TForm1 = class(TForm) PageControl1: TPageControl; ... ... And then

List and Contains method

人走茶凉 提交于 2019-12-06 00:51:59
i have this problem: starting from an empty list (0 elements) i want check if an element is present or not present in this list. In case this record not is present in list then i add this record to list, otherwise update element in list. I have tried writing this code: program Project1; {$APPTYPE CONSOLE} {$R *.res} uses System.SysUtils, System.Generics.Collections, System.Generics.Defaults; type TDBStats = record Comb: Integer; Freq: Integer; end; TDBStatsList = TList<TDBStats>; procedure Add(ODBStats: TDBStatsList; const Item: TDBStats); var rItem: TDBStats; begin rItem := Item; rItem.Freq :

How to automatically initialize / uninitialize something globally for every thread?

六眼飞鱼酱① 提交于 2019-12-06 00:37:28
I have a unit with an initialization and finalization section. This unit contains a complex object which is instantiated in the initialization and destroyed in the finalization . However, this object also contains an ADO Connection. That makes it an issue when using this across threads, because ADO is COM, and needs to be initialized for every thread. This is how I currently handle this global object instance: uses ActiveX; ... initialization CoInitialize(nil); _MyObject:= TMyObject.Create; finalization _MyObject.Free; CoUninitialize; end. This only works on the main thread. Any other thread

How to install DWSScript

喜你入骨 提交于 2019-12-05 22:58:56
I am having trouble installing DWSScript component. I am using Delphi XE2 and when I try to compile the dwsLibRuntime.dpk I get an error ( Array type required ). I am using the latest DWScript source pulled from the project's svn repo. What am I doing wrong? toStr:=TStringListCracker(sl).FList[i].FString; //produces error System.MonitorExit(sl); You're not using the latest version, the monitor isn't used anymore (due to contention bugs in the RTL implementation), the second line should read as "sl.FLock.Leave;". You're likely on a pre-Delphi XE2 version, as the Monitor was dropped in february

Is VclStyle Bug ? TProgressBar.Style := pbstMarQuee Does not work

ぃ、小莉子 提交于 2019-12-05 22:45:39
问题 Is VclStyle Bug ? T^T I tried to find BugFix list(http://edn.embarcadero.com/article/42090/) but I can't File > New > VCL Application TProgressBar put main form >TProgressBar.Style := pbstMarQuee Project Option > Appearence > set Custom Style > set Default Style Ctrl + F9 ProgressBar does not work Sorry. My english is bad :( 回答1: This is a feature not implemented in the TProgressBarStyleHook. Unfortunally Windows does not send any message to the progress bar control to indicate if the

Delphi SOAP Client can not keep more than 2 concurrent requests. How to increase?

隐身守侯 提交于 2019-12-05 22:37:08
问题 I have a multi-user COM+ application that needs to make multiple requests on SOAP WebServices. Each SOAP request may last from 10 to 60 seconds (that is not under my control). Problem is, I can never make more than 2 requests at the same time. When I have, for example, 3 concurrent requests the third requests only starts when the second one finishes. I watched the same behaviour on a console application (for testing purposes) making multiple concurrent requests to the same WebService, and I