Here is a *very* little program i wipped up, cause its been buggin me for a while.

I want a tool to quickly turn on and off the WS_EX_TOPMOST style on certain windows... Mainly so i can have certain text in veiw while writing asm in my IDE.

So i wipped this up quickly to suit my need.

To use it:

In the client aread, click and drag to the window you wish to modify. Then let go of the left click button. Then the window style is toggled of the window you let go on. (pretty simple).

You can also toggle the 'tool' itself by doing a quick click on the client area itself.

Hope you like, i know i do ;)
Posted on 2002-05-19 01:46:27 by NaN
NaN, your tool doesn't work on Win2000.
To have it work on both win98 and win2k, use global hooking with a dll.

Good idea, though.:alright:
Posted on 2002-05-19 02:12:24 by C.Z.
Thats bizarre..

I looked up the API's used and they are all 95 or above..??

I assume your getting at the SetCapture and ReleaseCaputure api's failing on the NT boxes, or does the window even appear???

Posted on 2002-05-19 03:16:41 by NaN
NaN: doesn't work here either (win2k). However the window handle is correct, it just doesn't bring it to top.
I tried with Get/SetWindowLong as well:

invoke GetWindowLong, hWND, GWL_EXSTYLE
xor eax, WS_EX_TOPMOST
invoke SetWindowLong, hWND, GWL_EXSTYLE, eax

But that didn't work either as it doesn't support Get/SetWindowLong on windows that do not belong to your process..

Posted on 2002-05-19 03:41:51 by Thomas
Ya, i tried Get/SetWindowLong as my first idea to get the job done, but win9x doesnt save the update, even tho GetLastError says it was done successfully.

I dunno why the MSDN likes to omit these short comming with their NT os's.

I use the online MSDN as its the most up to date. And every API im using is "ok" to use. (grrrrrrrr).

Im getting sick and tired of NT boxes "surprising you" with their lack of documentation.

However, thanx for the feedback!
:rolleyes: NaN :rolleyes:
Posted on 2002-05-19 03:52:20 by NaN
NaN, as far as I know SetWindowPos doens't apply on windows belonging to other processes under NT for security reasons. The best way to solve this is to inject your DLL into the target process using the hook functions.

Another solution is to use WriteProcessMemory but that will be pretty ugly and can't work on win98.:)
Posted on 2002-05-19 04:40:17 by C.Z.
BTW: one of the many things I always loved of my Amiga (the way I set it up, at least) was how it handled focus:

a click gave focus, but didn't put the window to front
double click gave both focus and put the window to front

Now if the Windows GUI could be "modified" to behave like that... NAN, could you write a tool that features just that?


Perhaps it's not intuitive how handy the above is unless one has been using it for years.
I think it's an abyss above the normal Windows GUI's way.
Posted on 2002-05-19 04:57:22 by Maverick
Maverick: I suppose WindowBlinds from Stardock can accomplish this; it does a quite complete system patching.
Posted on 2002-05-19 05:21:26 by C.Z.
Maverick, i dont really know, off hand i would say yes, but i have a feeling there will be catches with the WM_SETFOCUS message.

The other catch of course is the SetWindowPos api that is 'less than fully suported' on NT boxes. If there is a clearner solution i will implement it for ya's, but as a (becoming and ever so faithful) win9x fan, i dont really want to get into DLL's and HOOK's just to do somthing simple.

Posted on 2002-05-19 15:00:27 by NaN

Maverick: I suppose WindowBlinds from Stardock can accomplish this; it does a quite complete system patching.
Thank you for your suggestion.. but after having veryfied, I saw it doesn't support this (nice prog anyway).

NaN: Well, if you can I'd appreciate it much, otherwise.. neverminds. ;)
Posted on 2002-05-20 07:07:50 by Maverick
Ya nice idea. I tried this once but never followed up on it. You could always use SetForegroundWindow cause it works no matter the thread, but you will run into focus problems I am sure.
Posted on 2002-05-20 11:03:17 by Graebel
Well I've been running around like a madman all day and have just now been able to relax. I just skimmed through this thread so maybe this won't help at all, but here goes anyways.... :)

A while back I was doing something similar to this and I only tested it on a win2k box. Iirc the prog in question was a macro program that I never did get around to finishing. Anyways I switched from using the drag n drop cursor to select the right edit control and instead chose to use system wide hotkeys. There was some problem using GetFocus (I think that was the one) on windows in other threads. So I ended up using AttachThreadInput which worked. I'm not sure how clean of a solution that is but....

Anyways maybe this is of no use because I just skimmed through this thread, and maybe I completely misunderstood the problem.
Posted on 2002-05-20 14:43:48 by Will
Works here on win2000, but only if the window is restored (not maximized).
Posted on 2002-05-22 12:55:48 by grv575
Worx fine under my XP, regardless of window state (maximized or normal)
Posted on 2002-05-22 13:15:05 by drojid
Oh! So its just win NT that has the problem... hmm.. Perhaps it was tested on a restored window as well??

Oh well, i never liked that os anyways ;)

Posted on 2002-05-22 13:30:52 by NaN
Works fine here on win2k, and quite as expected... the topmost
state can only be set if the window is foreground window. This
might seem a bit weird, but on NT systems (and iirc also 98 and up?)
you're not supposed to push yourself to the foreground unless
you're the active app the user is working with. There might be a
way to make a non-foreground window topmost, I'm currently
looking into it.
Posted on 2002-05-22 14:58:21 by f0dder
Hm, seems that it even works for background windows, however
you have to be pretty careful when selecting the window - you
can't make a window topmost by dragging to the child of a window,
you have to end on the titlebar or menu bar. This could probably
be resolved by doing some GetParent calls...
Posted on 2002-05-22 15:14:22 by f0dder
Give this version a go. So much for the "shortcomings of NT" :rolleyes:
Posted on 2002-05-22 15:24:25 by f0dder
Thanx f0dder, always somthing to be learnt from you ;)

I see you like labels over @@'s, as well ;)

PS: I know you always recommending against merging sections, its just that it is set as a default to keep file size down. I never really think about it to be honest ;)

Posted on 2002-05-23 00:15:42 by NaN
NaN, sorry for having reported the wrong info. It works pretty fine under win2k, very handy tool.

One thing I don't understand is the windows of NetCaptor and Outlook, etc, can't become topmost with your tool, while others like Notepad and Winrar can. (that's where my previous wrong conclusion originated, forgive my being careless. :grin: )
Posted on 2002-05-23 04:31:46 by C.Z.