Hi,
QuoteForeground activation permission is like love: You can't steal it, it has to be given to you.
SetForegroundWindow.
Do you have any examples to prove it?
Thank you in advance.
Regard.
Hello,
More info about the topic :
https://devblogs.microsoft.com/oldnewthing/20241128-00/?p=110586
https://devblogs.microsoft.com/oldnewthing/20090220-00/?p=19083
Hi,Vortex
Thank you.
I'v still not fully grasped the Blog. here the codes would prove that it has to be stolen to each other.
"1" instance:
DlgProc proc hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
mov eax,uMsg
.if eax == WM_INITDIALOG
invoke LoadIcon,hInstance,ICO_MAIN
invoke SendMessage,hWnd,WM_SETICON,ICON_BIG,rax
invoke SetTimer,hWnd,IDC_TIMERID,3000,NULL
.elseif eax == WM_COMMAND
mov rcx,wParam
.if cx == IDC_EXIT
invoke SendMessage,hWnd,WM_CLOSE,NULL,NULL
.endif
.elseif eax == WM_TIMER
invoke FindWindow,NULL,CStr("Test Foreground '2'")
mov Remote_hWnd,rax
invoke SetForegroundWindow,Remote_hWnd
.elseif eax == WM_CLOSE
invoke KillTimer,hWnd,IDC_TIMERID
invoke EndDialog,hWnd,0
.else
mov rax,FALSE
ret
.endif
mov rax,TRUE
ret
DlgProc endp
WinMainCRTStartup Proc
invoke GetModuleHandle,NULL
mov hInstance,rax
invoke DialogBoxParam,hInstance,IDD_DIALOG,0,addr DlgProc,0
invoke ExitProcess,NULL
WinMainCRTStartup Endp
"2" instance:
DlgProc proc hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
mov eax,uMsg
.if eax == WM_INITDIALOG
invoke LoadIcon,hInstance,ICO_MAIN
invoke SendMessage,hWnd,WM_SETICON,ICON_BIG,rax
invoke SetTimer,hWnd,IDC_TIMERID,3000,NULL
.elseif eax == WM_COMMAND
mov rcx,wParam
.if cx == IDC_EXIT
invoke SendMessage,hWnd,WM_CLOSE,NULL,NULL
.endif
.elseif eax == WM_TIMER
invoke FindWindow,NULL,CStr("Test Foreground '1'")
mov Remote_hWnd,rax
invoke SetForegroundWindow,Remote_hWnd
.elseif eax == WM_CLOSE
invoke KillTimer,hWnd,IDC_TIMERID
invoke EndDialog,hWnd,0
.else
mov rax,FALSE
ret
.endif
mov rax,TRUE
ret
DlgProc endp
WinMainCRTStartup Proc
invoke GetModuleHandle,NULL
mov hInstance,rax
invoke DialogBoxParam,hInstance,IDD_DIALOG,0,addr DlgProc,0
invoke ExitProcess,NULL
WinMainCRTStartup Endp
regard.