So, as mentioned in the title, I'm after identifying which monitor (in multiscreen situation) is the external process (application) running on.
I know that my form can be identified by TForm.Monitor.MonitorNum property, and so far I can get the handle of the external process by using the FindWindowExtd
function, which I got on the net.
Later on I check if GetForegroundWindow = FindWindowExtd('App Partial Title')
, so I only do my procedures if the external application has focus.
Since I'm doing the mouse emulator, it is vital for me to also identify the screen ID, where that application has focus.
How could I do that? The web kinda left me dry on this one too today...
Here's the code for FindWindowExtd:
function FindWindowExtd(partialTitle: string): HWND;
var
hWndTemp: hWnd;
iLenText: Integer;
cTitletemp: array [0..254] of Char;
sTitleTemp: string;
begin
hWndTemp := FindWindow(nil, nil);
while hWndTemp <> 0 do begin
iLenText := GetWindowText(hWndTemp, cTitletemp, 255);
sTitleTemp := cTitletemp;
sTitleTemp := UpperCase(copy( sTitleTemp, 1, iLenText));
partialTitle := UpperCase(partialTitle);
if pos( partialTitle, sTitleTemp ) <> 0 then
Break;
hWndTemp := GetWindow(hWndTemp, GW_HWNDNEXT);
end;
result := hWndTemp;
end;
Can I use some help from the handle I get out of it?
Thanks!