SetWindowPos

I made a application consisting of a borderless nomoveable window wich I want to always stay behind all other applications.
The idea is to make it behave as part of the desktop.

The code I use is as follows:

In module:
Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Integer, ByVal hWndInsertAfter As Integer, ByVal X As Integer, ByVal Y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal wFlags As Integer) As Integer
Global Const HWND_TOPMOST = -1
Global Const HWND_NOTOPMOST = -2
Global Const HWND_BOTTOM = 1
Global Const HWND_DESKTOP = 0


In form declaration:
Dim Success%

On every object and event
    Success% = SetWindowPos(frmMain.hWnd, HWND_BOTTOM, 0, 0, 0, 0, Flags)

This works, but not as if the program was part of the desktopp.
Sometimes it pops to the front when I start other programs like
Novell NDS Manager.
Other times when I drag the scrolbar on a textbox on the application it pops to the front.
What does the HWND_DESKTOP do?

Is there another way to get the effect I am looking for?
trondsorensenAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

trondsorensenAuthor Commented:
Edited text of question.
0
mcriderCommented:
Are you doing:

 Success% = SetWindowPos(frmMain.hWnd, HWND_BOTTOM, 0, 0, 0, 0, Flags)

on mousemove, mouseup events and scroll events?

Cheers!
0
mcriderCommented:
You may want to consider adding a TimerEvent to your form that will also execute the SetWinsowPos...

Cheers!
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

trondsorensenAuthor Commented:
I am doing the code on every (All) events.
I have thought about adding it to a timer, but I dont think it is a good way of coding. How much processortime will it take up?
0
mcriderCommented:
It will take up processor time, but I think thats going to be your only way to get it to work...


Cheers!
0
Erick37Commented:
If you subclass the form, couldn't you intercept the appropriate windows messages and call SetWindowPos in the new WndProc?
0
trondsorensenAuthor Commented:
Whoa, Eric, the two of us are abiously in two defferent planets here ;) I almost dont know what you are talking about.
Can you please explain a little betther?
0
Erick37Commented:
Subclassing allows your application to intercept Windows messages that are not exposed thru VB.  The following MS article explaines how to determine when your app gains focus.  You might be able to send your window to the background each time Windows sends the WM_ACTIVATEAPP message.  Just a theory.

"HOWTO: Determine When Your Application Gains or Loses Focus"
http://support.microsoft.com/support/kb/articles/Q186/9/08.ASP
0
Bob LearnedCommented:
You can use SWP_NOACTIVATE = &H10, that will not activate the window, and bring it to the top.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.