Search code examples
delphiwinapidelphi-xe2ribbon

Restrict window movement to parent window area


I'm working on a delphi program using the TRibbon and launching separate exe files. Once I have executed the external application (with CreateProcessA() ) I set its parent as the form with the ribbon:

wHandle := FindWindow('MainRibbonForm');
Winapi.Windows.SetParent(wHandle,self.Handle);

All considered, this works alright, but the problem is that the application forms can be moved over the TRibbon in the main form. I was thinking about restricting the form's movement within the main application but how can I take into account the ribbon?


Solution

  • Place a TPanel as a container on your Form and use this TPanel as Parent. Now the Child can only move inside the TPanel.

    wHandle := FindWindow( 'MainRibbonForm' );
    SetParent( wHandle, MyContainerPanel.Handle );