-1

I need my form in front of an application. However, the common methods do not work.

Methods already tried

//method #1

PostMessage(HD, WM_USER, 0, 0);
SetWindowPos(HD, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE);


//method #2
dwThreadID := GetWindowThreadProcessId(HD, nil);
dwCurrentThreadID := GetCurrentThreadId;
AttachThreadInput(dwCurrentThreadID, dwThreadID, true);
BringWindowToTop(Aff.handle);
ShowWindow(Aff.handle, SW_SHOW);

Application in question enter image description here

Comments

The application in question only works in full screen mode.

I do not want complete code, only a way forward.

Excuse me for my bad English and thanks for your time.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
3V3LYN
  • 61
  • 6

2 Answers2

0

You are setting your form to the bottom. To make it topmost:

SetWindowPos(handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE or SWP_NOMOVE or SWP_NOSIZE);

Another approach, if you really want to force external application to the background you need to get its handle. For example, if such application is named calc:

hCalc := FindWindow('calc', nil); 
SendMessage(hCalc , WM_SYSCOMMAND, SC_MINIMIZE, 0); // you can also minimize the application
SetWindowPos(hCalc , HWND_BOTTOM, 0, 0, 0, 0,  SWP_NOACTIVATE or SWP_NOMOVE or SWP_NOSIZE);
0

You can try this:

function ForceForegroundWindow(AHandle: THandle): Boolean;
var
  Input: TInput;
begin
  Result := True;

  ZeroMemory(@Input, SizeOf(Input));
  SendInput(1, Input, SizeOf(Input));
  SetForegroundWindow(AHandle);
end;

Credits to Sertac Akyuz from (How to bring my application to the front?)

Community
  • 1
  • 1
ChrisB
  • 2,497
  • 2
  • 24
  • 43