|
楼主 |
发表于 2010-9-10 10:56
|
显示全部楼层
Private Declare Function DrawMenuBar Lib "user32" (ByVal Hwnd As Long) As Long
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 Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Const GWL_STYLE As Long = (-16)
Private Const GWL_EXSTYLE = (-20)
Private Const WS_CAPTION As Long = &HC00000
Private Const WS_EX_DLGMODALFRAME = &H1&
Dim myOlApp As New Outlook.Application
Public WithEvents myOlItems1 As Outlook.Items
Sub ListUnReadMail()
Set myOlItems1 = myOlApp.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Items
End Sub
Sub myOlItems1_ItemAdd(ByVal Item As Object)
Dim otlk As Outlook.Application
Dim nmspc As Outlook.NameSpace
Dim mlItem As Outlook.MailItem
Dim objFolder As Outlook.MAPIFolder
Set otlk = New Outlook.Application
Set nmspc = otlk.GetNamespace("MAPI")
Set objFolder = nmspc.GetDefaultFolder(olFolderInbox)
ListAllFolders objFolder
End Sub
Sub myOlItems1_Itemchange(ByVal Item As Object)
Dim otlk As Outlook.Application
Dim nmspc As Outlook.NameSpace
Dim mlItem As Outlook.MailItem
Dim objFolder As Outlook.MAPIFolder
Set otlk = New Outlook.Application
Set nmspc = otlk.GetNamespace("MAPI")
Set objFolder = nmspc.GetDefaultFolder(olFolderInbox)
ListAllFolders objFolder
End Sub
Sub ListAllFolders(objFolder As Outlook.MAPIFolder)
Dim IStyle As Long, Hwnd As Long
'******?取窗口句柄******
If Val(Application.Version) < 9 Then
Hwnd = FindWindow("ThunderXFrame", UserForm1.Caption)
Else
Hwnd = FindWindow("ThunderDFrame", UserForm1.Caption)
End If
'******去除窗体???******
IStyle = GetWindowLong(Hwnd, GWL_STYLE)
IStyle = IStyle And Not WS_CAPTION
SetWindowLong Hwnd, GWL_STYLE, IStyle
DrawMenuBar Hwnd
'******去除窗体四周的?框******
IStyle = GetWindowLong(Hwnd, GWL_EXSTYLE) And Not WS_EX_DLGMODALFRAME
SetWindowLong Hwnd, GWL_EXSTYLE, IStyle
With UserForm1
.Label1.Caption = "UnRead: " & objFolder.UnReadItemCount
.StartUpPosition = 0
.Left = 650
.Top = 285
.Repaint
End With
UserForm1.Show 0
Set mItem = Nothing
End Sub |
|