mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
ADD: Exit from drive if it removed
This commit is contained in:
parent
9fb30c52cc
commit
261feaf52f
2 changed files with 39 additions and 3 deletions
|
|
@ -5197,6 +5197,14 @@ end;
|
|||
procedure TfrmMain.OnDriveWatcherEvent(EventType: TDriveWatcherEvent; const ADrive: PDrive);
|
||||
begin
|
||||
UpdateDiskCount;
|
||||
|
||||
if (EventType = dweDriveRemoved) and Assigned(ADrive) then
|
||||
begin
|
||||
if IsInPath(ADrive^.Path, ActiveFrame.CurrentPath, True, True) then
|
||||
ActiveFrame.CurrentPath:= gpExePath
|
||||
else if IsInPath(ADrive^.Path, NotActiveFrame.CurrentPath, True, True) then
|
||||
NotActiveFrame.CurrentPath:= gpExePath;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TfrmMain.AppActivate(Sender: TObject);
|
||||
|
|
|
|||
|
|
@ -146,15 +146,43 @@ end;
|
|||
{$IFDEF MSWINDOWS}
|
||||
function MyWndProc(hWnd: HWND; uiMsg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;
|
||||
var
|
||||
ADrive: PDrive = nil;
|
||||
ADrive: TDrive;
|
||||
lpdb: PDEV_BROADCAST_HDR absolute lParam;
|
||||
lpdbv: PDEV_BROADCAST_VOLUME absolute lpdb;
|
||||
|
||||
function GetDrivePath(UnitMask: ULONG): String;
|
||||
var
|
||||
DriveNum: Byte;
|
||||
begin
|
||||
for DriveNum:= 0 to 25 do
|
||||
begin
|
||||
if ((UnitMask shr DriveNum) and $01) <> 0 then
|
||||
Exit(AnsiChar(DriveNum + Ord('a')) + ':\');
|
||||
end;
|
||||
end;
|
||||
|
||||
begin
|
||||
case uiMsg of
|
||||
WM_DEVICECHANGE:
|
||||
case wParam of
|
||||
DBT_DEVICEARRIVAL:
|
||||
DoDriveAdded(ADrive);
|
||||
begin
|
||||
if (lpdb^.dbch_devicetype <> DBT_DEVTYP_VOLUME) then
|
||||
DoDriveAdded(nil)
|
||||
else begin
|
||||
ADrive.Path:= GetDrivePath(lpdbv^.dbcv_unitmask);
|
||||
DoDriveAdded(@ADrive);
|
||||
end;
|
||||
end;
|
||||
DBT_DEVICEREMOVECOMPLETE:
|
||||
DoDriveRemoved(ADrive);
|
||||
begin
|
||||
if (lpdb^.dbch_devicetype <> DBT_DEVTYP_VOLUME) then
|
||||
DoDriveRemoved(nil)
|
||||
else begin
|
||||
ADrive.Path:= GetDrivePath(lpdbv^.dbcv_unitmask);
|
||||
DoDriveRemoved(@ADrive);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end; // case
|
||||
Result := CallWindowProc(OldWProc, hWnd, uiMsg, wParam, lParam);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue