function OFNHookProc(Wnd: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM): UINT;
stdcall;
var
col: COLORREF;
brush: HBRUSH;
begin
Writeln('
OFNHookProc');
brush := GetProp(Wnd, '
brush');
case Msg
of
WM_CTLCOLORDLG:
begin
Writeln('
WM_CTLCOLORDLG');
col :=
RGB($ff, 0, 0);
SetBkColor(wParam, col);
SetBkMode(wParam, TRANSPARENT);
if(brush <> 0)
then
DeleteObject(brush);
brush := CreateSolidBrush(col);
SetProp(Wnd, '
brush', brush);
Result := brush;
end;
WM_CLOSE:
begin
if(brush <> 0)
then
DeleteObject(brush);
end;
else
Result := ord(False);
end;
end;
var
ofn: tagOFNA;
Buffer:
array[0..MAX_PATH]
of Char;
begin
AllocConsole();
ZeroMemory(@ofn, sizeof(ofn));
ofn.lStructSize := sizeof(ofn);
ofn.hWndOwner := GetDesktopWindow();
ofn.hInstance := hInstance;
ofn.lpstrFilter := '
Textfiles'#0'
*.txt'#0'
Rich Text Documents'#0'
*.rtf'#0#0;
ofn.lpstrFile := @Buffer;
ofn.nMaxFile := sizeof(Buffer)
div sizeof(Char);
ofn.Flags := OFN_ENABLEHOOK
or OFN_FILEMUSTEXIST
or OFN_PATHMUSTEXIST;
ofn.lpfnHook := @OFNHookProc;
GetOpenFileName(ofn);
end.