Having a form always on top 
Author Message
 Having a form always on top

Hi everyone,

I'm sorry if this subject has been discussed here and I'm repeating it.

I'm trying to have a form always on top of all other froms in the
application even if the focus is on another form. So the form will be
floating on the screen.

Any body has done it before and can give me some advice?

Cheers,
Shuky



Sun, 07 Mar 1999 03:00:00 GMT  
 Having a form always on top

Quote:

> Hi everyone,

> I'm sorry if this subject has been discussed here and I'm repeating it.

> I'm trying to have a form always on top of all other froms in the
> application even if the focus is on another form. So the form will be
> floating on the screen.

> Any body has done it before and can give me some advice?

> Cheers,
> Shuky

KB said 'calling SetWindowPos(Me.Hwnd, -1, 0, 0, 0, 0, SWP_NOSIZE AND
SWP_NOMOVE) (or replace last argument with &H50), but you can check my
recent news message, there's a problem I didn't fix yet!)


Sun, 07 Mar 1999 03:00:00 GMT  
 Having a form always on top

You can create your so called "floating" window by using the SetWindowPos Windows API call.
Assuming your application is running under Windows, version 3.1.

Your code could look likt this !

Declare Function SetWindowPos Lib "User" (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

'
' Contants
'
Const SWP_NOMOVE = 2
Const SWP_NOSIZE = 1

Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
Const HWND_TOPMOST = -1

'
' Code
'

Dim RetCode%

'
' <form> is the name of the form tos set to "topmost"
'
RetCode = SetWindowPos (<form>.hWnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS)
RetCode <> 0 When Successful

---------------------------

---------------------------



Sun, 07 Mar 1999 03:00:00 GMT  
 Having a form always on top

You can find code for this on our web site: http://www.insteptech.com



Quote:
> Hi everyone,

> I'm sorry if this subject has been discussed here and I'm repeating it.

> I'm trying to have a form always on top of all other froms in the
> application even if the focus is on another form. So the form will be
> floating on the screen.

> Any body has done it before and can give me some advice?

> Cheers,
> Shuky



Sun, 07 Mar 1999 03:00:00 GMT  
 Having a form always on top

You can find code for this on our web site: http://www.insteptech.com



Quote:
> Hi everyone,

> I'm sorry if this subject has been discussed here and I'm repeating it.

> I'm trying to have a form always on top of all other froms in the
> application even if the focus is on another form. So the form will be
> floating on the screen.

> Any body has done it before and can give me some advice?

> Cheers,
> Shuky

--- Internet Message Header Follows ---
Path:
sun.inform.dk!gn.apc.org!plug.news.pipex.net!pipex!news.genacc.com!lade.news.pipex.net!pipex!dish.news.pipex.net!pipex!tank.news.pipex.net!pipex!news.be.innet.net!INbe.net!news.nl.innet.net!INnl.net!hunter.premier.net!www.nntp.primenet.com!nntp.primenet.com!news.sgi.com!news.msfc.nasa.g...

Newsgroups: comp.lang.basic.visual.misc
Subject: Re: Having a form always on top
Date: 18 Sep 1996 08:54:33 GMT
Organization: InStep Technologies
Lines: 17


NNTP-Posting-Host: ws02.insteptech.com
X-Newsreader: Microsoft Internet News 4.70.1155

**************************************
        Sent via Inform-BBS
-Denmark's leading alternative network

**************************************



Sun, 07 Mar 1999 03:00:00 GMT  
 Having a form always on top

This is how I do it in 16-bit VB.

Place this code in a code module, i.e. BAS file.

' Windows API Declarations
Declare Function SetWindowPos Lib "User" (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

' Windows API Constants
Public Const HWND_TOPMOST = -1
Public Const SWP_NOMOVE = 2
Public Const SWP_NOSIZE = 1
Public Const SWP_FLAGS = SWP_NOMOVE Or SWP_NOSIZE

Place this code in the Form_Load event of the form you want to stay on top.

Dim lAPIReturnValue as Long

lAPIReturnValue = SetWindowPos(Form1.hWnd, HWND_TOPMOST, 0, 0, 0, 0,
SWP_FLAGS)

Let me know if you have any problems.



Quote:
> Hi everyone,

> I'm sorry if this subject has been discussed here and I'm repeating it.

> I'm trying to have a form always on top of all other froms in the
> application even if the focus is on another form. So the form will be
> floating on the screen.

> Any body has done it before and can give me some advice?

> Cheers,
> Shuky



Mon, 15 Mar 1999 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Make a form always on top - always

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

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

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

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

6. Always on top (ALWAYS)

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

8. Keeping a Form Always On Top

9. VBA Form Always On Top

10. Form always on top

11. Form always on top

12. How I can make an Child-Form always on top

 

 
Powered by phpBB® Forum Software