From: <ah...@us...> - 2009-10-03 18:07:55
|
Revision: 12549 http://jvcl.svn.sourceforge.net/jvcl/?rev=12549&view=rev Author: ahuser Date: 2009-10-03 18:07:44 +0000 (Sat, 03 Oct 2009) Log Message: ----------- Mantis 4640: TJvExitWindowsDialog.Execute crashes program/or Delphi 2009 under Vista New property Kind controls the new Vista parameter (that caused the crash) Modified Paths: -------------- trunk/jvcl/run/JvWinDialogs.pas Modified: trunk/jvcl/run/JvWinDialogs.pas =================================================================== --- trunk/jvcl/run/JvWinDialogs.pas 2009-10-03 17:30:21 UTC (rev 12548) +++ trunk/jvcl/run/JvWinDialogs.pas 2009-10-03 18:07:44 UTC (rev 12549) @@ -364,12 +364,21 @@ property DriveChar: Char read FDriveChar write SetDriveChar default 'C'; end; + TJvExitWindowsKind = ( + ekXPDialog = 0, // Show XP style shutdown dialog + ekVistaLogoff = 1, // Vista Logoff without dialog + ekVistaShutdown = 2 // Vista Shutdown without dialog + ); + TJvExitWindowsDialog = class(TJvCommonDialogP) + private + FKind: TJvExitWindowsKind; public function Execute: Boolean; override; + published + property Kind: TJvExitWindowsKind read FKind write FKind default ekXPDialog; end; - // (p3) this extension (PlacesBar) is already in TJvOpenDialog TJvOpenDialog2000 = class(TOpenDialog) public @@ -564,6 +573,7 @@ SHFormatDriveProc = function(Wnd: THandle; Drive: UINT; fmtID: UINT; Options: UINT): DWORD; stdcall; SHShutDownDialogProc = procedure(Wnd: THandle); stdcall; + SHShutDownDialog6Proc = procedure(Wnd: THandle; Kind: Integer); stdcall; // Vista or newer SHRunDialogProc = function(Wnd: THandle; Unknown1: Integer; Unknown2: Pointer; szTitle: PChar; szPrompt: PChar; uiFlages: Integer): DWORD; stdcall; SHFindFilesProc = function(Root: PItemIDList; SavedSearchFile: PItemIDList): LongBool; stdcall; @@ -608,6 +618,7 @@ GetSaveFileNameEx: GetSaveFileNameExProc = nil; SHFormatDrive: SHFormatDriveProc = nil; SHShutDownDialog: SHShutDownDialogProc = nil; + SHShutDownDialog6: SHShutDownDialog6Proc = nil; SHRunDialog: SHRunDialogProc = nil; SHFindFiles: SHFindFilesProc = nil; SHFindComputer: SHFindComputerProc = nil; @@ -663,7 +674,10 @@ @SHChangeIcon := GetProcAddress(ShellHandle, PAnsiChar(62)); @SHFormatDrive := GetProcAddress(ShellHandle, PAnsiChar('SHFormatDrive')); @FreePIDL := GetProcAddress(ShellHandle, PAnsiChar(155)); - @SHShutDownDialog := GetProcAddress(ShellHandle, PAnsiChar(60)); + if CheckWin32Version(6, 0) then + @SHShutDownDialog6 := GetProcAddress(ShellHandle, PAnsiChar(60)) + else + @SHShutDownDialog := GetProcAddress(ShellHandle, PAnsiChar(60)); @SHRunDialog := GetProcAddress(ShellHandle, PAnsiChar(61)); @SHFindFiles := GetProcAddress(ShellHandle, PAnsiChar(90)); @SHFindComputer := GetProcAddress(ShellHandle, PAnsiChar(91)); @@ -1602,9 +1616,12 @@ function TJvExitWindowsDialog.Execute: Boolean; begin - if not Assigned(SHShutDownDialog) then + if not Assigned(SHShutDownDialog) and not Assigned(SHShutDownDialog6) then raise EWinDialogError.CreateRes(@RsENotSupported); - SHShutDownDialog(GetForegroundWindow); + if Assigned(SHShutDownDialog6) then + SHShutDownDialog6(GetForegroundWindow, Integer(Kind)) // Vista or newer + else + SHShutDownDialog(GetForegroundWindow); Result := True; end; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |