Is there a similar functio to SetWindowActive to do this ??
-
In the MSVC documentation, SetActivateWindow() activates a window - however this must be associated with the calling thread's message queue. Is there a way that I can pass control from my program to another app's main window knowing it's handle ?? (I have got the handle using EnumWindows() and checking the window title). Appreciate any help:confused: Doug
-
In the MSVC documentation, SetActivateWindow() activates a window - however this must be associated with the calling thread's message queue. Is there a way that I can pass control from my program to another app's main window knowing it's handle ?? (I have got the handle using EnumWindows() and checking the window title). Appreciate any help:confused: Doug
ummmm this might be dumb but cant you send a mouse click message to its message queue ... that would make the whole thing happen as if the user clicked it just a thought
"... and so i said to him ... if it don't dance (or code) and you can't eat it either f**k it or throw it away"
sonork: 100.18128 8028finder.com -
In the MSVC documentation, SetActivateWindow() activates a window - however this must be associated with the calling thread's message queue. Is there a way that I can pass control from my program to another app's main window knowing it's handle ?? (I have got the handle using EnumWindows() and checking the window title). Appreciate any help:confused: Doug
Use SetForegroundWindow() instead. --Mike-- Just released - RightClick-Encrypt v1.3 - Adds fast & easy file encryption to Explorer My really out-of-date homepage Sonork-100.19012 Acid_Helm
-
Use SetForegroundWindow() instead. --Mike-- Just released - RightClick-Encrypt v1.3 - Adds fast & easy file encryption to Explorer My really out-of-date homepage Sonork-100.19012 Acid_Helm
doh! i knew there would be an easy way i was too lazy to squizz thru the msdn stuff sorry :-O
"... and so i said to him ... if it don't dance (or code) and you can't eat it either f**k it or throw it away"
sonork: 100.18128 8028finder.com -
In the MSVC documentation, SetActivateWindow() activates a window - however this must be associated with the calling thread's message queue. Is there a way that I can pass control from my program to another app's main window knowing it's handle ?? (I have got the handle using EnumWindows() and checking the window title). Appreciate any help:confused: Doug
Before calling SetActiveWindow, use the AttachThreadInput function to attach the input states of the calling thread and the thread with the desired window:
DWORD tidThis,tidOther;
tidThis=GetCurrentThreadId();
tidOther=GetWindowThreadProcessId(hwnd,NULL);
if(tidThis!=tidOther)
AttachThreadInput(tidThis,tidOther,TRUE);
SetActiveWindow(hwnd); // or SetForegroundWindow
if(tidThis!=tidOther)
AttachThreadInput(tidThis,tidOther,FALSE);Peter O.
-
doh! i knew there would be an easy way i was too lazy to squizz thru the msdn stuff sorry :-O
"... and so i said to him ... if it don't dance (or code) and you can't eat it either f**k it or throw it away"
sonork: 100.18128 8028finder.comlauren wrote: i knew there would be an easy way Sadly under 2K and XP, it won't actually make it foreground :-( It'll just flash the taskbar icon thrice. Unless you change this setting using Powertoys. Something about preventing apps from stealing focus. Nish
Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]
-
Before calling SetActiveWindow, use the AttachThreadInput function to attach the input states of the calling thread and the thread with the desired window:
DWORD tidThis,tidOther;
tidThis=GetCurrentThreadId();
tidOther=GetWindowThreadProcessId(hwnd,NULL);
if(tidThis!=tidOther)
AttachThreadInput(tidThis,tidOther,TRUE);
SetActiveWindow(hwnd); // or SetForegroundWindow
if(tidThis!=tidOther)
AttachThreadInput(tidThis,tidOther,FALSE);Peter O.
Peter, that code works a treat !! Many thanks for your help - I've learnt something ! Thanks also to all the others who contributed to this thread. :):):) Doug