Delphi

Forward declarations for record types

懵懂的女人 提交于 2020-01-11 05:35:09
问题 Is there such a thing as in the title? I'm trying to do this in part of converting an API structure, and run into something I haven't encountered before: PFNReaderTranslatedDispatch = function(var msg: TMsg): BOOL; stdcall; PFNReaderScroll = function(var prmi: TReaderModeInfo; dx, dy: integer): BOOL; stdcall; TReaderModeInfo = record cbSize: DWord; hWnd: THandle; fFlags: DWord; prc: PRect; pfnScroll: PFNReaderScroll; fFlags2: PFNReaderTranslatedDispatch; lParam: DWord; end; PReaderModeInfo =

Will an interface-implementing form free itself when there are no more references to it?

怎甘沉沦 提交于 2020-01-11 05:24:04
问题 If I implement an interface on a form such as TMyForm = class(TForm, IMyInterface) , will the object free itself when there are no more interface references to it? It seems not to, although I couldn't work out how TForm is reference counted (if at all). I'm concerned about the form getting freed when an interface reference goes out of scope, but this does not seem to happen. I guess there are two parts to the question, firstly whether a form might get unexpectedly freed (the real question),

Delphi XE2: Jumping to an anchor in CHM?

孤者浪人 提交于 2020-01-11 05:06:09
问题 In a Delphi XE2 program, how do I jump to an anchor inside a CHM help file topic? The anchor has the following format (extracted from the source of the topic page in HTML HelpViewer showing the CHM file): <a name="my_anchor_id"></a> I tried the following: Application.HelpJump('MyTopicName.htm#my_anchor_id'); Unfortunately, this does not work: It does jump to this topic, but only to the top of the topic, not to the anchor, which is several scrolls down the page. 回答1: Jumping to an anchor in

How do I write a Delphi Galileo IDE Expert?

家住魔仙堡 提交于 2020-01-11 03:59:08
问题 HI, I want to write a small Delphi IDE Expert for D2007-D2009 (aka. Galileo IDE) in order to show a window with a TMemo instance on it, with all the component names and classes from the form designer in the above memo. The selected component will be marked with a '*'. The expert should appear on a menu/toolbar and have a shortcut assigned. How do I do? Ps: Actually the real code is more complicated than that, but I want to have a general framework to get started. TIA 回答1: I did my first OTA

Is it wise to create composite controls?

你说的曾经没有我的故事 提交于 2020-01-11 03:28:49
问题 I have this application that reuses a sort of idiom in a number of places. There's a TPanel, and on it are some labels and buttons. The purpose is to allow the user to select a date range. The "&Dates" caption is one label, and the "All Dates" part is a second one. When the user clicks the "Choose" button a form pops up presenting the user with a pair of Date/Time controls and OK/Cancel buttons. If the user hits OK after selecting some dates, the 2nd label changes to "From mm/dd/yyyy To mm/dd

How to free TOleStream in this bit of code

那年仲夏 提交于 2020-01-11 02:40:07
问题 This is from a custom namespacer handler done in Delphi I use to load files into a webbrowser component. Datastream:IStream; var F: TFileStream; Dummy: INT64; begin F:=TFileStream.Create(strfilename fmOpenRead); CreateStreamOnHGlobal(0, True, DataStream); TOleStream.Create(DataStream).CopyFrom(F, F.Size); DataStream.Seek(0, STREAM_SEEK_SET, Dummy); TotalSize := F.Size; F.Free; end; The problem is that Fastmm4 gives a memory leak error when the program ends and says that TOleStream was not

What is 'Limited Debug Information'? (Full “Debugging Information" generates huge EXE files)

二次信任 提交于 2020-01-11 02:35:00
问题 I installed Delphi XE7 recently. When I first compiled an old app my jaw dropped when I have seen that the size of the EXE increased with 10MB! Playing in the 'Project options' I discovered that setting the 'Debug information' to 'Limited Debug Information' decreases the EXE size to something VERY close to the EXE generated by Delphi XE. Maybe under Delphi XE7 'Limited Debug Information' is the equivalent of 'Debug Information' from Delphi XE since it results in the same EXE size? So, why

Avoid window getting focus

假如想象 提交于 2020-01-11 02:10:08
问题 I am working on a virtual keyboard the problem is when i press a key on the virtual keyboard the window witch the data needs to be sent loses focus. How can i avoid that ? 回答1: When your keyboard form receives focus, part of the message it receives is the handle of the window that lost focus (wParam). Do what you need to do and set the focus back to the window that lost focus. EDIT: See the documentation on WM_SETFOCUS EDIT 2: Also, you could use the following when creating your custom form:

Avoid window getting focus

偶尔善良 提交于 2020-01-11 02:09:47
问题 I am working on a virtual keyboard the problem is when i press a key on the virtual keyboard the window witch the data needs to be sent loses focus. How can i avoid that ? 回答1: When your keyboard form receives focus, part of the message it receives is the handle of the window that lost focus (wParam). Do what you need to do and set the focus back to the window that lost focus. EDIT: See the documentation on WM_SETFOCUS EDIT 2: Also, you could use the following when creating your custom form:

Generics: What's a “CONSTRUCTOR constraint”?

霸气de小男生 提交于 2020-01-11 01:40:27
问题 I made a custom TObjectList descendant designed to hold subclasses of a base object class. It looks something like this: interface TMyDataList<T: TBaseDatafile> = class(TObjectList<TBaseDatafile>) public constructor Create; procedure upload(db: TDataSet); end; implementation constructor TMyDataList<T>.Create; begin inherited Create(true); self.Add(T.Create); end; I want each new list to start out with one blank object in it. It's pretty simple, right? But the compiler doesn't like it. It says