Results 1 to 7 of 7

Thread: Visual BASIC Syntax check for .NET addin

  1. #1
    Newbie
    Join Date
    May 2005
    Posts
    46

    Visual BASIC Syntax check for .NET addin

    I am trying the simplist of .NET addins using Visual BASIC Studio 2005. I am not an object oriented programming expert --- using this as a learning experience!

    I have boiled down an example into the following to simply toggle the screen between fullscreen and windowed...I have followed the instructions of the C# sample, incluing putting the .dll in the Addins directory under the GUID, making the dll COM visible etc. Here is my visual basic code:

    ============================
    Code:
    Imports System.Runtime.InteropServices
    
    Namespace PDAKey
    
        <GuidAttribute("0304F473-515A-45ab-BE2E-E93419F21CB8"), ProgId("StreetDeck.PDAKey"), ComVisible(True)> _
           Public Class Class1
            Implements StreetDeck.IDualStreetDeckAddin
    
            Dim app As StreetDeck.StreetDeckApp
    
            Public Sub OnConnection(ByVal Application As Object, ByVal eConnectMode As StreetDeck.enumAddinConnectMode) Implements StreetDeck.IDualStreetDeckAddin.OnConnection
    
                app.SendFunction(StreetDeck.enumSDFunctions.eFunctionToggleFullscreen)
    
            End Sub
    
            Public Sub OnDisconnect() Implements StreetDeck.IDualStreetDeckAddin.OnDisconnect
    
            End Sub
    
    
        End Class
    
    End Namespace
    =========================

    The app builds and is in the addins directory under the GUID. When I run StreetDeck and look under Digital Mods within StreetDeck, it says that the Digital mod that I have created is 'stopped'

    Firstly, is my syntax correct for the above code, particular for the 'DIM app..' statement and use of 'app' for the app.sendfunction call...

    I have only created a script project withn StreetDeck..it is not clear to me what magic within StreetDeck looks within the 'addins' directory under the GUID to pull in the dll. I have not defined a scripted overlay or a module as I am not intending to script anything within StreetDeck (for this simple test case). I simply want the addin to be loaded, toggle the screen to confirm that I am connecting 'all of the dots correctly'

    I am sure others will want to use Visual BASIC to create a .NET addin, and hopefuly this thread will provide a tutorial of benefit.

    Thanks
    SLOJAM

    1972 'slightly enhanced' 240Z
    Epia M10000 Win XP
    Creative Soundblaster Audigy 2 ZS
    7" Touchscreen XMPCR GPS

  2. #2
    Newbie
    Join Date
    May 2005
    Posts
    46
    Can any of you C# experts help translate the syntax of this code snippet into a Visual Basic call....it's from the example code. Apologies if this is elemental!

    Thanks!

    Code:
          StreetDeck.Panel btnShowOverlay = (StreetDeck.Panel) module.CreatePanel(StreetDeck.enumCreatePanelType.eCPTButton, "BUTTON.LISTITEM_HIGH", 
                                               "ShowOverlay", //This is the function name that will be given back to us in any OnExec call and for all intents and purposes is the name of this panel 
                                               app.GetSystemMetric(StreetDeck.enumSystemMetrics.eSMGenericModuleClientX),
                                               app.GetSystemMetric(StreetDeck.enumSystemMetrics.eSMGenericModuleClientY),
                                               200, 200);
    SLOJAM

    1972 'slightly enhanced' 240Z
    Epia M10000 Win XP
    Creative Soundblaster Audigy 2 ZS
    7" Touchscreen XMPCR GPS

  3. #3
    Newbie
    Join Date
    Aug 2006
    Posts
    51
    I think you have to do something like:

    Code:
    Public Sub OnConnection(ByVal Application As Object, ByVal eConnectMode As StreetDeck.enumAddinConnectMode) Implements StreetDeck.IDualStreetDeckAddin.OnConnection
            app = Application
            app.SendFunction(StreetDeck.enumSDFunctions.eFunctionToggleFullscreen)
    
    End Sub
    Try that out and see if it works.

    Can any of you C# experts help translate the syntax of this code snippet into a Visual Basic call....it's from the example code. Apologies if this is elemental!
    As for this...

    Code:
    Dim myModule As StreetDeck.ScriptModule
    myModule = app.CreateModule("MyModule")
    Dim btnShowOverlay As StreetDeck.Panel
    btnShowOverlay = myModule.CreatePanel(StreetDeck.enumCreatePanelType.eCPTButton, _
       "BUTTON.LISTITEM_HIGH", "ShowOverlay", _
       app.GetSystemMetric(StreetDeck.enumSystemMetrics.eSMGenericModuleClientX), _
       app.GetSystemMetric(StreetDeck.enumSystemMetrics.eSMGenericModuleClientY), 200, 200)
    Kind of messy, but it gets the job done. the "_" are to put one line of code on several lines to make it easier to read instead of having one huge long line of code that scrolls off the page.

  4. #4
    Newbie
    Join Date
    May 2005
    Posts
    46
    Pogi,

    Thanks for your help. Still not toggling the screen.

    If I create the .dll (which I am) and place it in the addins directory, do I need to do anything within StreetDeck other than create the script project as outlined in the tutorial, which creates the GUID and GUID directory to actually have the addin 'run'? In other words, should I create a superficial script overlay within StreetDeck to kickstart the addin? It seems in the Com++ example that is the case. Again, apologies for simple questions...

    The fact that StreetDeck indicates that my DigMod is 'stopped' is the root of my question.

    Thanks any and all for wisdom...I am sure it will help others.
    SLOJAM

    1972 'slightly enhanced' 240Z
    Epia M10000 Win XP
    Creative Soundblaster Audigy 2 ZS
    7" Touchscreen XMPCR GPS

  5. #5
    Newbie
    Join Date
    May 2005
    Posts
    46
    Got it running...I had a problem within Visual Studio where I had declared a 'root namespace' on the application tab within Studio for this application, which basically prefixes to the Namespace given within the .vb file...e.g. instead of PDAKey.Class, the build was PDAKey.PDAKey.Class as I had used the root namespace field. I left that blank and I was then able to link to the dll as an exposed object properly.

    Also, no need to do anything in script overlay to get the addin to load and execute On_Create as I was suspecting.
    SLOJAM

    1972 'slightly enhanced' 240Z
    Epia M10000 Win XP
    Creative Soundblaster Audigy 2 ZS
    7" Touchscreen XMPCR GPS

  6. #6
    Newbie
    Join Date
    Aug 2006
    Posts
    51
    Sweet! Time to write some kick-*** addins!

  7. #7
    Newbie
    Join Date
    May 2005
    Posts
    46
    For those interested...below is the simple 'Example1' that Chuck wrote in C# transposed into Visual BASIC 2005.

    Code:
    Imports System.Runtime.InteropServices
    Imports System.Diagnostics
    
    
    Namespace StreetDeckVBAddin
    
        <GuidAttribute("0304F473-515A-45ab-BE2E-E93419F21CB8"), ProgId("StreetDeckVBAddin.Class1")> _
        Public Class Class1
            Implements StreetDeck.IDualStreetDeckAddin
    
            Public app As StreetDeck.StreetDeckApp
            Dim MyModule As StreetDeck.ScriptModule
            Dim overlay As StreetDeck.ScriptOverlay
            Dim btnShowOverlay As StreetDeck.Panel
    
            Public Sub OnConnection(ByVal Application As Object, ByVal eConnectMode As StreetDeck.enumAddinConnectMode) Implements StreetDeck.IDualStreetDeckAddin.OnConnection
                app = Application                       ' setup local reference to Object
                MyModule = app.CreateModule("ModuleName")
    
                btnShowOverlay = MyModule.CreatePanel(StreetDeck.enumCreatePanelType.eCPTButton, _
                "BUTTON.LISTITEM_HIGH", "ShowOverlay", _
                app.GetSystemMetric(StreetDeck.enumSystemMetrics.eSMGenericModuleClientX), _
                app.GetSystemMetric(StreetDeck.enumSystemMetrics.eSMGenericModuleClientY), _
                200, 200)
    
                btnShowOverlay.Caption = "Show Overlay"
                overlay = app.CreateOverlay("OverlayTest")
    
                ' Register for events
                AddHandler MyModule.OnExec, AddressOf module_OnExec
    
            End Sub
    
    
            Public Sub OnDisconnect() Implements StreetDeck.IDualStreetDeckAddin.OnDisconnect
                RemoveHandler MyModule.OnExec, AddressOf module_OnExec
            End Sub
    
            Public Function module_OnExec(ByVal Description As String, ByVal eEM As StreetDeck.enumExecMessage, ByVal wParam As Int32) As Boolean
                If (Description = "ShowOverlay") Then
                    If (eEM = StreetDeck.enumExecMessage.eEMSelect) Then
                        overlay.Visible = Not (overlay.Visible)
                        overlay.MsgBox("Overlay Visibility Changed!", "Button Clicked")
                        Return True
                    End If
                End If
                Return False
            End Function
    
    
    
        End Class
    
    End Namespace
    I first wrote this using the free 'Express' version of Visual BASIC, which is good enough except it does not allow you to run an external program (StreetDeck) for debugging purposes. I downloaded the 90 day trial of Visual Studio, which allowed me to trace through the execution of the .dll and find a couple of bugs/issues -- a really neat capability not available in the Express version.

    At any rate, I hope the above snippet helps those of you looking to write something in Visual BASIC as a .NET addin - I have learned a lot about object oriented programming and will now move on to creating a 'real' app.
    SLOJAM

    1972 'slightly enhanced' 240Z
    Epia M10000 Win XP
    Creative Soundblaster Audigy 2 ZS
    7" Touchscreen XMPCR GPS

Similar Threads

  1. Damn visual basic
    By BiohazrD in forum Software & Software Development
    Replies: 2
    Last Post: 02-04-2005, 01:10 PM
  2. Return from Hibernate - Visual Basic
    By Laidback in forum Software & Software Development
    Replies: 3
    Last Post: 01-28-2005, 01:41 PM
  3. i need a visual basic OCX for an generic infrared receiver
    By babas151 in forum Software & Software Development
    Replies: 9
    Last Post: 04-20-2002, 02:10 AM
  4. visual basic programming
    By mr0range in forum Software & Software Development
    Replies: 1
    Last Post: 11-07-2001, 04:39 PM
  5. Visual Basic HD44780 OCX, please?
    By Christian in forum Software & Software Development
    Replies: 4
    Last Post: 05-15-2000, 01:46 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •