Resume UWP app in Windows 10
Posted: Tue Jan 04, 2022 11:27 am
Our (Delphi 11) app allows the user to trigger the Windows calculator from the menu, and once open to restore it to the foreground using the same menu item, using the following (where wnd is the window handle of the app)
However, if the calculator is minimised (or closed) then that fails to restore the calculator to the foreground as the Windows 10 calculator is a UWP app which is in a suspended state.
As I understand it - the process needs to be resumed from the suspended state before it can be brought to the foreground, so I first tried to resume the process as a whole (pid is the process ID):
and, when that failed to work, attempting to resume the constituent threads individually (in addition to the process):
Neither variation has been successful, so the obvious question is "What have I done wrong?"
Code: Select all
ShowWindow(wnd, SW_SHOWNORMAL);
SetForegroundWindow(wnd);
As I understand it - the process needs to be resumed from the suspended state before it can be brought to the foreground, so I first tried to resume the process as a whole (pid is the process ID):
Code: Select all
processList := Processes();
for processIndex := 0 to processList.ItemCount - 1 do begin
processItem := processList.Items[processIndex];
if processItem.ID = pid then
processItem.Resume;
end;
end;
Code: Select all
processList := Processes();
for processIndex := 0 to processList.ItemCount - 1 do begin
processItem := processList.Items[processIndex];
if processItem.ID = pid then begin
threadList := processItem.Threads;
for threadIndex := 0 to threadList.ItemCount - 1 do begin
threadItem := threadList.Items[threadIndex];
if threadItem.IsSuspended then
threadItem.Resume();
end;
processItem.Resume;
end;
end;