PRB: Automation Error (-2147417843) Using the System TrayID: Q190523
|
When using the Shell_NotifyIcon API or the SysTray control sample from the
Visual Basic CD-ROM, you may receive the following error message:
Run-time error: -2147417843 (8001010d)
Automation Error
The run-time error occurs because you are trying to make an Automation call
to an out-of-process (ActiveX) EXE from within the event notification of
the system tray callback. The value -2147417843 translates to the following
error message:
An outgoing call cannot be made since the application is dispatching an input-synchronous call.
Avoid making outgoing Automation calls during the System Tray callback. If an Automation method needs to be called in response to a user event involving the System Tray, use a simple Timer to post yourself a message, and then let the callback function complete. When the Timer event fires, you can safely call your Automation method.
This behavior is by design.
Option Explicit
Private oWord As Object
Private Sub Form_Load()
Set oWord = CreateObject("Word.Application")
Set cSysTray1.TrayIcon = Me.Icon
cSysTray1.InTray = True
End Sub
Private Sub Form_Unload(Cancel As Integer)
cSysTray1.InTray = False
Set oWord = Nothing
End Sub
Private Sub cSysTray1_MouseDblClick(Button As Integer, Id As Long)
oWord.Visible = True
End Sub
Option Explicit
Private oWord As Object
Private Sub Form_Load()
Set oWord = CreateObject("Word.Application")
Set cSysTray1.TrayIcon = Me.Icon
cSysTray1.InTray = True
Timer1.Enabled = False
Timer1.Interval = 10
End Sub
Private Sub Form_Unload(Cancel As Integer)
cSysTray1.InTray = False
Set oWord = Nothing
End Sub
Private Sub cSysTray1_MouseDblClick(Button As Integer, Id As Long)
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Timer1.Enabled = False
oWord.Visible = True
End Sub
For additional information, please see the following article in the
Microsoft Knowledge Base:
Q176085 : HOWTO: Use the System Tray Directly from Visual Basic 5.0
Additional query words: kbVBp kbdsd kbDSupport kbVBp500 kbVBp600 kbAutomation
Keywords :
Version :
Platform : WINDOWS
Issue type : kbprb
Last Reviewed: May 25, 1999