MODULE COMDLG32;
IMPORT SYSTEM, Kernel32, User32, Modules;
CONST
PDPageNums* = 1; PDReturnDC* = 8; PDReturnDefault* = 10;
PSDMargins* = 1; PSDInThousandthsOfInches* = 2; PSDInHundredthsOfMillimeters* = 3;
FRDown* = 0; FRWholeWord* = 1; FRMatchCase* = 2; FRFindNext* = 3; FRReplace* = 4;
FRReplaceAll* = 5; FRDialogTerm* = 6; FRShowHelp * = 7; FRENableHook* = 8;
FREnableTemplate* = 9; FRNoUpDown* = 10; FRNoMatchCase* = 11; FRNoWholeWord* = 12;
FREnableTemplateHandle* = 13; FRHideUpDown* = 14; FRHideMatchCase* = 15;
FRHideWholeWord* = 16;
OFN_AllowMultiselect* = 0200H; OFN_Explorer* = 080000H;
TYPE
PRINTDLG* = RECORD
lStructSize*: LONGINT;
hwndOwner*: User32.HWND;
hDevMode*, hDevNames*: Kernel32.HANDLE;
hDC*: User32.HDC;
Flags*: SET;
nFromPage*, nToPage*: INTEGER;
nMinPage*, nMaxPage*: INTEGER;
fill*: ARRAY 2+8*4 OF SYSTEM.BYTE
END;
PAGESETUPDLG* = RECORD
lStructSize*: LONGINT;
hwndOwner*: User32.HWND;
hDevMode*, hDevNames*: Kernel32.HGLOBAL;
Flags*: SET;
ptPaperSize*: User32.Point;
rtMinMargin*, rtMargin*: User32.Rect;
hInstance*: Kernel32.HINSTANCE;
lCustData*: LONGINT;
lpfnPageSetupHook*: Kernel32.ADDRESS;
lpfnPagePaintHook*: Kernel32.ADDRESS;
lpPageSetupTemplateName*: Kernel32.LPSTR;
hPageSetupTemplate*: Kernel32.HANDLE
END;
OpenFileName* = RECORD
lStructSize*: LONGINT;
hwndOwner*: User32.HWND;
hInstance*: Kernel32.HINSTANCE;
lpstrFilter*, lpstrCustomFilter*: Kernel32.LPSTR;
nMaxCustFilter*, nFilterIndex*: LONGINT;
lpstrFile*: Kernel32.LPSTR;
nMaxFile*: LONGINT;
lpstrFileTitle*: Kernel32.LPSTR;
nMaxFileTitle*: LONGINT;
lpstrInitialDir*, lpstrTitle*: Kernel32.LPSTR;
Flags*: LONGINT;
nFileOffset*, nFileExtension*: INTEGER;
lpstrDefExt*: Kernel32.LPSTR;
lCustData*: User32.LParam;
lpfnHook*: Kernel32.ADDRESS;
lpTemplateName*: Kernel32.LPSTR
END;
FindReplace* = RECORD
lStructSize*: LONGINT;
hwndOwner*: User32.HWND;
hInstance*: Kernel32.HINSTANCE;
Flags*: SET;
lpstrFindWhat*, lpstrReplaceWith*: Kernel32.LPSTR;
wFindWhatLen*, wReplaceWithLen*: INTEGER;
lCustData*: User32.LParam;
lpfnHook*: Kernel32.ADDRESS;
lpTemplateName*: Kernel32.LPSTR
END;
VAR
CommDlgExtendedError-: PROCEDURE {WINAPI} (): LONGINT;
FindText-: PROCEDURE {WINAPI} (VAR lpfr: FindReplace): User32.HWND;
GetOpenFileName-: PROCEDURE {WINAPI} (VAR lpofn: OpenFileName): Kernel32.BOOL;
GetSaveFileName-: PROCEDURE {WINAPI} (VAR lpofn: OpenFileName): Kernel32.BOOL;
PageSetupDlg-: PROCEDURE {WINAPI} (VAR lppsd: PAGESETUPDLG): Kernel32.BOOL;
PrintDlg-: PROCEDURE {WINAPI} (VAR lppd: PRINTDLG): Kernel32.BOOL;
mod: Kernel32.HMODULE;
ReplaceText-: PROCEDURE {WINAPI} (VAR lpfr: FindReplace): User32.HWND;
WMFindText-: LONGINT;
FindMsgString: ARRAY 32 OF CHAR;
PROCEDURE InitAPI;
VAR str : ARRAY 32 OF CHAR;
BEGIN
WMFindText := User32.RegisterWindowMessage(FindMsgString);
str := "COMDLG32";
mod := Kernel32.LoadLibrary(str);
Kernel32.GetProcAddress(mod, "CommDlgExtendedError", SYSTEM.VAL(LONGINT, CommDlgExtendedError));
Kernel32.GetProcAddress(mod, "FindTextA", SYSTEM.VAL(LONGINT, FindText));
Kernel32.GetProcAddress(mod, "GetOpenFileNameA", SYSTEM.VAL(LONGINT, GetOpenFileName));
Kernel32.GetProcAddress(mod, "GetSaveFileNameA", SYSTEM.VAL(LONGINT, GetSaveFileName));
Kernel32.GetProcAddress(mod, "PageSetupDlgA", SYSTEM.VAL(LONGINT, PageSetupDlg));
Kernel32.GetProcAddress(mod, "PrintDlgA", SYSTEM.VAL(LONGINT, PrintDlg));
Kernel32.GetProcAddress(mod, "ReplaceTextA", SYSTEM.VAL(LONGINT,ReplaceText))
END InitAPI;
PROCEDURE FreeAPI;
BEGIN
Kernel32.FreeLibrary(mod); mod := Kernel32.NULL
END FreeAPI;
BEGIN
FindMsgString := "CommDlg_FindReplace";
InitAPI(); Modules.InstallTermHandler(FreeAPI);
FindMsgString := "commdlg_FindReplace";
END COMDLG32.