Click here to Skip to main content
15,899,679 members
Home / Discussions / C#
   

C#

 
QuestionHelp Regarding Source Code Of Meshack Pin
Caiser Mahmood13-Sep-13 23:34
Caiser Mahmood13-Sep-13 23:34 
AnswerRe: Help Regarding Source Code Of Meshack Pin
Abhinav S14-Sep-13 0:51
Abhinav S14-Sep-13 0:51 
GeneralRe: Help Regarding Source Code Of Meshack Pin
Richard MacCutchan14-Sep-13 1:17
mveRichard MacCutchan14-Sep-13 1:17 
QuestionHow can I change "zoom" value in print preview dialog ? Pin
babak1413-Sep-13 21:51
babak1413-Sep-13 21:51 
AnswerRe: How can I change "zoom" value in print preview dialog ? Pin
Abhinav S13-Sep-13 22:18
Abhinav S13-Sep-13 22:18 
GeneralRe: How can I change "zoom" value in print preview dialog ? Pin
babak1413-Sep-13 22:30
babak1413-Sep-13 22:30 
QuestionHow can I maximize print preview dialog ? Pin
babak1413-Sep-13 21:46
babak1413-Sep-13 21:46 
Questionembedding external application into from panel Pin
eng.iris13-Sep-13 13:11
eng.iris13-Sep-13 13:11 
hi there;

i want to embed an application in my form panel ;
i tried this code

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace show_exe
{
    public partial class form2 : Form
    {
        #region Methods/Consts for Embedding a Window
        [DllImport("user32.dll", EntryPoint = "GetWindowThreadProcessId", SetLastError = true,
             CharSet = CharSet.Unicode, ExactSpelling = true,
             CallingConvention = CallingConvention.StdCall)]
        private static extern long GetWindowThreadProcessId(long hWnd, long lpdwProcessId);

        [DllImport("user32.dll", SetLastError = true)]
        private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

        [DllImport("user32.dll", SetLastError = true)]
        private static extern long SetParent(IntPtr hWndChild, IntPtr hWndNewParent);

        [DllImport("user32.dll", EntryPoint = "GetWindowLongA", SetLastError = true)]
        private static extern long GetWindowLong(IntPtr hwnd, int nIndex);

        [DllImport("user32.dll")]
        static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);

        [DllImport("user32.dll", SetLastError = true)]
        private static extern long SetWindowPos(IntPtr hwnd, long hWndInsertAfter, long x, long y, long cx, long cy, long wFlags);

        [DllImport("user32.dll", SetLastError = true)]
        private static extern bool MoveWindow(IntPtr hwnd, int x, int y, int cx, int cy, bool repaint);

        [DllImport("user32.dll", EntryPoint = "PostMessageA", SetLastError = true)]
        private static extern bool PostMessage(IntPtr hwnd, uint Msg, int wParam, int lParam);

        [DllImport("user32.dll")]
        [return: MarshalAs(UnmanagedType.Bool)]
        static extern bool ShowWindow(IntPtr hWnd, ShowWindowCommands nCmdShow);

        [DllImport("user32.dll", EntryPoint = "SetWindowPos")]
        public static extern IntPtr SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int Y, int cx, int cy, int wFlags);


       public enum ShowWindowCommands
        {
               Hide = 0,
        Show = 5,
        Minimize = 6,
        Restore = 9
        }


        private const int SWP_NOOWNERZORDER = 0x200;
        private const int SWP_NOREDRAW = 0x8;
        private const int SWP_NOZORDER = 0x4;
        private const int SWP_SHOWWINDOW = 0x0040;
        private const int WS_EX_MDICHILD = 0x40;
        private const int SWP_FRAMECHANGED = 0x20;
        private const int SWP_NOACTIVATE = 0x10;
        private const int SWP_ASYNCWINDOWPOS = 0x4000;
        private const int SWP_NOMOVE = 0x2;
        private const int SWP_NOSIZE = 0x1;
        private const int GWL_STYLE = (-16);
        private const int WS_VISIBLE = 0x10000000;
        private const int WM_CLOSE = 0x10;
        private const int WS_CHILD = 0x40000000;
        private const int WS_MAXIMIZE = 0x01000000;
        #endregion
        #region Variables
        private IntPtr gpsHandle;
        private Process gpsProcess = null;
        private ProcessStartInfo gpsPSI = new ProcessStartInfo();
        #endregion
        private void SetupGPSPanel()
        {
            //Panel to Contain Controls
         //this.gpsPanel = new Panel();
        this.gpsPanel.Location = new Point(120, 50);
          this.gpsPanel.Size = new Size(this.Size.Width-200 , this.Size.Height-200 );
       //     this.gpsPanel.Visible = true;

            gpsPSI.FileName = "notepad.exe";//DVBViewerTE.exe";//"C:\Program Files\Adobe\Adobe Photoshop CS5\Photoshop.exe";
          //  gpsPSI.Arguments = "";
          //  gpsPSI.WindowStyle = ProcessWindowStyle.Maximized;
            gpsProcess = System.Diagnostics.Process.Start(gpsPSI);
            gpsProcess.WaitForInputIdle();
            gpsHandle = gpsProcess.MainWindowHandle;
            SetParent(gpsHandle, this.gpsPanel.Handle);
          SetWindowLong(gpsHandle, GWL_STYLE, WS_VISIBLE + WS_MAXIMIZE);
          MoveWindow(gpsHandle, this.gpsPanel.Location.X,this.gpsPanel.Location.Y, this.gpsPanel.Width, this.gpsPanel.Height, true);
          
            ShowWindow(gpsHandle, ShowWindowCommands.Show);

            SetWindowPos(gpsHandle, 0, 0, 0, this.gpsPanel.Bounds.Width, this.gpsPanel.Bounds.Height, SWP_NOZORDER | SWP_SHOWWINDOW);
            
            //this.Controls.Add(gpsPanel);

        }
        public form2()
        {
            InitializeComponent();

        }

        private void form2_Load(object sender, EventArgs e)
        {
            SetupGPSPanel();
        }

    }
}



