Thema: Delphi Position von Dialog

Einzelnen Beitrag anzeigen

Benutzerbild von stahli
stahli

Registriert seit: 26. Nov 2003
Ort: Halle/Saale
4.337 Beiträge
 
Delphi 11 Alexandria
 
#4

Re: Position von Dialog

  Alt 27. Feb 2008, 18:27
so hier nochmal komplett:

Delphi-Quellcode:
implementation

uses
  Windows, Messages;

var
  OldProcForOpenSaveDialog: DWord;

// OldProcfuerOpendialog1: Dword globale Variable
//Idee von Pascal Enz
function DialogProc(Handle: HWND; Msg: DWORD; wParam, lParam: Integer):Integer; stdcall;
const
  W = 683;
  H = 512;
begin
  if MSG = WM_SHOWWINDOW then Begin
    SendMessage(Handle, WM_COMMAND, $A004, 0);
    SendMessage(Handle, WM_COMMAND, $A004, 0);
    SetWindowPos(Handle, 0,
    FormXyz.Left + (FormXyz.Width div 2) - (W div 2),
    FormXyz.Top + (FormXyz.Height div 2) - (H div 2),
    W,
    H,
    0);
  End;
  Result := CallWindowProc(Pointer(OldProcForOpenSaveDialog), Handle, Msg, wParam, lParam);
end;


// und folgende Ereignisbehandlungen den Dialogen zuweisen...


procedure TFormXyz.OpenDialogClose(Sender: TObject);
var
  Handle: HWND;
begin
  Handle := GetParent((Sender as TOpenDialog).Handle);
  SetWindowLong(Handle, DWL_DLGPROC, Integer(OldProcForOpenSaveDialog));
  OldProcForOpenSaveDialog := 0;
end;

procedure TFormXyz.OpenDialogShow(Sender: TObject);
var
  Handle: HWND;
begin
  Handle := GetParent((Sender as TOpenDialog).Handle);
  OldProcForOpenSaveDialog := GetWindowLong(Handle, DWL_DLGPROC);
  SetWindowLong(Handle, DWL_DLGPROC, Integer(@DialogProc));
end;

procedure TFormXyz.SaveDialogClose(Sender: TObject);
var
  Handle: HWND;
begin
  Handle := GetParent((Sender as TSaveDialog).Handle);
  SetWindowLong(Handle, DWL_DLGPROC, Integer(OldProcForOpenSaveDialog));
  OldProcForOpenSaveDialog := 0;
end;

procedure TFormXyz.SaveDialogShow(Sender: TObject);
var
  Handle: HWND;
begin
  Handle := GetParent((Sender as TSaveDialog).Handle);
  OldProcForOpenSaveDialog := GetWindowLong(Handle, DWL_DLGPROC);
  SetWindowLong(Handle, DWL_DLGPROC, Integer(@DialogProc));
end;
stahli
  Mit Zitat antworten Zitat