home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / cdtray1a / form1.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-09-29  |  4.0 KB  |  117 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   5295
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   7755
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   5295
  10.    ScaleWidth      =   7755
  11.    StartUpPosition =   3  'Windows Default
  12.    Visible         =   0   'False
  13.    Begin VB.PictureBox Picture1 
  14.       Height          =   615
  15.       Left            =   600
  16.       Picture         =   "Form1.frx":0000
  17.       ScaleHeight     =   555
  18.       ScaleWidth      =   555
  19.       TabIndex        =   1
  20.       Top             =   480
  21.       Width           =   615
  22.    End
  23.    Begin VB.CommandButton command1 
  24.       Caption         =   "Command1"
  25.       Height          =   495
  26.       Left            =   360
  27.       TabIndex        =   0
  28.       Top             =   1560
  29.       Width           =   1335
  30.    End
  31.    Begin VB.Menu mnuMain 
  32.       Caption         =   "&Main"
  33.       Visible         =   0   'False
  34.       Begin VB.Menu mnuExit 
  35.          Caption         =   "&Exit"
  36.       End
  37.    End
  38. Attribute VB_Name = "Form1"
  39. Attribute VB_GlobalNameSpace = False
  40. Attribute VB_Creatable = False
  41. Attribute VB_PredeclaredId = True
  42. Attribute VB_Exposed = False
  43. ' Force declare of all variables in this project
  44. Option Explicit
  45. 'Window messages that identify mouse action
  46. Private Const WM_MOUSEMOVE = &H200
  47. Private Const WM_LBUTTONDOWN = &H201
  48. Private Const WM_LBUTTONUP = &H202
  49. Private Const WM_LBUTTONDBLCLK = &H203
  50. Private Const WM_RBUTTONDOWN = &H204
  51. Private Const WM_RBUTTONUP = &H205
  52. Private Const WM_RBUTTONDBLCLK = &H206
  53. Private Const WM_MBUTTONDOWN = &H207
  54. Private Const WM_MBUTTONUP = &H208
  55. Private Const WM_MBUTTONDBLCLK = &H209
  56. ' declare a new instance of the clsCDTray class
  57. Public MyCdTray As New clsCDTray
  58. 'declare a new instance of CSysTrayIcon
  59. Public MySysTray As New CSystrayIcon
  60. Private Sub Form_Load()
  61.         
  62.     ' This funtion block initializes cd to ready and open to commands
  63.     MyCdTray.InitCD
  64.       
  65.     ' set the Status flag to False to indcate the CD Tray is closed
  66.     MyCdTray.CdTrayOpen = False
  67.     ' change tooltip message to closed
  68.     MySysTray.PopUpMessage = "CD Tray (Closed)"
  69.     ' add the icon to the System Tray
  70.     MySysTray.Initialize hWnd, Picture1.Picture, MySysTray.PopUpMessage
  71.     MySysTray.ShowIcon
  72. End Sub
  73. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  74.   'When the callback message of CSystrayIcon is WM_MOUSEMOVE,
  75.   'the X of Form_MouseMove is used to see what happen to the
  76.   'icon in the systray.
  77.   Dim msgCallBackMessage As Long
  78.   'To be able to compare the callback value to the window message,
  79.   'we must divide X by Screen.TwipsPerPixelX. That represent the
  80.   'horizontal number of twips in the screen. (1 pixel ~= 15 twips)
  81.   msgCallBackMessage = X / Screen.TwipsPerPixelX
  82.   Select Case msgCallBackMessage
  83.     Case WM_MOUSEMOVE
  84.       MySysTray.TipText = MySysTray.PopUpMessage
  85.       
  86.     Case WM_LBUTTONDOWN
  87.        ' very simple - check status of tray and perform appropriate action
  88.     If MyCdTray.CdTrayOpen = False Then    ' Tray is closed
  89.         
  90.         MyCdTray.OpenCDTray             ' open/eject  tray
  91.         
  92.         ' set the Status flag to True to indcate the CD Tray is open
  93.         MyCdTray.CdTrayOpen = True
  94.      
  95.         ' change tooltip message to open
  96.         MySysTray.PopUpMessage = "CD Tray (Open)"
  97.         
  98.     Else
  99.         MyCdTray.CloseCDTray            ' close em up
  100.         
  101.         ' set the Status flag to False to indcate the CD Tray is closed
  102.         MyCdTray.CdTrayOpen = False
  103.         ' change tooltip message to closed
  104.         MySysTray.PopUpMessage = "CD Tray (Closed)"
  105.         
  106.     End If
  107.      
  108.      Case WM_RBUTTONDOWN
  109.         Form1.PopupMenu mnuMain
  110.    End Select
  111. End Sub
  112. Private Sub Form_Unload(Cancel As Integer)
  113. MySysTray.HideIcon
  114. End Sub
  115. Private Sub mnuExit_Click()
  116. End Sub
  117.