SendMessage issue

Add-in Express™ Support Service
That's what is more important than anything else

SendMessage issue
 
Nathan Wright




Posts: 6
Joined: 2008-12-12
Hi

I have created a simple toolbar which has a label on it called txtLabel and a button called btnPopup. The onClick event for btnPopup is form1.show().

In the toolbar I am trapping the OnSendMessage event which has a txtLabel.text="hello"

My problem is I need to be able to fire the OnSendMessage event from the form1 form but I cannot get it to work.

I have looked at the search example and am still confused and cannot find an answer on the forum.

Please can you provide some pointers as to how I fire the sendmessage from the form1.

Thanks

Nathan
Posted 16 Dec, 2008 09:39:13 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hello Nathan,

Could you please specify which of our products you use? Is it Add-in Express for Office or Add-in Express for Internet Explorer?

Posted 16 Dec, 2008 11:14:39 Top
Nathan Wright




Posts: 6
Joined: 2008-12-12
Sorry I should have said, Internet Explorer.
Posted 16 Dec, 2008 18:39:51 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hello Nathan,

Thank you. Please try to use the code below:

Dim myModule As IEModule = AddinExpress.IE.ADXIEModule.CurrentInstance.Item(AppDomain.GetCurrentThreadId())
myModule.SendMessageToAll(...)


Also, yesterday we found out that the SendMessageToAll method has stopped working for some reason. Now we are trying to find a solution.


Posted 17 Dec, 2008 08:11:41 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hello Nathan,

The SendMessageToAll method works fine. Please see the code below to see how you can do what you described in your first post:

' Additional class with constants
Friend Class Constant
    'window messages
    Public Shared ReadOnly WM_USER As Integer = 1024
    'custom
    Public Shared ReadOnly WM_TEST As Integer = WM_USER + 2000
End Class

    ' ADXIEToolbar
    Private Sub btnPopup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPopup.Click
        Dim frm As Form1 = New Form1()
        frm.Show()
    End Sub

    Private Sub MyIEToolBar1_OnSendMessage(ByVal e As AddinExpress.IE.ADXIESendMessageEventArgs) Handles MyBase.OnSendMessage
        If e.Message = Constant.WM_TEST Then
            txtLabel.Text = "hello"
        End If
    End Sub

    ' Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim myModule As IEModule = AddinExpress.IE.ADXIEModule.CurrentInstance.Item(AppDomain.GetCurrentThreadId())
        myModule.ToolBars.Item(0).ToolBarObj.SendMessage(Constant.WM_TEST, IntPtr.Zero, IntPtr.Zero)
    End Sub



Posted 19 Dec, 2008 09:27:23 Top