So I've started fiddling around with VSB to, generally be better. I really want to learn, but I feel either the information I can find is outdated, or the code just doesn't work for me, for whatever reason. But, to the problem:
I want to be able to: Be able to click on a tab inside my VSB project, once that tab is clicked, there's a panel. Inside that panel, I want for example notepad to open, maximized to the panel window, docked and not able to move it (notepad).
I would like to do the same for other programs as well. My current code is the basic that opens notepad in a new window. I've only just begun poking at VSB so my knowledge is very limited.
I was able to do this in VSB (No C#) but not for C3
Current Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace Software_Solution_C__Project__v._10._0._0
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
AboutBox1 myForm = new AboutBox1();
myForm.ShowDialog();
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
Process.Start("mspaint.exe");
}
}
}
I tried to google, I tried different solutions I found, tried to find my way around, but it either crashed or gave endless error messages rendering me unable to do it.
Edit: I've also tried the following code:
namespace Software_Solution_C__Project__v._10._0._0
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
AboutBox1 myForm = new AboutBox1();
myForm.ShowDialog();
}
private const int WM_SYSCOMMAND = 274; private const int SC_MAXIMIZE = 61488;
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)]
public static extern int SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
private void panel1_Paint(object sender, PaintEventArgs e)
{
Process proc;
proc = Process.Start("Notepad.exe");
proc.WaitForInputIdle();
SetParent(proc.MainWindowHandle, panel1.Handle);
//SendMessage(proc.MainWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
}
}
}
The problem here is, notepad does open in the panel, but not stretched / docked to fit window, and if I move the window, another instance of notepad opens. And if I close notepad, it just reopens again.