vbAccelerator - Contents of code file: fToolWindow.frm

VERSION 5.00
Begin VB.Form frmToolWin 
   BorderStyle     =   5  'Sizable ToolWindow
   Caption         =   "Sizeable Tool WIndow"
   ClientHeight    =   3570
   ClientLeft      =   2280
   ClientTop       =   1545
   ClientWidth     =   1620
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   3570
   ScaleWidth      =   1620
   ShowInTaskbar   =   0   'False
End
Attribute VB_Name = "frmToolWin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private m_cT As New cTitleBar
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA"
 (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA"
 (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Const SWW_HPARENT = (-8)

Private Sub Form_Load()
    m_cT.Color(eActiveStartColor) = &H40C0E0
    m_cT.GradientForm Me
    Me.Show
    FormOnTopOfForm Me, mfrmMain, True
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    m_cT.GradientReleaseForm
    FormOnTopOfForm Me, mfrmMain, False
End Sub
Sub FormOnTopOfForm( _
        frmTopMost As Form, _
        frmParent As Form, _
        bState As Boolean _
    )
'**********************************************************
' Description:
'   This function sets frmTopMost as always on top of frmParent
'   if iState is True, otherwise resets to normal otherwise.
'
'   NOTE: ensure that any form which is made topmost is
'   unloaded before the Parent form, and that whenever it
'   is unloaded a call is made to this sub to reset the
'   topmost property first.  Otherwise the parent form
'   will retain a bad child form hWnd with possible GPF.
'
' Input Parameters:
'   frmTopMost  : Form object to set above frmParent
'   frmParent   : Form object to always be below frmTopMost
'   bState      : Whether to set topmost (True) or normal (False)
'
' *********************************************************
Dim iRval As Integer
    If (bState) Then
        SetWindowLong frmTopMost.hwnd, SWW_HPARENT, frmParent.hwnd
    Else
        SetWindowLong frmTopMost.hwnd, SWW_HPARENT, 0
    End If
End Sub