Click here to Skip to main content
15,914,642 members
Home / Discussions / C#
   

C#

 
GeneralRe: read and display image in c# Pin
Richard MacCutchan10-Mar-12 1:13
mveRichard MacCutchan10-Mar-12 1:13 
GeneralRe: read and display image in c# Pin
OriginalGriff10-Mar-12 1:22
mveOriginalGriff10-Mar-12 1:22 
GeneralRe: read and display image in c# Pin
DaveyM6910-Mar-12 2:16
professionalDaveyM6910-Mar-12 2:16 
GeneralRe: read and display image in c# Pin
majid abdollahi10-Mar-12 3:11
majid abdollahi10-Mar-12 3:11 
Questionrun .exe file in a panel Pin
pancakeleh9-Mar-12 19:09
pancakeleh9-Mar-12 19:09 
AnswerRe: run .exe file in a panel Pin
Abhinav S9-Mar-12 19:35
Abhinav S9-Mar-12 19:35 
GeneralRe: run .exe file in a panel Pin
OriginalGriff9-Mar-12 22:06
mveOriginalGriff9-Mar-12 22:06 
AnswerRe: run .exe file in a panel Pin
OriginalGriff9-Mar-12 22:02
mveOriginalGriff9-Mar-12 22:02 
The solution Abhinav gave you will not work as is: you need to wait for the window to be fully loaded before you set the new value:
C#
Process process = Process.Start("calc.exe");
Thread.Sleep(500);
SetParent(process.MainWindowHandle, myPanel.Handle);

You will also need to move it to a "sensible" location within your panel after you display it.

C#
[DllImport("user32.dll")]
static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndParent);
[DllImport("user32.dll", EntryPoint = "SetWindowPos")]
public static extern IntPtr SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int Y, int cx, int cy, int wFlags);
private const short SWP_NOMOVE = 0X2;
private const short SWP_NOSIZE = 1;
private const short SWP_NOZORDER = 0X4;
private const int SWP_SHOWWINDOW = 0x0040;

private void myButton_Click(object sender, EventArgs e)
    {
    Process process = Process.Start("calc.exe");
    Thread.Sleep(500);
    IntPtr processHandle = process.MainWindowHandle;
    SetParent(processHandle, myPanel.Handle);
    SetWindowPos(processHandle, 0, 0, 0, myPanel.Bounds.Width, myPanel.Bounds.Height, SWP_NOZORDER | SWP_SHOWWINDOW);
    }




You might want to look at this: Window Tabifier[^] - it's a bit more complex that you appear to need, but it does everything you want to!
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water

SuggestionRe: run .exe file in a panel Pin
DaveyM699-Mar-12 22:15
professionalDaveyM699-Mar-12 22:15 
GeneralRe: run .exe file in a panel Pin
OriginalGriff9-Mar-12 22:24
mveOriginalGriff9-Mar-12 22:24 
AnswerRe: run .exe file in a panel Pin
DaveyM699-Mar-12 22:11
professionalDaveyM699-Mar-12 22:11 
AnswerRe: run .exe file in a panel Pin
Ravi Bhavnani10-Mar-12 4:38
professionalRavi Bhavnani10-Mar-12 4:38 
AnswerRe: run .exe file in a panel Pin
pancakeleh10-Mar-12 8:54
pancakeleh10-Mar-12 8:54 
QuestionC# .net pointer to variable length array Pin
MichCl9-Mar-12 9:54
MichCl9-Mar-12 9:54 
AnswerRe: C# .net pointer to variable length array Pin
PIEBALDconsult9-Mar-12 10:30
mvePIEBALDconsult9-Mar-12 10:30 
AnswerRe: C# .net pointer to variable length array Pin
Luc Pattyn9-Mar-12 13:04
sitebuilderLuc Pattyn9-Mar-12 13:04 
QuestionRegarding file path wildcards Pin
PIEBALDconsult9-Mar-12 9:03
mvePIEBALDconsult9-Mar-12 9:03 
AnswerRe: Regarding file path wildcards Pin
Luc Pattyn9-Mar-12 9:47
sitebuilderLuc Pattyn9-Mar-12 9:47 
GeneralRe: Regarding file path wildcards Pin
PIEBALDconsult9-Mar-12 10:08
mvePIEBALDconsult9-Mar-12 10:08 
AnswerRe: Regarding file path wildcards Pin
Luc Pattyn9-Mar-12 10:13
sitebuilderLuc Pattyn9-Mar-12 10:13 
GeneralRe: Regarding file path wildcards Pin
PIEBALDconsult9-Mar-12 10:20
mvePIEBALDconsult9-Mar-12 10:20 
AnswerRe: Regarding file path wildcards Pin
Luc Pattyn9-Mar-12 10:33
sitebuilderLuc Pattyn9-Mar-12 10:33 
GeneralRe: Regarding file path wildcards Pin
PIEBALDconsult9-Mar-12 10:41
mvePIEBALDconsult9-Mar-12 10:41 
GeneralRe: Regarding file path wildcards Pin
PIEBALDconsult9-Mar-12 15:37
mvePIEBALDconsult9-Mar-12 15:37 
GeneralRe: Regarding file path wildcards Pin
Luc Pattyn9-Mar-12 15:41
sitebuilderLuc Pattyn9-Mar-12 15:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.