Quote:
>I have two ?'s
>1) How do i assign a form to "stay on top" even though it is not active?
>2) How do i assign vb to play a .wav file whenever i click on a command
>button or open the program?
> T.I.A.
> ---Mike---
> __
> -------------------^^^--\/--^^^-------------------
>also, tell me if this signature looks right to you......
Here's what the VB knowledge base help file (Vbknowlg.hlp) says.
Summary:
You can create a "floating" window such as that used for the Microsoft
Windows version 3.1 Clock by using the SetWindowPos Windows API call.
More Information:
A floating (or TOPMOST) window is a window that remains constantly
above all other windows, even when it is not active. Examples of
floating windows are the Find dialog box in WRITE.EXE, and CLOCK.EXE
(when Always on Top is selected from the Control menu).
There are two methods to produce windows that "hover" or "float," one
of which is possible in Visual Basic for Windows. This method is
described below:
Call SetWindowPos, specifying an existing non-topmost window and
HWND_TOPMOST as the value for the second parameter (hwndInsertAfter):
Use the following declarations:
Declare Function SetWindowPos Lib "user" (ByVal h%, ByVal hb%,
ByVal x%, ByVal y%, ByVal cx%, ByVal cy%, ByVal f%) As Integer
' The above Declare statement must appear on one line.
Global Const SWP_NOMOVE = 2
Global Const SWP_NOSIZE = 1
Global Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
Global Const HWND_TOPMOST = -1
Global Const HWND_NOTOPMOST = -2
To set the form XXXX to TOPMOST, use the following code:
success% = SetWindowPos (XXXX.hWnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS)
REM success% <> 0 When Successful
To reset the form XXXX to NON-TOPMOST, use the following code:
success% = SetWindowPos (XXXX.hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, FLAGS)
REM success% <> 0 When Successful
Note: This attribute was introduced in Windows, version 3.1, so
remember to make a GetVersion() API call to determine whether the
application is running under Windows, version 3.1.