I am trying to implement Luke Quinane's answer on this question to work with Microsoft Access.
The code I am using is exactly what was posted in the answer, but I have put it below for convenience. Suffice to say, my Windows Form consists of a panel and a button:
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows.Forms;
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Process p = Process.Start("MSACCESS.exe");
p.WaitForInputIdle();
SetParent(p.MainWindowHandle, panel1.Handle);
}
[DllImport("user32.dll")]
static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
private void Form1_Load(object sender, EventArgs e)
{
}
}
Microsoft Access launches fine, but then disappears whenever I try and place it inside the panel.
Whenever I replace MSACCESS.exe
with notepad.exe
, the program functions with Notepad as expected.
Is there something extra I need to do to get this procedure to work with Microsoft Access?