this code works for notepad application but not for other apps

like photoshop ,dvbviewer , winword

why ???

i hope some body help Frown | :(

thanx in advance
AnswerRe: embedding external application into from panel Pin
BillWoodruff13-Sep-13 16:25
professionalBillWoodruff13-Sep-13 16:25 
GeneralRe: embedding external application into from panel Pin
eng.iris13-Sep-13 17:14
eng.iris13-Sep-13 17:14 
Questionproblem with time field in MySQL Pin
Jassim Rahma13-Sep-13 12:24
Jassim Rahma13-Sep-13 12:24 
AnswerRe: problem with time field in MySQL Pin
Midnight Ahri13-Sep-13 14:02
Midnight Ahri13-Sep-13 14:02 
AnswerRe: problem with time field in MySQL Pin
Richard MacCutchan13-Sep-13 22:32
mveRichard MacCutchan13-Sep-13 22:32 
GeneralRe: problem with time field in MySQL Pin
Jassim Rahma14-Sep-13 10:15
Jassim Rahma14-Sep-13 10:15 
GeneralRe: problem with time field in MySQL Pin
Jassim Rahma14-Sep-13 10:28
Jassim Rahma14-Sep-13 10:28 
GeneralRe: problem with time field in MySQL Pin
Richard MacCutchan14-Sep-13 21:05
mveRichard MacCutchan14-Sep-13 21:05 
AnswerRe: problem with time field in MySQL Pin
Richard Deeming16-Sep-13 2:12
mveRichard Deeming16-Sep-13 2:12 
QuestionOpera and Safari Url listeners Pin
Túlio Cruz13-Sep-13 8:15
Túlio Cruz13-Sep-13 8:15 
AnswerRe: Opera and Safari Url listeners Pin
Dave Kreskowiak13-Sep-13 9:53
mveDave Kreskowiak13-Sep-13 9:53 
GeneralRe: Opera and Safari Url listeners Pin
Richard Andrew x6413-Sep-13 16:44
professionalRichard Andrew x6413-Sep-13 16:44 
GeneralRe: Opera and Safari Url listeners Pin
Dave Kreskowiak14-Sep-13 4:05
mveDave Kreskowiak14-Sep-13 4:05 
QuestionDesign Pattern Pin
Ankit Mishra12-Sep-13 23:44
Ankit Mishra12-Sep-13 23:44 
AnswerRe: Design Pattern Pin
Richard MacCutchan12-Sep-13 23:55
mveRichard MacCutchan12-Sep-13 23:55 
AnswerRe: Design Pattern Pin
Richard Deeming13-Sep-13 1:11
mveRichard Deeming13-Sep-13 1:11 
AnswerRe: Design Pattern Pin
Abhinav S13-Sep-13 17:25
Abhinav S13-Sep-13 17:25 

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.