Keep Outlook Note on Screen

  • Thread starter Lisa in The Lowcountry
  • Start date
L

Lisa in The Lowcountry

Can an Outlook 2003 Note be made to stay on screen, on top of what ever
windows are open?

Thanks!
 
M

Matthias Günther

"Lisa in The Lowcountry" <Lisa in The (e-mail address removed)>
schrieb im Newsbeitrag
Can an Outlook 2003 Note be made to stay on screen, on top of what ever
windows are open?


With a little VBA Code (Extras/Macro/Visual Basic Editor)

'[In ThisOutlookSession]

Option Explicit

Private WithEvents m_Inspectors As Inspectors
Private m_ThreadID As Long

Private Sub Application_StartUp()
m_ThreadID = GetCurrentThreadId
Set m_Inspectors = Application.Inspectors
End Sub

Private Sub Application_Quit()
Set m_Inspectors = Nothing
End Sub

Private Sub m_Inspectors_NewInspector(ByVal Inspector As Inspector)
If TypeOf Inspector.CurrentItem Is NoteItem Then g_Hook =
SetWindowsHookEx(WH_CBT, AddressOf WndProc, 0&, m_ThreadID)
End Sub

'[/In ThisOutlookSession]


'[In a module]

Option Explicit

Public Declare Function SetWindowsHookEx Lib "user32" _
Alias "SetWindowsHookExA" (ByVal idHook As Long, _
ByVal lpfn As Long, ByVal hmod As Long, ByVal _
dwThreadId As Long) As Long

Public Declare Function GetCurrentThreadId Lib "kernel32" () _
As Long

Private Declare Function UnhookWindowsHookEx Lib "user32" _
(ByVal hHook As Long) As Long

Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, _
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 Long

Public Const WH_CBT = 5
Private Const HCBT_ACTIVATE = 5
Private Const HWND_TOPMOST As Long = -1
Private Const SWP_NOSIZE As Long = &H1
Private Const SWP_NOMOVE As Long = &H2

Public g_Hook As Long

Public Function WndProc(ByVal uMsg As Long, ByVal wParam As Long, ByVal
lParam As Long) As Long

If uMsg = HCBT_ACTIVATE Then

Call SetWindowPos(wParam, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or
SWP_NOMOVE)
UnhookWindowsHookEx g_Hook

End If

WndProc = False

End Function

'[/In a Module]


Hope this helps

Matthias
 
M

Matthias Günther

Addition:

Example sets all notes topmost

If you need a TopMostNote only a few times change code of ThisOutlookSession
to


'[In ThisOutlookSession]

Option Explicit

Private m_ThreadID As Long

Private Sub Application_StartUp()
m_ThreadID = GetCurrentThreadId
End Sub

Public Sub TopMostNote()
Dim oTopMostNote As NoteItem

Set oTopMostNote =
Application.Session.GetDefaultFolder(olFolderNotes).Items.Add
g_Hook = SetWindowsHookEx(WH_CBT, AddressOf WndProc, 0&, m_ThreadID)
oTopMostNote.Display
Set oTopMostNote = Nothing
End Sub

'[/In ThisOutlookSession]


and add macro to your commandbar

Code in module is the same


Matthias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top