🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.basic.visual.misc
Article #265

Re: Help, I want my form ALWAYS staying on top of ANY other window

#265
From: sheppe
Date: Thu, 08 Oct 1998 00:00
62 lines
2853 bytes
In article <361CB6BD.50185564@advalvas.be>,
  Marc Alcide <marc.alcide@advalvas.be> wrote:
> This is a multi-part message in MIME format.
> --------------0C1D3B7B56CA867369DF86FB
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit
>
> Hi,
>
> I want my form always staying on top of any other window
>
> How do I do that.?
>
> Is there a property that does the job?
>
> (WIN 98-VB 5.0)

In a module, place the following code

'this is the function used to manipulate the window position
Public 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

'several constants that are used in conjunction with that function (hehe, that
'rymes) ;)
Public Const SWP_FRAMECHANGED = &H20 ' The frame changed: send WM_NCCALCSIZE
Public Const SWP_DRAWFRAME = SWP_FRAMECHANGED
Public Const SWP_HIDEWINDOW = &H80
Public Const SWP_NOACTIVATE = &H10
Public Const SWP_NOCOPYBITS = &H100
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOOWNERZORDER = &H200 ' Don't do owner Z ordering
Public Const SWP_NOREDRAW = &H8
Public Const SWP_NOREPOSITION = SWP_NOOWNERZORDER
Public Const SWP_NOSIZE = &H1
Public Const SWP_NOZORDER = &H4
Public Const SWP_SHOWWINDOW = &H40
Public Const HWND_BOTTOM = 1
Public Const HWND_TOP = 0
Public Const HWND_NOTOPMOST = -2
Public Const HWND_TOPMOST = -1

'and now in your form, usually in the form load event, enter the following:

Private Sub Form_Load()

    'a variable to hold the return value of the setwindowpos function
    Dim RetVal As Long
    'set the form as the topmost window
    RetVal = SetWindowPos(Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or _
    SWP_NOMOVE)
    'If RetVal <> 0 Then Success!
End Sub

--
Sheppe Pharis
VB5/ActiveX Developer
http://members.xoom.com/2mStn

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    
Technical Details
Message-ID: <6viohg$2l4$1@nnrp1.dejanews.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <361CB6BD.50185564@advalvas.be>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 110e3b,537b9fb8f551a378
X-Google-Attributes: gid110e3b,public
X-Google-Thread: 111c4c,537b9fb8f551a378
X-Google-Attributes: gid111c4c,public
From: sheppe@rogersfoods.com
Subject: Re: Help, I want my form ALWAYS staying on top of ANY other window
Date: 1998/10/08
Message-ID: <6viohg$2l4$1@nnrp1.dejanews.com>
X-Deja-AN: 399028994
References: <361CB6BD.50185564@advalvas.be>
X-Http-Proxy: 1.0 INTERNET, 1.0 x5.dejanews.com:80 (Squid/1.1.22) for client 199.166.227.168
Organization: Deja News - The Leader in Internet Discussion
X-Article-Creation-Date: Thu Oct 08 16:16:48 1998 GMT
Newsgroups: comp.lang.basic.visual.misc,be.comp
X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows 98)