Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6009013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:54:36+00:00 2026-05-23T01:54:36+00:00

Windows Live Writer hosts an Internet Explorer control for editing, but there’s no zoom

  • 0

Windows Live Writer hosts an Internet Explorer control for editing, but there’s no zoom control. I’d like to be able to send a zoom command to it. Since other apps host the IE browser, I’d think a utility that can send zoom commands to specific IE browser instances would be really handy, but I haven’t found one.

I’ve seen there’s a command, OLECMDID_OPTICAL_ZOOM, but I’m not sure how to send that command to it. Ideally I’d like to do this from C# or Powershell.

Note: The question is asking about controlling the zoom in a web browser control in a running application which I did not create, the main example being the editor surface in Windows Live Writer.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T01:54:36+00:00Added an answer on May 23, 2026 at 1:54 am

    Short version: I’m not entirely sure you can do what you’re attempting to do.

    I have some code that actually gets a handle on the HTML document inside the WLW window, and that works, but what I’m finding is that I can’t actually get a reference to the parent window of the document. I’m no native Windows guy, but I’ve done some PInvoke in my time. It may be just that my lack of native Windows knowledge is stopping me from bridging that last gap.

    From what I’ve put together, the general process for getting a reference to an IE window is:

    1. Get a reference for the top-level window.
    2. Find the window containing the HTML document in there (recursive search).
    3. Get the HTML document object from that window.
    4. Get the parent window of the HTML document (which is the IE window).

    Once you have that parent window, you can call the IWebBrowser2.ExecWB method to run your OLE zoom command.

    The problem is that the IHTMLDocument2.parentWindow property always seems to throw an InvalidCastException when you try to access it. From what I’ve read, that’s the deal when you try to grab the parent window from a thread other than the one the document is running on.

    So, anyway, I’ll drop the code on you that gets the HTML document reference and if you can bridge that tiny last step of the way, you’ll have your answer. I just couldn’t figure it out myself.

    This is a console app. You’ll need a reference to Microsoft.mshtml for the IHTMLDocument2 interface.

    using System;
    using System.Runtime.InteropServices;
    
    namespace ControlInternetExplorerServer
    {
        ////////////////////////
        // LOTS OF PINVOKE STUFF
        ////////////////////////
    
        [Flags]
        public enum SendMessageTimeoutFlags : uint
        {
            SMTO_NORMAL = 0x0,
            SMTO_BLOCK = 0x1,
            SMTO_ABORTIFHUNG = 0x2,
            SMTO_NOTIMEOUTIFNOTHUNG = 0x8
        }
    
        public static class NativeMethods
        {
            [DllImport("user32.dll", CharSet = CharSet.Unicode)]
            public static extern IntPtr FindWindow(
                string lpClassName,
                string lpWindowName);
    
            [DllImport("user32.dll", SetLastError = true)]
            public static extern IntPtr FindWindowEx(
                IntPtr hwndParent,
                IntPtr hwndChildAfter,
                string lpszClass,
                string lpszWindow);
    
            [DllImport("user32.dll", CharSet = CharSet.Auto, EntryPoint = "GetWindow", SetLastError = true)]
            public static extern IntPtr GetNextWindow(IntPtr hwnd, [MarshalAs(UnmanagedType.U4)] int wFlag);
    
            [DllImport("oleacc.dll", PreserveSig = false)]
            [return: MarshalAs(UnmanagedType.Interface)]
            public static extern object ObjectFromLresult(
                IntPtr lResult,
                [MarshalAs(UnmanagedType.LPStruct)] Guid refiid,
                IntPtr wParam);
    
            [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
            public static extern uint RegisterWindowMessage(string lpString);
    
            [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
            public static extern IntPtr SendMessageTimeout(
                IntPtr windowHandle,
                uint Msg,
                IntPtr wParam,
                IntPtr lParam,
                SendMessageTimeoutFlags flags,
                uint timeout,
                out IntPtr result);
    
            public static IntPtr FindWindowRecursive(IntPtr parent, string windowClass, string windowCaption)
            {
                var found = FindWindowEx(parent, IntPtr.Zero, windowClass, windowCaption);
                if (found != IntPtr.Zero)
                {
                    return found;
                }
    
                var child = FindWindowEx(parent, IntPtr.Zero, null, null);
                while (child != IntPtr.Zero)
                {
                    found = FindWindowRecursive(child, windowClass, windowCaption);
                    if (found != IntPtr.Zero)
                    {
                        return found;
                    }
                    child = GetNextWindow(child, 2);
                }
                return IntPtr.Zero;
            }
        }
    
    
        //////////////////////
        // THE INTERESTING BIT
        //////////////////////
    
        public class Program
        {
            public static void Main(string[] args)
            {
                // First parameter is the class name of the window type - retrieved from Spy++
                // Second parameter is the title of the window, which you'll
                // probably want to take in via command line args or something.
                var wlwWindow = NativeMethods.FindWindow("WindowsForms10.Window.8.app.0.33c0d9d", "Untitled - Windows Live Writer");
                if (wlwWindow == IntPtr.Zero)
                {
                    Console.WriteLine("Unable to locate WLW window.");
                    return;
                }
    
                // Since you don't know where in the tree it is, you have to recursively
                // search for the IE window. This will find the first one it comes to;
                // ostensibly there's only one, right? RIGHT?
                var ieWindow = NativeMethods.FindWindowRecursive(wlwWindow, "Internet Explorer_Server", null);
                if (ieWindow == IntPtr.Zero)
                {
                    Console.WriteLine("Unable to locate IE window.");
                    return;
                }
    
                // Get a handle on the document inside the IE window.
                IntPtr smResult;
                var message = NativeMethods.RegisterWindowMessage("WM_HTML_GETOBJECT");
                NativeMethods.SendMessageTimeout(ieWindow, message, IntPtr.Zero, IntPtr.Zero, SendMessageTimeoutFlags.SMTO_ABORTIFHUNG, 1000, out smResult);
                if (smResult== IntPtr.Zero)
                {
                    Console.WriteLine("Unable to locate the HTML document object.");
                }
    
                // Cast the document to the appropriate interface.
                var htmlDoc = (mshtml.IHTMLDocument2)NativeMethods.ObjectFromLresult(smResult, typeof(mshtml.IHTMLDocument2).GUID, IntPtr.Zero);
    
                // Here's where you would normally get htmlDoc.parentWindow and call ExecWB
                // to execute the zoom operation, but htmlDoc.parentWindow throws an InvalidCastException.
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use blogger and I install a windows live writer, I don't know how
does anyone know is there a way to implement Windows Live ID authentication into
Does anyone know is there a way to implement Windows Live ID authentication into
I am wondering How a blog software such as Windows Live writer reads/updates so
I am wondering How a blog software such as Windows Live writer reads/updates so
I'm developing a custom website and I want it to support Windows Live Writer.
Microsoft's new Windows Live Application Based Storage API is a RESTful API. More info
So I am fairly new to ASP.NET MVC and Windows Live Connect API. Basically
I have a C# Windows Form Application and a live video feed. I need
how to easily develop print css? with live preview/debugging, i'm on windows xp, use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.