Displaying Flash game in program without other parts of web page RRS feed

  • Question

  • I try to make small application that loads html page with Flash game and then it must hide web page and show only game.

    I have Panel with WebBrowser.

    My actions is:

    1. search for 'MacromediaFlashPlayerActiveX' class window.
    2. change Parent of Flash window to Panel
    3. hide WebBrowser (or remove it from panel)

    As result I have a Flash window on panel without any html. But I have a problem - I can't move Flash window after moving it from WebBrowser.

    Game is working normal, but I need to move window to left-top corner of Panel. I tried MoveWindow, SetWindowPos and other. I have also 1 interesting result when I use parameters, that didn't update window. The Flash window is moved, but after one (1) click it moved back to its first position.

    Code for find flash

    var handle = NativeMethods.FindWindowEx(_browser.Handle, IntPtr.Zero, "Shell Embedding", null);
    			handle = NativeMethods.FindWindowEx(handle, IntPtr.Zero, "Shell DocObject View", null);
    			handle = NativeMethods.FindWindowEx(handle, IntPtr.Zero, "Internet Explorer_Server", null);
    			handle = NativeMethods.FindWindowEx(handle, IntPtr.Zero, "MacromediaFlashPlayerActiveX", null);

    To remove WebBrowser

    IntPtr old = NativeMethods.SetParent( _flashHandle, panel.Handle );
    panel.Controls.Remove( _browser );

    Wednesday, December 15, 2010 1:58 PM


All replies

  • Hmm... I found simple and elegant solution. Just use IE DOM :)
    • Proposed as answer by Mio_Miao Tuesday, December 21, 2010 9:53 AM
    • Marked as answer by Alan_chenModerator Wednesday, December 22, 2010 12:55 AM
    Friday, December 17, 2010 6:48 PM
  • Hi Alexei Shcherbakov,

    Thank you for posting in the MSDN Forum.

    I’m glad to hear that you found the solution. Thank you for sharing your solutions & experience here. It will be very beneficial for other community members who have similar questions.


    Best Regards,



    Mio Miao[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, December 21, 2010 9:53 AM
  • There are two solutions.

    1. If flash is loaded from another site in iframe you can catch downloading process in DocumentComplete

    if (e.Url.ToString().StartsWith("<start address of flash>"))
    // Disable listener
                    _browser.DocumentCompleted -= DocumentCompletedListenter;

    // Navigate to flash directly
                    _browser.BeginInvoke(new Action<Uri>(_browser.Navigate), e.Url);

    2. Flash object is embedded in html page.

            public static void HideAllExceptFlash(HtmlDocument document)
    // list elements on html page
                HideHtmlTree( document.GetElementById( "..." ) );
                HtmlElement element = document.GetElementById("<our flash container>");
    // We get parent object to flash and hide all exapt flash object
                foreach (HtmlElement e in element.Parent.Children)
                    if (e==element)
                    HideHtmlTree( e );


            private static string _hideStyle = "display: none";
            private static void HideHtmlTree(HtmlElement element)
                foreach (HtmlElement e in element.Children)
                    e.Style = _hideStyle;


    P.S. Handle to flash is not needed :)

    Wednesday, January 5, 2011 11:35 PM