Réponse acceptée !
Salut, si tu connais un peu l'API Win32 je pense que c'est possible, voila un point de départ ( beaucoup de code mais tu as juste à utiliser la methode ILoveNotepad ).
[ DllImport( "user32.dll", SetLastError = true ) ]
private static extern IntPtr SetParent( IntPtr hWndChild, IntPtr hWndNewParent );
[ DllImport( "user32.dll", SetLastError = true ) ] // 32 bits.
private static extern int GetWindowLong( IntPtr hWnd, int nIndex );
[ DllImport( "user32.dll", SetLastError = true ) ] // 64 bits.
private static extern IntPtr GetWindowLongPtr( IntPtr hWnd, int nIndex );
[ DllImport( "user32.dll", SetLastError = true ) ] // 32 bits.
private static extern int SetWindowLong( IntPtr hWnd, int nIndex, int dwNewLong );
[ DllImport( "user32.dll", SetLastError = true ) ] // 64 bits.
private static extern IntPtr SetWindowLongPtr( IntPtr hWnd, int nIndex, IntPtr dwNewLong );
private const int WS_POPUP = unchecked( ( int )0x80000000 );
private const int WS_CHILD = 0x40000000;
private const int GWL_STYLE = -16;
private void ILoveNotepad( )
{
Process p = Process.Start( "notepad.exe" );
p.WaitForInputIdle( 2000 );
IntPtr hWnd = p.MainWindowHandle;
p.Close( );
p = null;
int styles = ( int )GetStyles( hWnd );
styles &= ~WS_POPUP;
styles |= WS_CHILD;
SetStyles( hWnd, ( IntPtr )styles );
SetParent( hWnd, this.Handle );
// WM_CHANGEUISTATE
// WM_UPDATEUISTATE
// etc..
}
private IntPtr GetStyles( IntPtr hWnd )
{
if ( IntPtr.Size == 8 ) // 64 bits.
return GetWindowLongPtr( hWnd, GWL_STYLE );
else // 32bits
return ( IntPtr )GetWindowLong( hWnd, GWL_STYLE );
}
private void SetStyles( IntPtr hWnd, IntPtr styles )
{
if ( IntPtr.Size == 8 ) // 64 bits.
SetWindowLongPtr( hWnd, GWL_STYLE, styles );
else // 32 bits.
SetWindowLong( hWnd, GWL_STYLE, ( int )styles );
}