0

Maybe I am just missing some silly link on the MSDN, but I cannot seem to find the list of possible values RegisterWindowMessage() can take

The only one I can find is "WM_HTML_GETOBJECT". I found this on pinvoke.net. This however, I believe this crashes my application because what I am trying to get is an IHTMLDialog and not a IHTMLDocument

I have looked at

Message Reference

Message Constants

SendMessage

OCM_BASE

WM_USER

A google search for RegisterWIndowMessage list of possible values

Another google search for send message types

Maybe I am searching for the wrong things, but I sure can't find it.

My application fails here:

 Dialog =    (IHTMLDialog)ObjectFromLresult(lRes, typeof(IHTMLDialog).GUID, IntPtr.Zero);

However I believe the issue happened further up the pipeline up here :

  uint iMsg = RegisterWindowMessage("WM_HTML_GETOBJECT");

Because this is not an HTML document, but actually a dialog.

If it helps I am getting the hwnd to the dialog this way :

   IntPtr hwnd = FindWindow("Internet Explorer_TridentDlgFrame", "Google -- Webpage Dialog");

Here is the full snippet of what I am trying to do if it helps :

        UIntPtr lRes;
        IHTMLDialog Dialog;  
        IntPtr hwnd = FindWindow("Internet Explorer_TridentDlgFrame", "Google -- Webpage Dialog");
        uint iMsg = RegisterWindowMessage("WM_HTML_GETOBJECT");

        if (SendMessageTimeout(hwnd, iMsg, IntPtr.Zero, IntPtr.Zero, SendMessageTimeoutFlags.SMTO_ABORTIFHUNG, 1000, out lRes) == IntPtr.Zero)
        {
            MessageBox.Show("operation failed");
        }
        else
        {
            Dialog =   (IHTMLDialog)ObjectFromLresult(lRes, typeof(IHTMLDialog).GUID, IntPtr.Zero);

        }

1 Answer 1

1

RegisterWindowMessage takes a string argument. You can pass any string value. If you are registering messages for your application, make sure to use unique string values (e.g. string representations of GUIDs).

Other than that, there is no complete list of string values you can pass, because any application can choose to register its own set of messages. You will have to consult the documentation that comes with those applications to find out, which messages it supports (if any).

Sign up to request clarification or add additional context in comments.

7 Comments

Thanks for clarifying that for me. So the string itself is not important as long as the application supports it? That means my code is failing at ObjectFromLresult for some other reason. I will investigate and ask a separate question as necessary.
@AlexanderRyanBaggett: It is not clear, what you are trying to accomplish. RegisterWindowMessage is "typically used to register messages for communicating between two cooperating applications." The example you used was introduced with IE 4. It may no longer be supported. But what are you ultimately trying to accomplish?
I am trying to get programmatic access to a modal dialog that is loaded in a page in a web browser control.
I can get the hwnd, but converting it to an HTMLDialog/IHTMLDialog is what I am trying to do here.
@AlexanderRyanBaggett: That appears to be the wrong approach. If you need to automate a UI, UI Automation would be a primary candidate for evaluation.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.