Run *.exe in DocumentWindow?

4 posts, 1 answers
  1. Oleg
    Oleg avatar
    6 posts
    Member since:
    Jul 2011

    Posted 07 May 2015 Link to this post


    Probably little bit strabeg question:

    Is it possible to run some external WinForms exe in DocumentWindow?

    Thank you.





  2. Answer
    Dimitar avatar
    2937 posts

    Posted 12 May 2015 Link to this post

    Hi Oleg,

    Thank you for contacting us.

    It appears that this is possible and you just need to use some methods from user32.dll. For example:
    private void radButton1_Click(object sender, EventArgs e)
        DocumentWindow document = new DocumentWindow();
        document.Text = "New Document";
        Process p = Process.Start("notepad.exe");          
        Thread.Sleep(500); //time is needed for the process starting
        SetParent(p.MainWindowHandle, document.Handle);
        SetWindowLong(p.MainWindowHandle, GWL_STYLE, WS_VISIBLE);         
        MoveWindow(p.MainWindowHandle, 0, 0, document.Width, this.Height, true);
    [DllImport("usesome r32.dll")]
    static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
    [DllImport("user32.dll", SetLastError = true)]
    private static extern bool MoveWindow(IntPtr hwnd, int x, int y, int cx, int cy, bool repaint);
    [DllImport("user32.dll", EntryPoint = "SetWindowLongA", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
    private static extern long SetWindowLong(IntPtr hwnd, int nIndex, long dwNewLong);
    private const int GWL_STYLE = (-16);
    private const int WS_VISIBLE = 0x10000000;

    Please let me know if there is something else I can help you with. 


    See What's Next in App Development. Register for TelerikNEXT.

  3. Jim
    Jim avatar
    1 posts
    Member since:
    May 2015

    Posted 06 Apr Link to this post

    Sorry to reply to an older thread, but I am attempting to achieve this as well, host another telerik winforms application within the DocumentWindow. What Dimitar posted works with notepad.exe, however with I haven't been able to recreate it using my basic RadForm application I created to host.

    Using notepad.exe, I am getting exactly the results I am looking for (telerik2.png). Unfortunately, using my winforms application seems to have no effect (telerik1.png).


    Thank you,


  4. Dess | Tech Support Engineer, Sr.
    Dess | Tech Support Engineer, Sr.  avatar
    4004 posts

    Posted 09 Apr Link to this post


    Hello, Jim,  

    Your question has already been answered in the support thread  you have opened on the same topic. Please, see our answer there for more information.
    We kindly ask you to use just one thread for a specific problem to contact us. Posting the same questions numerous times slows down our response time because we will need to review and address two or more tickets instead of one. Moreover, threads are handled according to license and time of posting, so if it is an urgent problem, we suggest you use a support ticket, which would be handled before a forum thread.

    Thank you for your understanding.

    However, I am posting the answer here as well in order the community to benefit from it. I would like to note that the provided approach in the referred forum post uses Windows API and our RadDock doesn't have any effect on it. The same piece of code can be executed in a standard WinForms application with an identical result. 

    After researching in general programming forums, it seems that the following threads may be suitable for your custom scenario:

    Please have in mind that RadDock is not intended to host external applications. However, it does support hosting other RadForms. Hence, if it is suitable for you case, I would recommend you to dock a separate form:

    I hope this information helps.  

    Dess | Tech Support Engineer, Sr.
    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.
Back to Top