Click here to Skip to main content
Click here to Skip to main content
Articles » Languages » VB.NET » HowTo » Downloads
 
Add your own
alternative version

ByPass difficult Automation and add applications "as is" in your .NET application

, 29 Dec 2004 CPOL
Fed up with automation? Need to add components as is to your application? Try this out.
bypassautomation.zip
ByPassAutomation
bin
ByPassAutomation.exe
MasteringAssmblyInfoFile.exe
ByPassAutomation.vbproj.user
interactwithapplications.zip
InteractWithApplications
bin
AxInterop.SHDocVw.dll
GetBrowserDom.exe
InteractWithApplications.exe
Interop.SHDocVw.dll
WindowsApplication2.exe
InteractWithApplications.vbproj.user
Imports System.Reflection
Imports System.Text
Imports System.Runtime.InteropServices
Public Class ExternalCalc
    Inherits System.Windows.Forms.Form
    ' Constants used to remove the borders of Media Player
    Private Const LEFT_CONST As Integer = 0
    Private Const RIGHT_CONST As Integer = 0
    Private Const TOP_CONST As Integer = 20
    Private Const BOTTOM_CONST As Integer = 0
#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        '
        'ExternalCalc
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(256, 206)
        Me.Name = "ExternalCalc"
        Me.Text = "ExternalCalc"

    End Sub

#End Region
    Dim p As Process
    Dim win32 As New Win32Functions
    Private Sub ExternalCalc_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim pinfo As New ProcessStartInfo("calc")
        p = System.Diagnostics.Process.Start(pinfo)
        p.WaitForInputIdle()
        win32.SetParent(p.MainWindowHandle, Me.Handle)
        win32.removeTitleBarAndRescale(p.MainWindowHandle)
        win32.SetWindowPos(p.MainWindowHandle, Me.Handle, -LEFT_CONST, -TOP_CONST, Me.Width + LEFT_CONST + RIGHT_CONST, Me.Height + TOP_CONST + BOTTOM_CONST, win32.SWP_FRAMECHANGED Or win32.SWP_NOZORDER)
    End Sub

    Private Sub ExternalCalc_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
        win32.SetForegroundWindow(p.MainWindowHandle)
        SendKeys.SendWait("^{c}")
        If Not (formParent1 Is Nothing) Then
            formParent1.TextBox1.Clear()
            formParent1.TextBox1.Paste()
            p.CloseMainWindow()
            p.Close()

        End If
    End Sub
    Dim formParent1 As Calculator
    Public Property formParent()
        Get
            formParent = formParent1
        End Get
        Set(ByVal Value)
            formParent1 = Value
        End Set
    End Property
End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Armoghan Asif
Architect
Pakistan Pakistan
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.141223.1 | Last Updated 29 Dec 2004
Article Copyright 2004 by Armoghan Asif
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid