SetActiveWindow() applying to ALL windows

Share your advanced PureBasic knowledge/code with the community.
User avatar
Primus
New User
New User
Posts: 5
Joined: Mon Feb 07, 2011 5:08 pm
Location: Europe

SetActiveWindow() applying to ALL windows

Post by Primus »

I discovered a simple way to set focus on a window, even if other programs have focus. As you know, the SetActiveWindow() function doesn't work in this situation.

Code: Select all

Procedure SetActiveWindowAdvanced(WindowNumber)
  StickyWindow(WindowNumber,1)
  StickyWindow(WindowNumber,0)
EndProcedure
Maybe this method has been mentioned before and I just didn't find it, but who cares.

Enjoy!
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: SetActiveWindow() applying to ALL windows

Post by ts-soft »

You have misunderstood the PB Funktion.

Code: Select all

SetActiveWindow() <> SetForegroundWindow_()
But thx for the nice tipp.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
skywalk
Addict
Addict
Posts: 4220
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: SetActiveWindow() applying to ALL windows

Post by skywalk »

Thanks for the tip. :)
Question?
How do we know the API commands used behind the native PB commands?
For example:

Code: Select all

; Windows XP or greater...
SetActiveWindow(#Window) <> SetForegroundWindow_(hWnd)
HideWindow(#Window,0)    =  ?
; etc...
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
Frarth
Enthusiast
Enthusiast
Posts: 241
Joined: Tue Jul 21, 2009 11:11 am
Location: On the planet
Contact:

Re: SetActiveWindow() applying to ALL windows

Post by Frarth »

Maybe you should call the procedure SetForegroundWindow() instead. Makes more sense. And thanks for the tip. I have no need for it now, but it is always good to know!
PureBasic 5.41 LTS | Xubuntu 16.04 (x32) | Windows 7 (x64)
Post Reply