WM_MSO_BROADCASTCHANGE 值

发布于 2024-09-30 21:14:03 字数 47 浏览 4 评论 0 原文

WM_MSO_BROADCASTCHANGE 的值是多少?下次我自己该如何计算?

What's the value for WM_MSO_BROADCASTCHANGE, and how would I figure it out for myself next time?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一个人练习一个人 2024-10-07 21:14:03

我知道,这是一个迟到的答案,但碰巧我最近自己也在寻找这个问题的答案,所以这可能会帮助其他犯错误的谷歌人......

事实证明“WM_MSO_BROADCASTCHANGE”没有设定值。您可以通过调用RegisterMessage动态获取它的值。请参阅 http://msdn.microsoft.com/en -us/library/ms644947(v=vs.85).aspx

请注意,在这种特殊情况下,MS Office 似乎会广播该消息,因此只有其他顶级窗口才会收到该消息。

一般来说,您可以使用 Spy++ 等工具(随 Visual Studio 提供,也可能随 Windows 平台 SDK 提供)来查看消息的值。在这种情况下,Spy++ 还将记录它是一条注册消息。

要监听它,您可以编写一些 C# 代码,例如,如下所示。

using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;
  ....
class ThemeChangeCatcherpublic : Form
    {
        private const string WM_MSO_BROADCAST_NAME = "WM_MSO_BROADCASTCHANGE";

        private int WM_MSO_BROADCASTCHANGE = 0;

        internal static class NativeMethods
        {
            [DllImport("user32.dll", SetLastError=true, CharSet=CharSet.Auto)]
            internal static extern int RegisterWindowMessage(string lpString);
        }

        protected override void OnHandleCreated(EventArgs e)
        {
            base.OnHandleCreated(e);

            WM_MSO_BROADCASTCHANGE = NativeMethods.RegisterWindowMessage(WM_MSO_BROADCAST_NAME);
        }

        protected override void WndProc(ref Message m)
        {
            if (m.Msg == WM_MSO_BROADCASTCHANGE)
                MessageBox.Show("gotcha!");
            else
                base.WndProc(ref m);    
        }        
    }

A late answer, I know, but as it happens I was recently looking for the answer to this question myself, so this may help other errant Googlers...

Turns out that "WM_MSO_BROADCASTCHANGE" has no set value. You obtain a value for it dynamically by calling RegisterMessage. See http://msdn.microsoft.com/en-us/library/ms644947(v=vs.85).aspx

Note that in this particular case MS Office appears to broadcast the message, so only other top-level windows will receive it.

In general, you can use a tool like Spy++ (provided with Visual Studio and probably the Windows Platform SDKs too) to see what the value of a message is. In this case, Spy++ will also log that it's a registered message.

To listen for it you might write some C# code, for example, that looks like this.

using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;
  ....
class ThemeChangeCatcherpublic : Form
    {
        private const string WM_MSO_BROADCAST_NAME = "WM_MSO_BROADCASTCHANGE";

        private int WM_MSO_BROADCASTCHANGE = 0;

        internal static class NativeMethods
        {
            [DllImport("user32.dll", SetLastError=true, CharSet=CharSet.Auto)]
            internal static extern int RegisterWindowMessage(string lpString);
        }

        protected override void OnHandleCreated(EventArgs e)
        {
            base.OnHandleCreated(e);

            WM_MSO_BROADCASTCHANGE = NativeMethods.RegisterWindowMessage(WM_MSO_BROADCAST_NAME);
        }

        protected override void WndProc(ref Message m)
        {
            if (m.Msg == WM_MSO_BROADCASTCHANGE)
                MessageBox.Show("gotcha!");
            else
                base.WndProc(ref m);    
        }        
    }
尹雨沫 2024-10-07 21:14:03

在大多数情况下,我会建议使用 Google 或 MSDN。在 MSDN 上搜索 WM_TIMER 会发现这是第一条答案:

http://msdn.microsoft.com/en-us/library/ms644902(VS.85).aspx

因此我们有:

#define WM_TIMER                        0x0113

在您的情况下,搜索该字符串谷歌只显示了两个匹配项,显示了不同的值 - 所以我不知道该告诉你什么。这是在第三方库中,其文档或代码会告诉您该值吗?如果它是正确的,则必须在头文件中的某个位置定义它,否则没有人可以在其代码中使用它。话又说回来,也许隐藏价值才是目的。这是外接程序使用的一些仅供内部使用的 Windows 消息吗?

In most cases, I would say use Google or MSDN. Searching for WM_TIMER on MSDN turns up this as the #1 answer:

http://msdn.microsoft.com/en-us/library/ms644902(VS.85).aspx

and so we have:

#define WM_TIMER                        0x0113

In your case, a search for that string on Google turns up just two matches, that show differing values - so I cannot think of what to tell you. Is this in a third-party library whose documentation or code would tell you the value? It has to be defined in a header file somewhere, if it's correct, or nobody can use it in their code. Then again, perhaps hiding the value is the intention. Is this some internal-only Windows Message used by an addin?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文