What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Plug-Ins » setForegroundWindow - BringWindowToTop [???]

setForegroundWindow - BringWindowToTop [???]
Author: Message:
TazDevil
Full Member
***

Avatar
sleep(0);

Posts: 359
Reputation: 11
40 / Male / Flag
Joined: May 2004
RE: setForegroundWindow - BringWindowToTop [???]
Actually if i understand correctly, what you trying to do is this...

You want to bring the window to front when another window has the foreground focus...

Regarding this matter Micro$oft, from version 98 of Windows and on decided to restrict the accessibility of this function, and now it should only work for windows that belong to the same thread...

This modification to the API was made due to the rise of adware, viruses, etc that would insert code to STEAL the foreground window...

Therefore in order to successfully acheive stilling the foreground you must use the followin function i found in the web... it is in c++ but some one can translate it for you if you can't :D

code:
void ReallySetForegroundWindow( HWND hWnd )
{
DWORD foregroundThreadID; // foreground window thread
DWORD ourThreadID; // our active thread
// If the window is in a minimized state, maximize now
if (GetWindowLong(hWnd, GWL_STYLE) & WS_MINIMIZE)
{
ShowWindow(hWnd, SW_MAXIMIZE);
UpdateWindow(hWnd);
}
// Check to see if we are the foreground thread
foregroundThreadID = GetWindowThreadProcessId(GetForegroundWindow(),
NULL);
ourThreadID = GetCurrentThreadId();
// If not, attach our thread's 'input' to the foreground thread's
if (foregroundThreadID != ourThreadID)
AttachThreadInput(foregroundThreadID, ourThreadID, TRUE);
// Bring our window to the foreground
SetForegroundWindow(hWnd);
// If we attached our thread, detach it now
if (foregroundThreadID != ourThreadID)
AttachThreadInput(foregroundThreadID, ourThreadID, FALSE);
// Force our window to redraw
InvalidateRect(hWnd, NULL, TRUE);
}

What the code does is actually sends input to the thread that has the focus, and makes it think that the window belongs in that thread, thus successfully brings the window in front

This post was edited on 06-17-2005 at 11:11 AM by TazDevil.
Window Manager is discontinued, for WLM try the new,
Enhancer for contact list docking, auto-hide, hide taskbar button, remove button flashing and remember keyboard layout in conversation windows
06-17-2005 11:07 AM
Profile PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
setForegroundWindow - BringWindowToTop [???] - by XM4ST3RX on 06-14-2005 at 11:50 PM
RE: setForegroundWindow - BringWindowToTop [???] - by matty on 06-15-2005 at 01:40 AM
RE: setForegroundWindow - BringWindowToTop [???] - by XM4ST3RX on 06-15-2005 at 01:41 AM
RE: setForegroundWindow - BringWindowToTop [???] - by matty on 06-15-2005 at 02:15 AM
RE: setForegroundWindow - BringWindowToTop [???] - by XM4ST3RX on 06-15-2005 at 02:18 AM
RE: setForegroundWindow - BringWindowToTop [???] - by matty on 06-15-2005 at 02:24 AM
RE: setForegroundWindow - BringWindowToTop [???] - by XM4ST3RX on 06-15-2005 at 02:30 AM
RE: setForegroundWindow - BringWindowToTop [???] - by Stigmata on 06-15-2005 at 06:29 AM
RE: setForegroundWindow - BringWindowToTop [???] - by TazDevil on 06-17-2005 at 11:07 AM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On