delphi-xe2

Anonymous methods - variable capture versus value capture

扶醉桌前 提交于 2019-12-17 07:52:19
问题 Below is a SSCCE based on an example in the Anonymous Methods section of Part 1 of Chris Rolliston's excellent Delphi XE2 Foundations book, about the idea of variable capture (any errors in it are entirely down to me). It works exactly as I'd expect, logging 666, 667, 668, 669 on successive clicks of the BtnInvoke button. In particular it nicely illustrates how the captured version of the local variable I persists long after btnSetUpClick exits. So far so good. The problem I'm asking about

Delphi VCL styles tutorial - how to change the style at runtime

我与影子孤独终老i 提交于 2019-12-17 07:25:54
问题 Is there a good VCL Styles tutorial where we see how to dynamically (in run time) load/change the style ? This should work with Delphi XE2 and up, since XE2 is the first version with VCL Styles. 回答1: I'm adding an answer because local information is often preferred to just links. Here's the key facts you need to know before you start: Many VCL controls have color properties, but those properties are going to get ignored when styles are on, and the default "common controls" like Button are

Delphi: Access Violation at the end of Create() constructor

百般思念 提交于 2019-12-17 02:24:26
问题 I have a very basic and simple class like this: unit Loader; interface uses Vcl.Dialogs; type TLoader = Class(TObject) published constructor Create(); end; implementation { TLoader } constructor TLoader.Create; begin ShowMessage('ok'); end; end. And from Form1 i call it like this: procedure TForm1.Button1Click(Sender: TObject); var the : TLoader; begin the := the.Create; end; Now, just after the the := the.Create part, delphi shows the message with 'ok' and then gives me an error and says

Copy sublist from list

我的梦境 提交于 2019-12-16 18:06:42
问题 i have this full code: program List; {$APPTYPE CONSOLE} {$R *.res} uses System.SysUtils, Generics.Collections; type TMySubList = TList<Integer>; TMyList = TObjectList<TMySubList>; var iIndex1, iIndex2: Integer; MyList: TMyList; MySubList: TMySubList; begin try { TODO -oUser -cConsole Main : Insert code here } MyList := TMyList.Create; try for iIndex1 := 1 to 10 do begin MySubList := TList<Integer>.Create; if MyList.Count <> 0 then MySubList := MyList.Last; MySubList.Add(iIndex1); MyList.Add

How to restrict minimum form's width in FireMonkey?

痞子三分冷 提交于 2019-12-14 03:41:11
问题 How do I restrict a minimum form's width in FireMonkey? It used to be so easy in VCL - it just had Max and Min constraints in forms properties. 回答1: Note for future readers: This will only work for versions below XE3 because the Fmx::Platform::TPlatform class was removed in XE3. Thanks to @Alain Thiffault for pointing it out in the comments. Original Post: Here's a more complicated (but more elegant) alternative solution, defining an entirely custom Form class from which you can inherit your

Delphi String Search From File

对着背影说爱祢 提交于 2019-12-14 02:22:25
问题 I have an application having 3 Forms (TForm1, TForm2, TForm3). I need the code for the following : On TForm1.BitBtn Click "10.220.70.32 BSNLESDP25A" and "10.220.70.33 BSNLESDP25B" will be searched from "host" file located in "%windir%\System32\drivers\etc" directory. If found "host" file attributes will be changed to "Readonly" and "System" and Form2 will be shown. If not found then "Readonly" and "System" attributes of "host" file will be removed and two lines will be appended to "host" file

Delphi XE2: Debug a 64 bit dll through a 64 bit app

感情迁移 提交于 2019-12-14 00:42:57
问题 Has anyone had success in debugging a 64 bit dll by running/attaching to a 64 bit application? I have Delphi code for both the application and the dll. I can debug the application in 32 bit and 64 bits. I can also debug the 32 bit dll by using Run -> Parameters to select the 32 bit version of the app. However, I cannot appear to debug my 64 bit dll by running the 64 bit app, has anyone got this to work? 回答1: As per @evdkraan's answer "Steve, there is a bug in XE2 with 64bit debugging when

Programmatically Print to PDF

筅森魡賤 提交于 2019-12-13 22:12:51
问题 I have a customer who wants to print to PDF and Physical printer at the same time. They don't want to print the physical copy from the PDF, why I don't know. I tried saving as a temporary RTF file and calling ShellExecute to print to Adobe but doesn't appear this works. Does anyone have a way without a 3rd party PDF library to print to PDF from a file? UPDATE: To clarify a bit the user is working with a dynamic document creator. They see preview text on the screen in a TRichEdit and the

Delphi XE2 64 bit ISAPI Access Violation

人走茶凉 提交于 2019-12-13 21:52:23
问题 Windows Server 2008 R2 64 bit IIS 7.5 Delphi XE2 i made a simple WebService/ISAPI DLL using delphi XE2. this web service has a function that returns the sum of two numbers and made a simple client application to test this function. When i compile it (along with the client) as a 32 bit application (in a virtual directory with a 32-bit enabled app pool), all works fine when i compile it as a 64 bit DLL (the client is also compiled as a 64-bit aplication) i alws get an access violation error

Strange, when i call function from DLL, application not start but no error found

天涯浪子 提交于 2019-12-13 19:17:45
问题 in mine project i have a Windows application and a dll. I have wrote dll so: library MyDLL; uses System.SysUtils, System.Classes; {$R *.res} function Prova: string; export; begin result := 'prova'; end; exports Prova; begin end. and in main program i have called routine so: unit FrmMain; interface uses // declaration uses // function Prova: string; external 'MyDLL.dll'; type // declaration type // implementation begin ... TAdvEdit1.Text := Prova; // [1] // ... end; end. When i compile all