Click to See Complete Forum and Search --> : Keep application forms on top


Gizmo001
February 5th, 2008, 09:31 PM
I want to keep the forms related to my forms on top of all other open applications. How do I do that? Thanks?

Shuja Ali
February 6th, 2008, 02:46 AM
Forms related to your Forms?? :confused:

Forms have a property called TopMost that can be set to true or false. Look at MSDN for more

Gizmo001
February 8th, 2008, 06:54 AM
Shuja:

I had tried that. That has no effect. I have a non-.Net, third-party application running with its form taking up the whole screen. Now, I want to run my application so that its form shows up above the first application and remains there even when I shift control to the first application. Is that possible? I am using VS 2003. Thanks.

WoF
February 8th, 2008, 07:22 AM
I presume Form.TopMost is the same we had to achieve with an API call in VB6


Public Declare Function SetWindowPos Lib "user32" ( _
ByVal hWnd As Long, _
ByVal hWia As Long, _
ByVal X As Long, ByVal Y As Long, _
ByVal cx As Long, ByVal cy As Long, _
ByVal wFlags As Long _
) As Long

Public Const SWP_NoSize = 1&
Public Const SWP_NoMove = 2&

Public Const HWND_TopMost = -1&

'the call:
SetWindowPos FormX.hWnd, HWND_TopMost, 0, 0, 0, 0, SWP_NoSize + SWP_NoMove

FormX.hWnd being the window handle of the app's Form.

After calling the app's Form stays on top of all others.
Only, if another app does the same call it will take over the topmost position.
Maybe you can use a timer to set the TopMost property repeatedly every 500msec (either by API cal or by setting the Form's property)
Maybe that smartens out the other app.