回 帖 发 新 帖 刷新版面

主题:TPanel中加载TForm问题!

问一下,TPanel中怎么加载一个窗口?或者说,同类的容器控件怎么加载?
主要目的就是在一个窗口中动态加载另一个窗口。

回复列表 (共1个回复)

沙发

Here are the code I made to loading a program( Dasher) to my 
Panel:DasherPanel.
Good luck

HWND DasherHandle=NULL; // handle for Dasher
PROCESS_INFORMATION ProcessInfo;
STARTUPINFO StartupInfo = {0};

StartupInfo.cb = sizeof(STARTUPINFO);
if (DasherHandle) return true;  // if Dasher has already started.do nothing
Result = CreateProcess(NULL, "XXXXX-Path of the Dasher", NULL, NULL, false, 0, NULL, NULL, &StartupInfo, &ProcessInfo);

if (!Result) {
   //"Can't find Dasher."
      return false;
}

while(1) {
    DasherHandle = FindWindow("DASHER", NULL);
    if (IsWindow(DasherHandle) && IsWindowVisible(DasherHandle)) break; // visible
            else Sleep(200);
}

DWORD style=0;
style = GetWindowLong(DasherHandle,GWL_STYLE);
        SetWindowLong(DasherHandle,GWL_STYLE,(style&(~WS_CAPTION)&(~WS_SYSMENU )));
ShowWindow(DasherHandle,SW_SHOWMAXIMIZED);

HWND H1 = MainForm->DasherPanel->Handle;

if (DasherHandle){
    ::SetParent(DasherHandle,H1);
    MoveWindow(DasherHandle,0,0,MainForm->DasherPanel->Width,  MainForm->DasherPanel->Height,true);
    ::ShowWindow(H1,SWP_SHOWWINDOW);
}else {
     // "Have problem to load Dasher"
     return false;
}

我来回复

您尚未登录,请登录后再回复。点此登录或注册