Home Image-Pro Plus Automation with Macros
Options

Startup plug-ins in VB.Net

(Originally posted by KevinR on 6/13/2006)

The question of creating start-up dialogs in VB.Net came up from _several_ people recently - I went through the exercise, and thought the results might be interesting for Image-Pro developers. This methodology should also apply to startup dialogs written in C#.

Creating a minimal test project in VB.Net, I first specified that the module should react to standard and extended events. Keyboard and mouse were not important.

In the Invoke routine:


    Public Sub Invoke() Implements IpCom32.IPluginTask.Invoke
        fDialog = New Form1
        
        ' Show a _modal_ dialog. Do not attach to the application or 
        ' register the handle - that's not needed in this case.
        fDialog.ShowDialog()

    End Sub


To make certain this gets called, add some code to the IPlugEventEx AppOpened event:


    Public Sub AppOpened() Implements IpCom32.IPluginEventEx.AppOpened
        ' Show the startup dialog. Note the test to make certain we 
        ' have only one copy!
        If fDialog Is Nothing Then
            Call Invoke()
        End If
    End Sub


If the "Is Nothing" test is not present, you may end up with multiple copies of the dialog, resulting in some error messages.

In the .MNU file I added a hidden line to call my project on startup:


	%comitem VB Plugin, Invoke VB Plugin, ipcom32.dll, 0x480, TestVB.TestVB1


Finally, I put some text in the dialog and added a 'Done' button that calls "Close()". For a startup I set the dialog to open centered, no minimize/maximize buttons, and not resizable.

This is a _simple_ example - I encourage people wanting a log-in or other startup dialog to expand it as desired.

Sign In or Register to comment.