Host a Delphi 7 application process in .net -
hi!
i'm trying host delphi 7 vcl application in .net wpf application. works great except modal dialogs not behave modal dialogs, parent window isn't disabled.
code far:
class mysimpledelphihost : hwndhost { private process _appproc; public intptr hwndhost; protected override handleref buildwindowcore(handleref hwndparent) { _appproc = new process(); _appproc.startinfo.windowstyle = processwindowstyle.hidden; _appproc.startinfo.filename = @"mysimpledelphiapplication.exe"; _appproc.start(); thread.sleep(1000); hwndhost = win32api.findwindow("tmainform", null); int oldstyle = win32api.getwindowlong(hwndhost, win32api.gwl_style); win32api.setwindowlong(hwndhost, win32api.gwl_style, (oldstyle | win32api.ws_child) & ~win32api.ws_border); win32api.setparent(hwndhost, hwndparent.handle); win32api.showwindowasync(hwndhost, win32api.sw_showmaximized); return new handleref(this, hwndhost); } protected override void destroywindowcore(handleref hwnd) { _appproc.kill(); } }
if host none delphi application works fine. ideas?
i created demo http://www.easy-share.com/1913154119/simpledelphiapphosting.zip . sorry hosting site.
fwiw have tried setting:
form.modalpopupmode = pmexplicit; form.modalparent = parentform; form.showmodal;
also don't have change tapplication in forms unit, do
var oldwndproc: pointer; function newwndproc(handle: hwnd; msg: uint; pw: wparam; pl: lparam): lresult stdcall; begin if msg = wm_enabled begin dowhatever(); result := 1; // handled end else result := callwindowproc(oldwndproc, handle, msg, pw, pl); end; initialization oldwndproc := pointer(setwindowlong(application.handle, gwl_wndproc, longint(@newwndproc)));
Comments
Post a Comment