Basé sur la question Embedding window into another process, j'incorpore une application qui n'a qu'un composant TWebBrowser sur le formulaire principal, sur mon application principale. Même si je l'incorpore à un composant TScrollBox, les barres de défilement n'apparaissent pas lorsque l'application principale est redimensionnée. J'ai fait des recherches sur cette question, mais sans succès. Comment puis-je activer les barres de défilement de la scrollbox? LE: Pour clarifier la question: L'application A est une forme simple avec un composant TWebBrowser dessus. Application B, l'application principale, est l'intégration de l'application A sur un TScrollBox placé sur un formulaire, avec Align défini sur alClient. Code pour l'enrobage A dans BDelphi - barre de défilement de l'application intégrée non visible
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, GWL_STYLE, GetWindowLong(Container.Handle,GWL_STYLE) or WS_CLIPCHILDREN);
/// Make the running app to fill all the client area of the container
SetWindowPos(WindowHandle,0,0,0,Container.ClientWidth,Container.ClientHeight,SWP_NOZORDER);
SetForegroundWindow(WindowHandle);
end;
Lors du redimensionnement de l'application principale (B), les barres de défilement de l'élément TScrollBox de B ne sont pas montré et l'application A repose à sa création de la mendicité.
Solution: Sur la base du commentaire de Kobik, l'application A est intégrée dans l'application B dans un TPanel aligné sur alClient à l'intérieur d'une TScrollBox. En cas OnPanelResize le code suivant est exécuté:
if IsWindow(App_B_WindowHandle) then
SetWindowPos(App_B_WindowHandle, 0, 0, 0, Panel1.Width, Panel1.Height, SWP_ASYNCWINDOWPOS);
Cela ne va tout simplement pas fonctionner. Windows n'est pas conçu pour de telles actions. La parenté de fenêtre croisée de processus a cessé d'être raisonnable il y a plus de 20 ans quand Win32 a été présenté. –
@DavidHeffernan - Je connais David. La solution fonctionne, mais je suis d'accord avec vous que cela ne devrait pas être fait comme ça. – RBA
Il est peu probable que cela fonctionne correctement. Il y a forcément plus de problèmes que vous n'avez pas encore trouvé. –