方法'WndProc'接受0个参数
本文关键字:参数 0个 WndProc 方法 接受 | 更新日期: 2023-09-27 18:10:43
protected override void WndProc(ref Message message)
{
if (message.Msg == WM_SETTINGCHANGE)
{
if (message.WParam.ToInt32() == SPI_SETDESKWALLPAPER)
{
// Handle that wallpaper has been changed.
}
}
base.WndProc(ref message);
}
private void check_Tick(object sender, EventArgs e)
{
WndProc();
}
我知道我错过了一些东西,在()WndProc之后,但我不确定什么…有人能帮忙吗?
当我在Windows消息处理程序中放置一个断点时,我注意到当背景改变时,它正在接收一个42而不是20的Wparam,它可能是位的组合,所以你可以尝试这样的东西。
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_SETTINGCHANGE)
{
if ((m.WParam.ToInt32() & (int)SPI_SETDESKWALLPAPER) == SPI_SETDESKWALLPAPER)
{
// Handle that wallpaper has been changed.
}
}
base.WndProc(ref m);
}
如果你想用计时器轮询变化,你可以创建一个消息,然后像这样调用WndProc方法。
private void timer1_Tick(object sender, EventArgs e)
{
Message m = new Message();
m.Msg = (int)WM_SETTINGCHANGE;
m.WParam = (IntPtr)SPI_SETDESKWALLPAPER;
WndProc(ref m);
}
你不需要一个计时器来检查更改,这是WndProc的工作:
private static readonly UInt32 SPI_SETDESKWALLPAPER = 0x14;
private static readonly UInt32 WM_SETTINGCHANGE = 0x1A;
protected override void WndProc(ref Message message)
{
if (message.Msg == WM_SETTINGCHANGE)
{
if (message.WParam.ToInt32() == SPI_SETDESKWALLPAPER)
{
// Handle that wallpaper has been changed.]
Console.Beep();
}
}
base.WndProc(ref message);
}