Delphi

How to test the type of a generic interface?

帅比萌擦擦* 提交于 2021-02-06 12:58:08
问题 I'm not sure if the title makes sense, but I hope you can understand my question with some code. Given the following code for a publish/subscribe framework. type IMessage = interface ['{B1794F44-F6EE-4E7B-849A-995F05897E1C}'] end; ISubscriber = interface ['{D655967E-90C6-4613-92C5-1E5B53619EE0}'] end; ISubscriberOf<T: IMessage> = interface(ISubscriber) procedure Consume(const message: T); end; TMessageService = class private FSubscribers: TList<ISubscriber>; public constructor Create;

How to extract frames from a TGifImage into Bitmaps?

淺唱寂寞╮ 提交于 2021-02-06 11:40:47
问题 The demo below tries to draw the GIF on form's canvas. It doesn't work. The image won't advance. How to make it work? procedure TForm1.FormCreate(Sender: TObject); begin GIF := TGIFImage.Create; GIF.LoadFromFile('c:\2.gif'); end; procedure TForm1.FormDestroy(Sender: TObject); begin GIF.Free; end; procedure TForm1.Button1Click(Sender: TObject); VAR i: Integer; begin REPEAT for i:= 0 to GIF.Images.Count-1 DO begin DisplayGifFrame(i); Sleep(30); end; UNTIL FALSE; end; procedure TForm1

How to extract frames from a TGifImage into Bitmaps?

我怕爱的太早我们不能终老 提交于 2021-02-06 11:40:44
问题 The demo below tries to draw the GIF on form's canvas. It doesn't work. The image won't advance. How to make it work? procedure TForm1.FormCreate(Sender: TObject); begin GIF := TGIFImage.Create; GIF.LoadFromFile('c:\2.gif'); end; procedure TForm1.FormDestroy(Sender: TObject); begin GIF.Free; end; procedure TForm1.Button1Click(Sender: TObject); VAR i: Integer; begin REPEAT for i:= 0 to GIF.Images.Count-1 DO begin DisplayGifFrame(i); Sleep(30); end; UNTIL FALSE; end; procedure TForm1

How do I instantiate a class from its TRttiType?

自古美人都是妖i 提交于 2021-02-06 11:09:49
问题 I want to create a form given its class name as a string, which has been asked about before, but instead of calling GetClass , I want to use Delphi's new RTTI feature. With this code, I've got a TRttiType , but I don't know how to instantiate it. var f:TFormBase; ctx:TRttiContext; lType:TRttiType; begin ctx := TRttiContext.Create; for lType in ctx.GetTypes do begin if lType.Name = 'TFormFormulirPendaftaran' then begin //how to instantiate lType here? Break; end; end; end; I've also tried

How do I instantiate a class from its TRttiType?

时间秒杀一切 提交于 2021-02-06 11:05:05
问题 I want to create a form given its class name as a string, which has been asked about before, but instead of calling GetClass , I want to use Delphi's new RTTI feature. With this code, I've got a TRttiType , but I don't know how to instantiate it. var f:TFormBase; ctx:TRttiContext; lType:TRttiType; begin ctx := TRttiContext.Create; for lType in ctx.GetTypes do begin if lType.Name = 'TFormFormulirPendaftaran' then begin //how to instantiate lType here? Break; end; end; end; I've also tried

Is it possible to use Attributes on Delphi method arguments?

為{幸葍}努か 提交于 2021-02-06 08:57:13
问题 Is this valid code with newer Delphi versions? // handle HTTP request "example.com/products?ProductID=123" procedure TMyRESTfulService.HandleRequest([QueryParam] ProductID: string); In this example, the argument "ProductID" is attributed with [QueryParam] . If this is valid code in Delphi, there must also be a way to write RTTI based code to find the attributed argument type information. See my previous question Which language elements can be annotated using attributes language feature of

Is it possible to use Attributes on Delphi method arguments?

£可爱£侵袭症+ 提交于 2021-02-06 08:56:24
问题 Is this valid code with newer Delphi versions? // handle HTTP request "example.com/products?ProductID=123" procedure TMyRESTfulService.HandleRequest([QueryParam] ProductID: string); In this example, the argument "ProductID" is attributed with [QueryParam] . If this is valid code in Delphi, there must also be a way to write RTTI based code to find the attributed argument type information. See my previous question Which language elements can be annotated using attributes language feature of

Is it possible to use Attributes on Delphi method arguments?

扶醉桌前 提交于 2021-02-06 08:55:24
问题 Is this valid code with newer Delphi versions? // handle HTTP request "example.com/products?ProductID=123" procedure TMyRESTfulService.HandleRequest([QueryParam] ProductID: string); In this example, the argument "ProductID" is attributed with [QueryParam] . If this is valid code in Delphi, there must also be a way to write RTTI based code to find the attributed argument type information. See my previous question Which language elements can be annotated using attributes language feature of

Is it possible to use Attributes on Delphi method arguments?

走远了吗. 提交于 2021-02-06 08:55:01
问题 Is this valid code with newer Delphi versions? // handle HTTP request "example.com/products?ProductID=123" procedure TMyRESTfulService.HandleRequest([QueryParam] ProductID: string); In this example, the argument "ProductID" is attributed with [QueryParam] . If this is valid code in Delphi, there must also be a way to write RTTI based code to find the attributed argument type information. See my previous question Which language elements can be annotated using attributes language feature of

How to Schedule a task programmatically

荒凉一梦 提交于 2021-02-06 04:42:38
问题 How can I schedule a task using delphi 7 like Google updater? I'm not using the registry because it gets detected by Kaspersky antivirus as a false alarm. Anything I add in the registry as a start-up item gets detected as a trojan so I decided to use task schedule 回答1: The following piece of code shows how to delete and create the task which will run the application at system startup with system privileges. It uses the following command line: However the Task Scheduler since Windows Vista