none
How To include ( import Programs ) RRS feed

  • Question

  • I want to make a button to make inports to other programs like AOL , MSN , OR Microsoft Word. How would i make a button to Import a program like that.

    Sunday, March 30, 2008 3:25 PM

Answers

  • Hi Dtecneon,

     

    Based on my understanding, you intend to run external applications (such as AOL , MSN , OR Microsoft Word) on Windows Form (.NET) when clicking Button.

     

    Here are some approaches for you to try:

     

    1. Run application on Panel control inside VB.NET Form throught Process.Start method and P/Invoke API.

    Prerequisites: Button1 and Panel1 on Form1.

    Code Block

    Imports System.Runtime.InteropServices

     

    Public Class Form1

     

        Private Const WM_SYSCOMMAND As Integer = 274

        Private Const SC_MAXIMIZE As Integer = 61488

        Declare Auto Function SetParent Lib "user32.dll" (ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As Integer

        Declare Auto Function SendMessage Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer

     

       Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

            'Run Notepad application inside Panel1 control

            Dim proc As Process

            proc = Process.Start("Notepad.exe")

            proc.WaitForInputIdle()

            SetParent(proc.MainWindowHandle, Me.Panel1.Handle)

            SendMessage(proc.MainWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0)

     

        End Sub

     

    End Class

    Trackback: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2616199&SiteID=1

     

     

    2. Another approaches to integrate Microsoft Word in .NET Form.

    Check this thread for detail:

    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3022227&SiteID=1

     

    1) Using third-part Word control.

    http://www.codeproject.com/KB/office/WordInDotnet.aspx

     

    2) Using DSOFramer.ocx ActiveX Control to host Office documents in .NET Form.

    Detail: http://support.microsoft.com/kb/311765

     

     

     

    Regards,

    Martin

    Friday, April 4, 2008 9:09 AM