Delphi

Empty string becomes null when passed from Delphi to C# as a function argument

邮差的信 提交于 2020-01-21 09:20:37
问题 I have a native Delphi exe which calls into C# dll via COM interop. Here's the simplest case which demonstrate this issue: Delphi: IClass1 = interface(IDispatch) ['{B29BAF13-E9E4-33D7-9C92-FE28416C662D}'] function Test(const aStr: WideString): WideString; safecall; end; var obj: IClass1; s: string; begin obj := CoClass1.Create as IClass1; s := obj.Test(''); // Returns '[null]' end; C#: [ComVisible(true)] public interface IClass1 { string Test(string aStr); } [ComVisible(true)] public class

Empty string becomes null when passed from Delphi to C# as a function argument

若如初见. 提交于 2020-01-21 09:19:12
问题 I have a native Delphi exe which calls into C# dll via COM interop. Here's the simplest case which demonstrate this issue: Delphi: IClass1 = interface(IDispatch) ['{B29BAF13-E9E4-33D7-9C92-FE28416C662D}'] function Test(const aStr: WideString): WideString; safecall; end; var obj: IClass1; s: string; begin obj := CoClass1.Create as IClass1; s := obj.Test(''); // Returns '[null]' end; C#: [ComVisible(true)] public interface IClass1 { string Test(string aStr); } [ComVisible(true)] public class

Delphi Chromium - Iterate DOM

你说的曾经没有我的故事 提交于 2020-01-21 08:45:08
问题 I'm trying to iterate the DOM using TChromium and because i use Delphi 2007 i can't use anonymous methods, so i created a class inherited of TCEFDomVisitorOwn. My code is as below, but for some reason the 'visit' procedure is never called, so nothings happens. unit udomprinc; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ceflib, cefvcl; type TForm1 = class(TForm) Chromium1: TChromium; procedure FormCreate(Sender: TObject); procedure

Delphi Chromium - Iterate DOM

末鹿安然 提交于 2020-01-21 08:43:09
问题 I'm trying to iterate the DOM using TChromium and because i use Delphi 2007 i can't use anonymous methods, so i created a class inherited of TCEFDomVisitorOwn. My code is as below, but for some reason the 'visit' procedure is never called, so nothings happens. unit udomprinc; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ceflib, cefvcl; type TForm1 = class(TForm) Chromium1: TChromium; procedure FormCreate(Sender: TObject); procedure

Math for slow image zoom

六眼飞鱼酱① 提交于 2020-01-21 07:25:11
问题 I have an .bmp image with a comic book layout. Currently my code works like this. If I right click and hold down mouse button i can draw a marquee type box around one of the frames on the comic book page. When I release the button it will zoom into that frame. But its instant. And I would like for it to have an animation effect. Thus instead of going and setting the values of PicRect to the "END VALUE" PicRect.Left PicRect.right PicRect.top PicRect.bottom as seen in code below, I need a way

Adding a unit automatically to the project

血红的双手。 提交于 2020-01-21 05:06:10
问题 I am working on a component in Delphi 7 and Delphi 2006 , where I am using a unit which I need to add to the .dpr file of the project on which the component is dropped automatically. Like the way Eureka Log automatically adds the unit 'ExceptionLog' to the project file: Can anyone tell me how to programmatically add a unit to the project file when I drop my component on any form in the project? 回答1: You most likely have to use the Open Tools API for that. Also it might require to write a

Adding a unit automatically to the project

不羁的心 提交于 2020-01-21 05:05:06
问题 I am working on a component in Delphi 7 and Delphi 2006 , where I am using a unit which I need to add to the .dpr file of the project on which the component is dropped automatically. Like the way Eureka Log automatically adds the unit 'ExceptionLog' to the project file: Can anyone tell me how to programmatically add a unit to the project file when I drop my component on any form in the project? 回答1: You most likely have to use the Open Tools API for that. Also it might require to write a

Is it OK to use DecimalSeparator to force Floattostr/Strtofloat functions to use a decimal point

元气小坏坏 提交于 2020-01-21 03:01:25
问题 Currently, I'm setting DecimalSeparator to a '.' in each procedure which uses these functions. It would be much easier to set this globally at the start of the program but I found Delphi seems to periodically set this back to the current locale. I need to make sure that a decimal point is used for all conversions no matter which country the program is used in as this is the standard for this type of program and all files structure and communication protocols, numeric displays in forms/edits

How can I test private methods with DUnit?

狂风中的少年 提交于 2020-01-21 02:41:05
问题 I have a class that I am unit testing into with DUnit. It has a number of methods some public methods and private methods. type TAuth = class(TDataModule) private procedure PrivateMethod; public procedure PublicMethod; end; In order to write a unit test for this class I have to make all the methods public. Is there a different way to declare the private methods so that I can still test them but they are not public? 回答1: You don't need to make them public. Protected will do. Then you can

How can I specify the window position of an external console program?

混江龙づ霸主 提交于 2020-01-20 22:08:30
问题 In my Win32 VCL application I am using ShellExecute to launch a number of smaller Delphi console applications. Is there a way to control the position of those console windows? I would like to launch them centered on screen. 回答1: If you have control over the console application, You could set the console window position from inside the console application itself: program Project1; {$APPTYPE CONSOLE} uses Windows, MultiMon; function GetConsoleWindow: HWND; stdcall; external kernel32 name