unit UMain; interface uses Forms, Windows, Messages, SysUtils, Classes, Graphics, Controls, Dialogs, StdCtrls, ComCtrls, CheckLst, ExtCtrls; const // This constants are from WpmForms.h WM_FM_FORMBASE = (WM_USER + 1800); WM_FM_INITFOCUS = (WM_FM_FORMBASE + 5); // Sent by the manager at the end of Window creation, after the // window has been made visible. The dialog should set focus to // whichever control it wishes. WM_F_FORMBASE = (WM_USER + 2000); WM_F_GETBASEDIR = (WM_F_FORMBASE + 65); // Get the full path to the directory from which WINPMAIL.EXE was // run. lParam points to a buffer into which the path should be // copied and wParam is the maximum length of the string to copy, // including the terminating nul. You should allocate at least 128 // characters. The string returned is a full path in DOS format // and does not have a trailing "\" character. type TFMain = class(TForm) BtnClose: TButton; BtnGetBaseDir: TButton; EdGetBaseDir: TEdit; procedure BtnGetBaseDirClick(Sender: TObject); procedure BtnCloseClick(Sender: TObject); private procedure WmFmInitFocus(var Message: TMessage); message WM_FM_INITFOCUS; public constructor CreateParented(ParentWindow: HWnd); end; var FMain: TFMain; implementation {$R *.DFM} { TFMain } procedure TFMain.WmFmInitFocus(var Message: TMessage); begin Visible := True; end; procedure TFMain.BtnGetBaseDirClick(Sender: TObject); var C: array[0..255] of char; begin SendMessage(ParentWindow, WM_F_GETBASEDIR, 255, Integer(@C)); EdGetBaseDir.Text := C; end; procedure TFMain.BtnCloseClick(Sender: TObject); begin PostMessage(ParentWindow, WM_CLOSE, 0, 0); end; constructor TFMain.CreateParented(ParentWindow: HWnd); begin inherited CreateParented(ParentWindow); Left := 0; Top := 0; end; initialization FMain := nil; finalization if Assigned(FMain) then FMain.Free; end.