www.pudn.com > 维文输入法源代码.rar > main.frm


VERSION 5.00 
Begin VB.Form frm_Main  
   BorderStyle     =   0  'None 
   Caption         =   "TrayIcon Demo Program" 
   ClientHeight    =   480 
   ClientLeft      =   3105 
   ClientTop       =   2490 
   ClientWidth     =   450 
   Icon            =   "main.frx":0000 
   LinkTopic       =   "Form1" 
   MaxButton       =   0   'False 
   Picture         =   "main.frx":0442 
   ScaleHeight     =   480 
   ScaleWidth      =   450 
   ShowInTaskbar   =   0   'False 
   Begin VB.Image Image1  
      Height          =   480 
      Left            =   0 
      Picture         =   "main.frx":0884 
      Top             =   0 
      Width           =   480 
   End 
End 
Attribute VB_Name = "frm_Main" 
Attribute VB_GlobalNameSpace = False 
Attribute VB_Creatable = False 
Attribute VB_PredeclaredId = True 
Attribute VB_Exposed = False 
Option Explicit 
Private sToolTip As String 
Private picImage As Picture 
Private Sub Form_Load() 
     Dim iconNotify As NOTIFYICONDATA 
    Dim rVal As Long 
     On Error Resume Next 
sToolTip = "维文输入法" 
    Set picImage = Image1.Picture 
    ghWnd = Me.hWnd 
    HookWindow 
    With iconNotify 
        .cbSize = Len(iconNotify) 
        .hWnd = Me.hWnd 
        .uID = 1 
        .uFlags = NIF_MESSAGE Or NIF_ICON Or NIF_TIP 
        .uCallbackMessage = WM_LBUTTONDOWN 
        .hIcon = Image1.Picture 
        .szTip = sToolTip & Chr$(0) 
    End With 
    rVal = Shell_NotifyIcon(NIM_ADD, iconNotify) 
    Me.Hide 
     
    SetKeyboardHook Me.hWnd, WM_USER 
 
    If err.Number <> 0 Then 
        MsgBox "请先将 KeybHook.dll 复制到 Windows 的所在路径!", vbCritical 
        End 
    End If 
    On Error GoTo 0 
     
    prevWndProc = GetWindowLong(Me.hWnd, GWL_WNDPROC) 
    SetWindowLong Me.hWnd, GWL_WNDPROC, AddressOf WndProc 
    End Sub 
Private Sub Form_Resize() 
If WindowState = vbMinimized Then 
        WindowState = vbNormal 
    End If 
    End Sub 
Private Sub Form_Unload(Cancel As Integer) 
Dim iconNotify As NOTIFYICONDATA 
    Dim rVal As Long 
        Unload frm_Menu 
    Set frm_Menu = Nothing 
    With iconNotify 
        .cbSize = Len(iconNotify) 
        .hWnd = Me.hWnd 
        .uID = 1 
    End With 
    rVal = Shell_NotifyIcon(NIM_DELETE, iconNotify) 
    UnhookWindow 
    End Sub