home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Programmer'…arterly (Limited Edition) / Visual_Basic_Programmers_Journal_VB-CD_Quarterly_Limited_Edition_1995.iso / code / ch18code / ontop.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-08-14  |  1.5 KB  |  55 lines

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   6540
  5.    ClientLeft      =   3456
  6.    ClientTop       =   876
  7.    ClientWidth     =   5772
  8.    Height          =   6864
  9.    Left            =   3408
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   6540
  12.    ScaleWidth      =   5772
  13.    Top             =   600
  14.    Width           =   5868
  15.    Begin VB.CommandButton Command1 
  16.       Caption         =   "Click me"
  17.       Height          =   852
  18.       Left            =   1080
  19.       TabIndex        =   0
  20.       Top             =   600
  21.       Width           =   1572
  22.    End
  23. Attribute VB_Name = "Form1"
  24. Attribute VB_Creatable = False
  25. Attribute VB_Exposed = False
  26. Private mbAlwaysOnTop As Boolean
  27. Public Property Get OnTop() As Boolean
  28.     OnTop = mbAlwaysOnTop
  29. End Property
  30. Private Sub Command1_Click()
  31.     Me.OnTop = Not Me.OnTop
  32.     If Me.OnTop Then
  33.         Me.Caption = "I'm always on top."
  34.     Else
  35.         Me.Caption = "I'm a normal window."
  36.     End If
  37. End Sub
  38. Public Property Let OnTop(bSetting As Boolean)
  39.     If bSetting Then
  40.         SetWindowPos Me.hWnd, _
  41.             HWND_TOPMOST, _
  42.             0, 0, 0, 0, _
  43.             SWP_NOSIZE Or SWP_NOMOVE _
  44.             Or SWP_NOACTIVATE Or SWP_SHOWWINDOW
  45.         mbAlwaysOnTop = True
  46.     Else
  47.         SetWindowPos Me.hWnd, _
  48.             HWND_NOTOPMOST, _
  49.             0, 0, 0, 0, _
  50.             SWP_NOSIZE Or SWP_NOMOVE _
  51.             Or SWP_NOACTIVATE
  52.         mbAlwaysOnTop = False
  53.     End If
  54. End Property
  55.