New form freezes on CommandBarButton.Click

T

tobias_ebsen

Hi

I'm creating a CommandBarButton for Outlook that creates a new form in
the Click event handler.


The problem is that when I show the form it seems to be frozen and
accepts no user input.


I ripped most of the code from an example found on MSDN:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnou...



But somehow there is a difference that I can't spot. Have any of you
experienced anything like this?


My code is very straight forward:


------


Dim WithEvents _inspectors As Outlook.Inspectors
Dim WithEvents _commandButton As CommandBarButton


Private Sub OnConnection(...)
_inspectors = application.Inspectors
End Sub


Private Sub OnNewInspector(...) Handles _inspectors.NewInspector
If TypeOf inspector.CurrentItem Is Outlook.MailItem Then
Dim _commandBar As CommandBar =
inspector.CommandBars("Standard")
_commandButton =
CType(_commandBar.Controls.Add(MsoControlType.msoControlButton),
CommandBarButton)
_commandButton.Caption = "Test"
_commandButton.Style = MsoButtonStyle.msoButtonCaption
_commandButton.Visible = True
End If
End Sub


Public Sub OnButtonClick(...) Handles _commandButton.Click
Dim frmTest As New TestForm()
frmTest.Show()
System.Windows.Forms.Application.DoEvents()
End Sub
 
K

Ken Slovak - [MVP - Outlook]

Does this work any better?

frmTest.Show()
frmTest.BringToFront()
 

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