delphi-2009

Delphi 2009 - Bug? Adding supposedly invalid values to a set

前提是你 提交于 2019-12-22 05:25:19
问题 First of all, I'm not a very experienced programmer. I'm using Delphi 2009 and have been working with sets, which seem to behave very strangely and even inconsistently to me. I guess it might be me, but the following looks like there's clearly something wrong: unit test; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Edit1: TEdit; procedure Button1Click(Sender: TObject); private test: set of 1..2;

Which lists could serve as temporary lists?

扶醉桌前 提交于 2019-12-22 04:40:19
问题 When working with lists of items where the lists just serve as a temporary container - which list types would you recommend me to use? I don't want to destroy the list manually would like to use a built-in list type (no frameworks, libraries, ...) want generics Something which would make this possible without causing leaks: function GetListWithItems: ISomeList; begin Result := TSomeList.Create; // add items to list end; var Item: TSomeType; begin for Item in GetListWithItems do begin // do

Which lists could serve as temporary lists?

自古美人都是妖i 提交于 2019-12-22 04:40:17
问题 When working with lists of items where the lists just serve as a temporary container - which list types would you recommend me to use? I don't want to destroy the list manually would like to use a built-in list type (no frameworks, libraries, ...) want generics Something which would make this possible without causing leaks: function GetListWithItems: ISomeList; begin Result := TSomeList.Create; // add items to list end; var Item: TSomeType; begin for Item in GetListWithItems do begin // do

{$IFOPT A4}?

╄→尐↘猪︶ㄣ 提交于 2019-12-21 21:30:26
问题 In Delphi 2009 (or older versions), how do you check the "Align" compile option in the code? The IFOPT directive seems to work only with pure switches ( {$IFOPT A4} does not compile ). I couldn't find an equivalent constant or such defined ( {$IF Align = 4} or such ) 回答1: You can do this by defining a record with known packing rules and check it using SizeOf. Tested in Delphi 2009: type TTestRec = record A: Byte; B: Int64; end; {$IF SIZEOF(TTestRec) = 9} {$MESSAGE HINT '$A1'} {$ELSEIF SIZEOF

PNGs in Delphi 2009 Imagelists and Images

半城伤御伤魂 提交于 2019-12-21 17:54:26
问题 D2009 introduces PNG support for Images and Imagelists. However... I have an imagelist containing png images with alpha. I want to place one of these on a form using a TImage. How do I do this and get the image nicely composited? As an example of the problem I'm facing the code below fails to work correctly, and produces the effect shown: ImageList.GetBitmap(index, Image1.Picture.Bitmap); (source: clip2net.com) To explain a bit more: Drop a Timage on a form, and at design time, load a PNG

PNGs in Delphi 2009 Imagelists and Images

南楼画角 提交于 2019-12-21 17:53:01
问题 D2009 introduces PNG support for Images and Imagelists. However... I have an imagelist containing png images with alpha. I want to place one of these on a form using a TImage. How do I do this and get the image nicely composited? As an example of the problem I'm facing the code below fails to work correctly, and produces the effect shown: ImageList.GetBitmap(index, Image1.Picture.Bitmap); (source: clip2net.com) To explain a bit more: Drop a Timage on a form, and at design time, load a PNG

Unicode problems with Delphi 2009 / 2010 and windows API calls

馋奶兔 提交于 2019-12-21 17:28:50
问题 Hi I have been using this function in Delphi 2006, but now with D2010 it throws an error. I think it is related to the switch to Unicode. Function TWinUtils.GetTempFile(Const Extension: STRING): STRING; Var Buffer: ARRAY [0 .. MAX_PATH] OF char; Begin Repeat GetTempPath(SizeOf(Buffer) - 1, Buffer); GetTempFileName(Buffer, '~~', 0, Buffer); Result := ChangeFileExt(Buffer, Extension); Until not FileExists(Result); End; What should I do to make it work? EDIT I get an 'access violation' when the

Requirements for JSON Parser

╄→гoц情女王★ 提交于 2019-12-21 16:34:12
问题 I'm thinking about implementing JSON parser for Delphi. What should a good JSON parser do? Any ideas for requirements? I believe it should at least output and process JSON... Looking at XML parsers, should it be more DOM or SAX-like? 回答1: I think Json.NET does a pretty bang up job. JsonReader and JsonWriter for low level work of parsing and outputting JSON JsonSerializer for converting objects to and from JSON JObject, JArray and JValue classes for working with JSON in an object model Note I

Delphi 2009 COM/ActiveX Type Library support stability

烂漫一生 提交于 2019-12-21 09:16:09
问题 Referring to TLB and maintenance issues ... My question to people (often) using the new COM/ActiveX type library support in Delphi 2009 : How stable is the implementation? Especially, I'm interested in: adding/deleting classes, changing GUIDs, renaming methods/properties, reordering methods/properties, huge type libraries (50+ classes), ... Is it as stable as in Delphi 2007 (a nightmare) or Delphi 7 (quite OK, but sometimes you have to restore the TLB file from SVN) or super-stable (as in, ..

How can I create a most recently used file list in Delphi 2009?

故事扮演 提交于 2019-12-21 02:47:21
问题 I have an TActionManager, and a TActionMainMenuBar, and I know how to add an TActionClientItem for each MRU file to the main menu bar. But do I have to create a separate action for each MRU file in the list? Or is there a way to create just one action, and somehow pass a tag or something to the action's OnExecute event based on which MRU file was clicked? Delphi's help says: "For more information about MRU lists, sample code, and methods for finding actions in lists, see FindItemByAction and