delphi-xe2

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

廉价感情. 提交于 2019-12-22 10:24:02
问题 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? 回答1: You can use a interposer class for the TPageControl component check this sample type

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

别说谁变了你拦得住时间么 提交于 2019-12-22 09:53:42
问题 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;

How to install DWSScript

本秂侑毒 提交于 2019-12-22 09:49:59
问题 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); 回答1: 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

Firemonkey Grid Control - Aligning a column to the right

允我心安 提交于 2019-12-22 05:31:26
问题 I am using the FireMonkey Grid control but have an on-going issue in trying to right align a column. From other users postings, I have managed to create a new TColumn type, apply a style to this (text as HorzAlign=taTrailing) and in theory - thought that this would be solution. The values are provided by the OnGetValue function to the Grid control. The problem is however that although at first it looks OK, if you scroll the bar/mouse wheel etc. the new TColumn type column does not appear to

How to hide a protected procedure of an object?

痞子三分冷 提交于 2019-12-22 05:12:08
问题 In one base class, there's a protected procedure. When inheriting that class, I want to hide that procedure from being used from the outside. I tried overriding it from within the private and even strict private sections, but it can still be called from the outside. The Original class is not mine, so I can't change how TOriginal is defined. Is it possible to hide this procedure in my inherited class? And how? type TOriginal = class(TObject) protected procedure SomeProc; end; TNew = class

Which wait method to call in an infinite waiting thread for Delphi XE2

大憨熊 提交于 2019-12-21 20:45:40
问题 if I've got a While not terminated do begin doStuff; end loop in the execute method of a Delphi XE2 thread, and I want to not make it bogart all my flops. What should I call, in Delphi 7, it was easy, I'd call Sleep(X) where X was inversely proportional to how interesting I thought the thread was. But now, I've got SpinWait(X); Which calls YieldProcessor X number of times and Yield; which calls the windows function "SwitchToThread". Should I use any of these or should I just set the priority

Can I define MyType that can contain only these values?

醉酒当歌 提交于 2019-12-21 18:00:31
问题 I have this problem: if I have, for example, these values: 'AA', 'AB', 'AC', 'BC' - can I define MyType that can contain only these values? I want to do in mode that: type MyType = ... ; // something var X: MyType; begin x := 'AA' ; // is valid, 'AA' is included in X X := 'SS' ; // not valid, 'SS' not is included in X, than raise an exception. end; How can I solve it? Is there some solution directly using type data? 回答1: This is actually rather simple using operator overloading. Do type

TIdHttp.Post - can't get utf-8 encoding

混江龙づ霸主 提交于 2019-12-21 17:46:08
问题 How can I force TIdHttp.post method to return the web page encoded in utf-8? I tried http.Request.ContentEncoding := 'UTF-8' but it doesn'twork. Here's my code: procedure TeUpdateNews.Check; var url: string; Http: TIdHttp; SS: TStringStream; param: TStringList; SWIDESTRING: WideString; begin http := TIDHttp.Create(nil); http.HandleRedirects := true; http.ReadTimeout := 5000; http.Request.ContentEncoding := 'UTF-8'; param := TStringList.create; param.Clear; url := CONST_SOME_WWW; try SS :=

OutputDebugString() with Delphi for MacOS

守給你的承諾、 提交于 2019-12-21 17:24:25
问题 Is there an NSLog declaration in the Delphi OSX units. I failed to find a substitude for OutputDebugString in a Firemonkey application. The final solution looks like this: /// <remarks> /// Output debug string. Output debug string can be seen in Delphi /// View|Debug Windows|Event Log or with 3-rd party programs such as /// dbgview.exe from SysInternals (www.sysinternals.com) /// </remarks> procedure ODS(const Text: string); begin {$IFDEF MACOS} // http://stackoverflow.com/questions/12405447

Delphi/ASM code incompatible with 64bit?

拥有回忆 提交于 2019-12-21 16:59:23
问题 I have some sample source code for OpenGL, I wanted to compile a 64bit version (using Delphi XE2) but there's some ASM code which fails to compile, and I know nothing about ASM. Here's the code below, and I put the two error messages on the lines which fail... // Copy a pixel from source to dest and Swap the RGB color values procedure CopySwapPixel(const Source, Destination: Pointer); asm push ebx //[DCC Error]: E2116 Invalid combination of opcode and operands mov bl,[eax+0] mov bh,[eax+1]