How to avoid issues when embedding a TForm in another TForm?

I do this as well and I use the following routine to make it happen: procedure TMyForm.PlaceInsideContainer(Container: TWinControl); begin Parent := Container; Align := alClient; BorderIcons := []; BorderStyle := bsNone; ParentBackground := True; Show; end; I have no problems with this. The only difference that I could possibly imagine could be relevant is the … Read more

How to free control inside its event handler?

The solution is to post a queued message to the control, which it responds to by destroying itself. Ny convention we use CM_RELEASE which is the private message used by TForm in its implementation of the Release method that performs an analogous task. interface type TAmountEdit = class (TEdit) … procedure KeyUp(var Key: Word; Shift … Read more

Delphi – get what files are opened by an application

Using the Native API function NtQuerySystemInformation you can list all open handles from all processes. try this example program ListAllHandles; {$APPTYPE CONSOLE} uses PSApi, Windows, SysUtils; const SystemHandleInformation = $10; STATUS_SUCCESS = $00000000; STATUS_BUFFER_OVERFLOW = $80000005; STATUS_INFO_LENGTH_MISMATCH = $C0000004; DefaulBUFFERSIZE = $100000; type OBJECT_INFORMATION_CLASS = (ObjectBasicInformation,ObjectNameInformation,ObjectTypeInformation,ObjectAllTypesInformation,ObjectHandleInformation ); SYSTEM_HANDLE=packed record uIdProcess:ULONG; ObjectType:UCHAR; Flags :UCHAR; Handle :Word; … Read more

How to associate a program with a file type, but only for the current user?

If you want to register the association for every user, write your data to HKEY_LOCAL_MACHINE\Software\Classes If you want to register the association for the current user only, write your data to HKEY_CURRENT_USER\Software\Classes This is how to do the latter: with TRegistry.Create do try RootKey := HKEY_CURRENT_USER; if OpenKey(‘\Software\Classes\.myfile’, true) then WriteString(”, ‘MyAppDataFile’); if OpenKey(‘\Software\Classes\MyAppDataFile’, true) … Read more

Creating a component with named sub-components?

This Thread helped me creating something as we discussed yesterday. I took the package posted there and modified it a bit. Here is the source: TestComponents.pas unit TestComponents; interface uses Classes; type TParentComponent = class; TChildComponent = class(TComponent) private FParent: TParentComponent; procedure SetParent(const Value: TParentComponent); protected procedure SetParentComponent(AParent: TComponent); override; public destructor Destroy; override; function … Read more

FTP Over SSH (SFTP) In delphi 2010

SFTP and “FTP over SSH” are two separate things, and neither involves SSL (as someone else has suggested). SFTP is a sub-protocol of SSH while “FTP over SSH” is good/bad ol’ FTP tunnelled through an SSH connection with port forwarding. Either way, what you’re after is a Delphi SSH library. I was unable to find … Read more