home *** CD-ROM | disk | FTP | other *** search
- Attribute VB_Name = "basShared"
- '*********************************************************************
- ' SHARED.BAS - This module contains code that is shared by two or
- ' more modules.
- '*********************************************************************
- Option Explicit
- '*********************************************************************
- ' Declare SetWindowPos for AlwaysOnTop.
- '*********************************************************************
- #If Win32 Then
- Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd&, _
- 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 Boolean
- #Else
- Private Declare Function SetWindowPos Lib "User" (ByVal hWnd%, _
- ByVal hb%, ByVal x%, ByVal y%, ByVal cx%, ByVal cy%, _
- ByVal FLAGS%) As Integer
- #End If
- '*********************************************************************
- ' Forces a window to stay in front of all other windows.
- '*********************************************************************
- Public Sub AlwaysOnTop(FormName As Form, TopMost As Boolean)
- Const HWND_TOPMOST = -1
- Const HWND_NOTOPMOST = -2
- Const SWP_NOSIZE = &H1
- Const SWP_NOMOVE = &H2
- Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
- '*****************************************************************
- ' Set the window to TopMost, and ignore the return value.
- '*****************************************************************
- If TopMost Then
- SetWindowPos FormName.hWnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS
- '*****************************************************************
- ' Otherwise, return the window to its normal non-topmost state.
- '*****************************************************************
- Else
- SetWindowPos FormName.hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, FLAGS
- End If
- End Sub
- '*********************************************************************
- ' Displays and unloads the splash form.
- '*********************************************************************
- Public Sub SplashVisible(bState As Boolean, Optional ByVal sCaption)
- If bState Then
- sCaption = IIf(IsMissing(sCaption), "Loading...Please Wait!", _
- sCaption)
- With frmSplash
- .lblMessage = sCaption
- .Show
- .Refresh
- End With
- Else
- DoEvents
- Unload frmSplash
- End If
- End Sub
- '*********************************************************************
- ' This Procedure draws a 3D button (in either a up or down state),
- ' draws a picture, and prints a caption.
- '*********************************************************************
- Public Sub DrawButton(pBox As PictureBox, IsDown As Boolean, _
- IsResource As Boolean, Optional ByVal sCaption, _
- Optional ByVal sIcon)
- Dim Offset%, where%, sTag$
- '*****************************************************************
- ' If the button is supposed to be down, then offset it by 2 pixels.
- '*****************************************************************
- On Error Resume Next
- If IsDown Then Offset = 2
- '*****************************************************************
- ' The tag can contain a caption and a name of a sIcon. The format
- ' is "sCaption|sIcon". If a caption and icon were provided, then
- ' the tag is ignored.
- '*****************************************************************
- sTag = Trim(pBox.Tag)
- where = InStr(sTag, "|")
- If sTag <> "" Then
- sCaption = IIf(IsMissing(sCaption), Left(sTag, where - 1), _
- sCaption)
- sIcon = IIf(IsMissing(sIcon), Mid(sTag, where + 1), sIcon)
- Else
- sCaption = IIf(IsMissing(sCaption), "", sCaption)
- sIcon = IIf(IsMissing(sIcon), "", sIcon)
- End If
- '*****************************************************************
- ' Clear the picture box, and redraw the 3D effect.
- '*****************************************************************
- pBox.Cls
- Draw3DPicBorder pBox, IsDown
- '*****************************************************************
- ' Paint the picture from a file, or icon resource, then vertically
- ' center position for the caption.
- '*****************************************************************
- With pBox
- If IsResource Then
- .PaintPicture LoadResPicture(sIcon, vbResIcon), 10, _
- ((pBox.Height / 2) - 16) + Offset
- Else
- .PaintPicture LoadPicture(sIcon), 10, 4 + Offset
- End If
- .CurrentY = (pBox.Height / 2) - (pBox.TextHeight("X") / 2) _
- + Offset
- .CurrentX = 52
- End With
- '*****************************************************************
- ' Draw the caption.
- '*****************************************************************
- pBox.Print sCaption
- End Sub
-