Make a form always on top - always 
Author Message
 Make a form always on top - always

I need to make a form that is ALWAYS on top of every other form.  I can
create a form from the example in Vis. Studio help that stays on top most of
the time.  But if I minimize a form underneath mine and then restore that
form from the task bar it covers mine up.  What I require is a form that
will not be covered by anything as long as its open.  Can the Z order for a
form be coded to always be first?  The following is the code I have tried.
Developing with VB6.0

************************
In module:
Option Explicit

Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal
hWndInsertAfter 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 conHwndTopmost = -1
Public Const conHwndNoTopmost = -2
Public Const conSwpNoActivate = &H10
Public Const conSwpShowWindow = &H40

******************
In form:
Option Explicit

Private Sub Form_Load()
      SetWindowPos hWnd, conHwndTopmost, 100, 100, 300, 300,
conSwpNoActivate Or conSwpShowWindow
End Sub

Any help greatly appreciated.

Thanks
Alan in San Antonio



Sun, 27 Jan 2002 03:00:00 GMT  
 Make a form always on top - always
It is my experience that the technique you are using is correct, but that
Visual Basic seems to remove the top-most status of forms under certain
conditions (such as when the form gains or perhaps loses the focus).

I would experiment with resetting the top-most status (as you are doing) in,
perhaps, the Activate or Deactivate events and see what works.

I know it's a pain but I haven't seen this problem with C programs so it
must be something VB is doing.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com


Quote:
> I need to make a form that is ALWAYS on top of every other form.  I can
> create a form from the example in Vis. Studio help that stays on top most
of
> the time.  But if I minimize a form underneath mine and then restore that
> form from the task bar it covers mine up.  What I require is a form that
> will not be covered by anything as long as its open.  Can the Z order for
a
> form be coded to always be first?  The following is the code I have tried.
> Developing with VB6.0

> ************************
> In module:
> Option Explicit

> Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal
> hWndInsertAfter 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 conHwndTopmost = -1
> Public Const conHwndNoTopmost = -2
> Public Const conSwpNoActivate = &H10
> Public Const conSwpShowWindow = &H40

> ******************
> In form:
> Option Explicit

> Private Sub Form_Load()
>       SetWindowPos hWnd, conHwndTopmost, 100, 100, 300, 300,
> conSwpNoActivate Or conSwpShowWindow
> End Sub

> Any help greatly appreciated.

> Thanks
> Alan in San Antonio



Sun, 27 Jan 2002 03:00:00 GMT  
 Make a form always on top - always
Just curious, what do you expect to happen if you run 2 instances of
your app?  Mutual Assured Destruction?


Sun, 27 Jan 2002 03:00:00 GMT  
 Make a form always on top - always
If this is for a compiled exe, don't worry about it falling behind in the
IDE .. this is normal. It should work as you want once compiled.

--

Randy Birch, MVP Visual Basic

http://www.mvps.org/vbnet/
http://www.mvps.org/ccrp/

Please correspond only using the newsgroups so all can benefit.


| I need to make a form that is ALWAYS on top of every other form.  I can
| create a form from the example in Vis. Studio help that stays on top most
of
| the time.  But if I minimize a form underneath mine and then restore that
| form from the task bar it covers mine up.  What I require is a form that
| will not be covered by anything as long as its open.  Can the Z order for
a
| form be coded to always be first?  The following is the code I have tried.
| Developing with VB6.0
|
| ************************
| In module:
| Option Explicit
|
| Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal
| hWndInsertAfter 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 conHwndTopmost = -1
| Public Const conHwndNoTopmost = -2
| Public Const conSwpNoActivate = &H10
| Public Const conSwpShowWindow = &H40
|
| ******************
| In form:
| Option Explicit
|
| Private Sub Form_Load()
|       SetWindowPos hWnd, conHwndTopmost, 100, 100, 300, 300,
| conSwpNoActivate Or conSwpShowWindow
| End Sub
|
|
| Any help greatly appreciated.
|
| Thanks
| Alan in San Antonio
|
|
|



Sun, 27 Jan 2002 03:00:00 GMT  
 Make a form always on top - always
I agree, what a battle that would be!
Quote:

>Just curious, what do you expect to happen if you run 2 instances of
>your app?  Mutual Assured Destruction?



Sun, 27 Jan 2002 03:00:00 GMT  
 Make a form always on top - always
Multiple top-most windows simply overlap each other just like ordinary
windows do.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com


Quote:
> Just curious, what do you expect to happen if you run 2 instances of
> your app?  Mutual Assured Destruction?



Sun, 27 Jan 2002 03:00:00 GMT  
 Make a form always on top - always
Geez, that doesn't meet the poster's requirement, does it?
Quote:

> Multiple top-most windows simply overlap each other just like ordinary
> windows do.

> --
> Jonathan Wood
> SoftCircuits Programming
> http://www.softcircuits.com



> > Just curious, what do you expect to happen if you run 2 instances of
> > your app?  Mutual Assured Destruction?



Mon, 28 Jan 2002 03:00:00 GMT  
 Make a form always on top - always

?I need to make a form that is ALWAYS on top of every other form.  I
can
?create a form from the example in Vis. Studio help that stays on top
most of
?the time.  But if I minimize a form underneath mine and then restore
that
?form from the task bar it covers mine up.  What I require is a form
that
?will not be covered by anything as long as its open.  Can the Z order
for a
?form be coded to always be first?  The following is the code I have
tried.
?Developing with VB6.0

I can confirm what Jonathan mentioned. Topmost forms have a habit of
losing their topmostness (sorry about that), so it's a good idea to
call this function when the app is activated.

Paul
~~~~



Tue, 29 Jan 2002 03:00:00 GMT  
 Make a form always on top - always
Have you tried making it modal?

Neil P. Fallon


Quote:

> ?I need to make a form that is ALWAYS on top of every other form.  I
> can
> ?create a form from the example in Vis. Studio help that stays on top
> most of
> ?the time.  But if I minimize a form underneath mine and then restore
> that
> ?form from the task bar it covers mine up.  What I require is a form
> that
> ?will not be covered by anything as long as its open.  Can the Z order
> for a
> ?form be coded to always be first?  The following is the code I have
> tried.
> ?Developing with VB6.0

> I can confirm what Jonathan mentioned. Topmost forms have a habit of
> losing their topmostness (sorry about that), so it's a good idea to
> call this function when the app is activated.

> Paul
> ~~~~




Tue, 29 Jan 2002 03:00:00 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. Making a form always stay on top.

2. Making a form be always on top.

3. Always on top (ALWAYS)

4. Make a window always on top (of every window..always)

5. Making Always On Top windows

6. Making the task bar NOT ALWAYS ON TOP BY PROGRAMIING

7. How can a form be fixed to be always on top of another form

8. How can a form be fixed to be always on top of another form

9. Hide a Form's Titlebar and Make Form Always on Top

10. VB Form always goes to top of Zorder upon form content update

11. Keeping a Form Always On Top

12. VBA Form Always On Top

 

 
Powered by phpBB® Forum Software