Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Embed Extra in .NET form 1

Status
Not open for further replies.

streetprog

Technical User
Nov 9, 2006
41
US
I started developing Extra! macros a few years ago and quickly moved into VBA to interact with Extra! sessions due to improved performance and functionality. I've now gotten into .NET and have begun development of better tools but don't love having to switch back and forth from the .NET app and Extra. Ideally I would love to build a .NET that sits on top of the session, allowing users to type in the application as they would in Extra but also have quick access to .NET menus and tools.

In other words, I want custom menus and tools that I can't build in Extra Basic macros/forms yet have that close tie with the session instead of running two apps like I do with VBA.

I've read a little about Host Integration Server but got lost and I don't know that this is an option. Is there a way I can embed Extra in my app or at least dock my form around Extra? Or a better idea?
 
Nope.... I have PCOMM and Attachmate at work, and the only emulator that allows this is PCOMM, using Java Beans
 
Gotcha. I figured it would be something like that. I don't know that licenscing PCOMM is an option for me, but I've been playing around with a "no extra cost" solution that might do what I want, although not as slick as an emulator. I was able to create a .NET form with a transparent panel and "dock" EXTRA inside the panel. When EXTRA is docked, resizing/moving the form also resizes and moves EXTRA. I also figured out how to lock keyboard entry so that while .NET code is executing in EXTRA, user input is not allowed.
 
How were you able to "dock" Extra inside the panel? i am trying to do this as well.
 
I'm posting the pertinent code from my form. You'll need to create the following but change whatever you don't like to fit your needs:
- form (frmMain) with a MenuStrip at the top and a StatusStrip as the bottom. The default size is 800x600.
- panel (pnlEXTRA) with the BackColor set equal to your form's TransparencyKey color. I set the Dock = Fill which makes it 784x518. Making the panel transparent allows you to see through the panel and click through it as well which allows the form to sit around EXTRA and still allow you to click directly in it.
- MenuItem (DockSessionToolStripMenuItem) that fires the Dock/Undock session sub
- button (btnBringToFront) - this fires off ActivateExtra which just brings focus to the docked Session in the panel. Is useful when EXTRA gets lost behind other windows or is minimized.

I refer to the EXTRA object as G.mySess which is a global variable I store in a module. I din't include the code I use to initialize the session object, but you probably already have that. I cut out this code from my form so I hope I gave you all you need. It should give you a general idea to get started though.

Code:
'I have this enum in another class but you can use it in the form as well
'I did this because the EXTRA object doesn't specify which numbers
'pertain to what window state
    Public Enum SessionWindowState
        Minimized = 0
        Restore = 1
        Maximized = 2
    End Enum

Public Class frmMain
    Public IsDocked As Boolean = False
    
    'These variables are set prior to docking so that if the user undocks EXTRA,
    'it will return to it's original location on the screen
    Private eTop As Integer, eLeft As Integer, eHeight As Integer, eWidth As Integer, eWindowState As SessionWindowState

    Private Sub DockSessionToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DockSessionToolStripMenuItem.Click
        DockExtra(Not IsDocked)
        ActivateExtra()
    End Sub

    Private Sub ActivateExtra()
        'Because the form and EXTRA aren't the same application, EXTRA can get
	'lost behind other windows at times; this brings it to focus
        If IsDocked Then
            If G.mySess.WindowState = SessionWindowState.Minimized Then
                G.mySess.WindowState = SessionWindowState.Restore
            End If
            AppActivate(G.mySess.Name + " - EXTRA! for NetWare")
        End If
    End Sub

    Private Sub DockExtra(ByVal Dock As Boolean)
        Try
            IsDocked = Dock
            btnBringToFront.Visible = Dock

            Select Case Dock
                Case False
                    With G.mySess
                        If eTop <> 0 AndAlso .WindowState <> SessionWindowState.Minimized AndAlso eTop > 0 Then
			    'reset EXTRA's size to what it was prior to docking
                            .Top = eTop
                            .Left = eLeft
                            .Height = eHeight
                            .Width = eWidth
                            .WindowState = eWindowState
                        End If

                    End With

                    DockSessionToolStripMenuItem.Text = "&Dock Session"
                Case True
                    GetSessionSize()
                    SizeForm()
                    SizeExtra()

                    DockSessionToolStripMenuItem.Text = "&Undock Session"
            End Select
        Catch ex As Exception

        End Try

    End Sub


    Private Sub GetSessionSize()
        If Me.Visible = True Then
            With G.mySess
                eTop = .Top
                eLeft = .Left
                eHeight = .Height
                eWidth = .Width
                'Extra WindowState: 0=Minimized,1=Restore,2=Maximized
                eWindowState = .WindowState
            End With
        End If
    End Sub

    Private Sub SizeExtra()
        With G.mySess
            If pnlEXTRA.Height > 0 Then
                .WindowState = 1
                .Top = Me.Top + pnlEXTRA.Top + 29
                .Left = Me.Left + pnlEXTRA.Left + 9
                .Height = pnlEXTRA.Height
                .Width = pnlEXTRA.Width + 5
            End If
        End With
    End Sub

    Private Sub frmMain_Move(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Move, MyBase.ResizeEnd
        If Me.Visible = True AndAlso IsDocked = True AndAlso Me.Top > 0 Then
            SizeExtra()
        End If
    End Sub

    Private Sub btnBringToFront_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBringToFront.Click
        ActivateExtra()
    End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top