Hosting a process in C#.Net form disables some process's buttons -
Hosting a process in C#.Net form disables some process's buttons -
i trying host .exe within .net application (mainly video viewing software) applications not allow me utilize menu's or controls. has had problem before or thought of why happening?
here code host application:
#region methods/consts embedding 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); 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 hostedprocesshandle; private process hostedprocess = null; private processstartinfo hostedpsi = new processstartinfo(); #endregion //helper method start process contained within form private void hostprocess(string processpath) { //start process located @ processpath hostedpsi.filename = processpath; hostedpsi.arguments = ""; hostedpsi.windowstyle = processwindowstyle.maximized; hostedprocess = system.diagnostics.process.start(hostedpsi); //stop watch used calculate time out period. stopwatch sw = new stopwatch(); sw.start(); //loop aquire application handle. exit loop if time out period past. { hostedprocesshandle = hostedprocess.mainwindowhandle; if (sw.elapsedmilliseconds > 10000) throw new timeoutexception(); } while (hostedprocesshandle == new intptr(0)); //host process in forms panel. setparent(hostedprocesshandle, this.panel1.handle); setwindowlong(hostedprocesshandle, gwl_style, ws_visible + ws_maximize); movewindow(hostedprocesshandle, 10, 10, this.panel1.width - 20, this.panel1.height - 20, true); } private void closehostedprocess() { hostedprocess.kill(); }
here screen shot of test application hosting vlc, of menu's , buttons can see grayed out , not working:
this not problem vlc — see issue when hosting other applications too.
just update. if right click on vlc -> play -> add together , play video manually menu bar works again. video controls @ bottom still not working! alter color when rolled on clicking them still doesn't work!
the problem may facing similar problem teamviewer running in background. when stopped process works fine.
c# .net windows process
Comments
Post a Comment