Delphi – 嵌入式应用程序滚动条不可见
发布时间:2020-12-15 09:12:58 所属栏目:大数据 来源:网络整理
导读:基于 Embedding window into another process问题,我在我的主应用程序中嵌入了一个在主窗体上只有一个TWebBrowser组件的应用程序.即使我将它嵌入到TScrollBox组件中,当主应用程序调整大小时,滚动条也不会出现.我对这个问题做了一些研究,但没有成功.如何启用
基于
Embedding window into another process问题,我在我的主应用程序中嵌入了一个在主窗体上只有一个TWebBrowser组件的应用程序.即使我将它嵌入到TScrollBox组件中,当主应用程序调整大小时,滚动条也不会出现.我对这个问题做了一些研究,但没有成功.如何启用滚动条的滚动条?
LE:澄清问题:应用程序A是一个带有TWebBrowser组件的简单表单.应用程序B是主应用程序,它将应用程序A嵌入到放置在表单上的TScrollBox上,并将Align设置为alClient.将A嵌入B的代码 procedure ShowAppEmbedded(WindowHandle: THandle; Container: TWinControl); var WindowStyle : Integer; FAppThreadID: Cardinal; begin /// Set running app window styles. WindowStyle := GetWindowLong(WindowHandle,GWL_STYLE); WindowStyle := WindowStyle - WS_CAPTION - WS_BORDER - WS_OVERLAPPED - WS_THICKFRAME; SetWindowLong(WindowHandle,GWL_STYLE,WindowStyle); /// Attach container app input thread to the running app input thread,so that /// the running app receives user input. FAppThreadID := GetWindowThreadProcessId(WindowHandle,nil); AttachThreadInput(GetCurrentThreadId,FAppThreadID,True); /// Changing parent of the running app to our provided container control Windows.SetParent(WindowHandle,Container.Handle); SendMessage(Container.Handle,WM_UPDATEUISTATE,UIS_INITIALIZE,0); UpdateWindow(WindowHandle); /// This prevents the parent control to redraw on the area of its child windows (the running app) SetWindowLong(Container.Handle,GetWindowLong(Container.Handle,GWL_STYLE) or WS_CLIPCHILDREN); /// Make the running app to fill all the client area of the container SetWindowPos(WindowHandle,Container.ClientWidth,Container.ClientHeight,SWP_NOZORDER); SetForegroundWindow(WindowHandle); end; 调整主应用程序(B)的大小时,不会显示来自B的TScrollBox组件的滚动条,并且应用程序A停留在它上面是从请求设置的. 解决方案:根据Kobik的评论,应用程序A嵌入到与TScrollBox内的alClient对齐的TPanel内的应用程序B中.在OnPanelResize事件上运行以下代码: if IsWindow(App_B_WindowHandle) then SetWindowPos(App_B_WindowHandle,Panel1.Width,Panel1.Height,SWP_ASYNCWINDOWPOS); 解决方法
将VCL容器(例如TPanel)放入TScrollbox中.并将客户端应用程序嵌入Panel中.这样TScrollbox就能正确处理Panel.您不能简单地将嵌入式应用程序与Delphi容器对齐.您可能希望处理TPanel.OnResize以调整嵌入式应用程序的新维度(如果需要).
无论如何,正如你所知,整个想法都是痛苦的世界. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |