home *** CD-ROM | disk | FTP | other *** search
/ Dan Appleman's Visual Bas…s Guide to the Win32 API / Dan.Applmans.Visual.Basic.5.0.Programmers.Guide.To.The.Win32.API.1997.Ziff-Davis.Press.CD / VB5PG32.mdf / articles / vbdev / source / frmspool.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-01-22  |  4.6 KB  |  129 lines

  1. VERSION 4.00
  2. Begin VB.Form frmSpoolWatch 
  3.    Appearance      =   0  'Flat
  4.    BackColor       =   &H80000005&
  5.    Caption         =   "SpoolWatch"
  6.    ClientHeight    =   1290
  7.    ClientLeft      =   1095
  8.    ClientTop       =   1485
  9.    ClientWidth     =   4935
  10.    BeginProperty Font 
  11.       name            =   "MS Sans Serif"
  12.       charset         =   1
  13.       weight          =   700
  14.       size            =   9.75
  15.       underline       =   0   'False
  16.       italic          =   0   'False
  17.       strikethrough   =   0   'False
  18.    EndProperty
  19.    ForeColor       =   &H00000000&
  20.    Height          =   1695
  21.    Icon            =   "FRMSPOOL.frx":0000
  22.    Left            =   1035
  23.    LinkTopic       =   "Form1"
  24.    ScaleHeight     =   86
  25.    ScaleMode       =   3  'Pixel
  26.    ScaleWidth      =   329
  27.    Top             =   1140
  28.    Width           =   5055
  29.    Begin VB.CheckBox chkAnnounce 
  30.       Appearance      =   0  'Flat
  31.       BackColor       =   &H80000005&
  32.       Caption         =   "Announce Print Status"
  33.       BeginProperty Font 
  34.          name            =   "MS Sans Serif"
  35.          charset         =   1
  36.          weight          =   700
  37.          size            =   8.25
  38.          underline       =   0   'False
  39.          italic          =   0   'False
  40.          strikethrough   =   0   'False
  41.       EndProperty
  42.       ForeColor       =   &H80000008&
  43.       Height          =   255
  44.       Left            =   1680
  45.       TabIndex        =   0
  46.       Top             =   720
  47.       Value           =   1  'Checked
  48.       Width           =   2535
  49.    End
  50.    Begin VBX.ccSubClassDemo SubClass1 
  51.       CtlParam        =   "frmSpoolWatch"
  52.       Left            =   480
  53.       Messages        =   "FRMSPOOL.frx":030A
  54.       Retval20Mode    =   0   'False
  55.       Top             =   360
  56.    End
  57.    Begin VB.Label Label1 
  58.       Appearance      =   0  'Flat
  59.       BackColor       =   &H80000005&
  60.       Caption         =   "0 jobs in queue"
  61.       BeginProperty Font 
  62.          name            =   "MS Sans Serif"
  63.          charset         =   1
  64.          weight          =   700
  65.          size            =   8.25
  66.          underline       =   0   'False
  67.          italic          =   0   'False
  68.          strikethrough   =   0   'False
  69.       EndProperty
  70.       ForeColor       =   &H80000008&
  71.       Height          =   255
  72.       Left            =   1680
  73.       TabIndex        =   1
  74.       Top             =   300
  75.       Width           =   2595
  76.    End
  77. Attribute VB_Name = "frmSpoolWatch"
  78. Attribute VB_Creatable = False
  79. Attribute VB_Exposed = False
  80. Option Explicit
  81. Dim PrintmanIcon%       ' Icon used by print manager
  82. Dim CurrentJobCount%    ' Number of jobs left in spooler
  83. Private Sub Form_Load()
  84.     PrintmanIcon = GetPrintmanIcon()
  85. End Sub
  86. ' Always cleanup afterwards -
  87. Private Sub Form_Unload(Cancel As Integer)
  88.     Dim di%
  89.     If PrintmanIcon <> 0 Then di% = DestroyIcon(PrintmanIcon)
  90. End Sub
  91. Private Sub SubClass1_WndMessage(wnd As Integer, msg As Integer, wp As Integer, lp As Long, retval As Long, nodef As Integer)
  92.     Dim ps As PAINTSTRUCT
  93.     Dim dc%
  94.     Dim di%, dl&
  95.     Dim jobcnt$
  96.     Dim soundfile$
  97.     Dim usepath$
  98.     Dim prevjobcount%
  99.     Dim doannounce%
  100.     Select Case msg
  101.         Case WM_SPOOLERSTATUS
  102.                 prevjobcount% = CurrentJobCount%
  103.                 CurrentJobCount% = lp And &H7FFF
  104.                 label1.Caption = Str$(CurrentJobCount%) & " jobs in queue"
  105.                 Refresh
  106.                 If CurrentJobCount% = 0 Or CurrentJobCount% > prevjobcount% Then doannounce = True
  107.                 If chkAnnounce And doannounce Then
  108.                     usepath$ = App.Path
  109.                     If right$(usepath$, 1) <> "\" Then usepath$ = usepath$ & "\"
  110.                     If CurrentJobCount% = 0 Then usepath$ = usepath$ & "swempty.wav" Else usepath$ = usepath$ & "swnewjob.wav"
  111.                     di% = sndPlaySound(usepath$, SND_SYNC Or SND_NODEFAULT)
  112.                 End If
  113.         
  114.         
  115.         Case WM_PAINT
  116.                 If Me.WindowState = 1 And PrintmanIcon <> 0 Then
  117.                     ' If it's minimized, do a typical icon draw
  118.                     dc% = BeginPaint(wnd, ps)
  119.                     di% = DrawIcon(ps.hDC, 1, 1, PrintmanIcon)
  120.                     jobcnt$ = Str$(CurrentJobCount)
  121.                     di% = TextOut(ps.hDC, (32 - TextHeight(jobcnt$)) \ 2, (32 - TextWidth(jobcnt$)) \ 2, jobcnt$, Len(jobcnt$))
  122.                     EndPaint wnd, ps
  123.                     ' And don't allow VB to do it's icon draw!
  124.                     nodef = True
  125.                     retval = 0
  126.                 End If
  127.     End Select
  128. End Sub
  129.