Create floating window (top most window)

Source: Internet
Author: User

In fact, the use of SetWindowPos () to change the Z-order, the so-called z-order is the screen is generally the x axis y axis to represent the position, and the z axis to represent the position, this is the Z-order

Bwndinsertafter of the Set value

Hwnd_bottom Places The window at the BOTTOM's Z order. If the HWND

parameter identifies a topmost window, the window loses its

Topmost status and is placed at the bottom of

Windows.

Hwnd_notopmost Places The window above all non-topmost windows

Behind all topmost windows). This flag has no effect if the

Window is already a non-topmost window.

Hwnd_top Places the window at the top of the Z order.

Hwnd_topmost Places The window above all non-topmost windows. The window

Maintains its topmost position even as it is deactivated.

Set Value of Wflag

Swp_drawframe draws a frame (defined in the window ' s class description) around the window.

Swp_framechanged sends a WM_NCCALCSIZE message to the window, which even if the window ' s size is not being changed. IF This flag isn't specified, Wm_nccalcsize is sent only when the window ' s size is being changed.

Swp_hidewindow hides the window.

Swp_noactivate does not activate the window. IF This flag isn't set, the window is activated and moved to the top of either the topmost or non-topmost group (Dependin G on the setting of the Hwndinsertafter parameter).

Swp_nocopybits discards the entire contents of the client area. IF This flag isn't specified, the valid contents of the client area are saved and copied The window is sized or repositioned.

Swp_nomove retains the current position (ignores the x and Y parameters).

Swp_nosize retains the current size (ignores the CX and CY parameters).

Swp_noredraw does not redraw changes. IF This flag is set, no repainting of the any kind occurs. This is applies to the client area, the nonclient area (including the title bar and scroll bars), and the Window uncovered as a result of the

Swp_nozorder retains the current Z-order (ignores the Hwndinsertafter parameter).

Swp_showwindow Displays the window.

Example

Const SWP_NOMOVE = &H2
Const SWP_NOSIZE = &H1
Const FLAG = SWP_NOMOVE Or SWP_NOSIZE
Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2
Const HWND_TOP = 0
Const HWND_BOTTOM = 1
Private 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
Private Sub Command1_Click()
Call SetWindowPos(Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, FLAG)
End Sub
Private Sub Command2_Click()
Call SetWindowPos(Me.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, FLAG)
End Sub

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.