⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 26.3.txt

📁 《Microsoft Visual C# .NET 2003开发技巧大全》源代码
💻 TXT
字号:
Listing 26.3 Overriding WndProc to Handle Window Messages
public void EnumWindows()
{
// call the native dll function
EnumerateDeviceWindows( this.Hwnd );
}
// Override the default WndProc behavior to monitor messages.
protected override void WndProc(ref Message msg)
{
switch(msg.Msg)
{
case WM_USER_ADDWINDOW:
{
// get the window title using GetWindowText
StringBuilder windowText = new StringBuilder(1024);
GetWindowText( msg.LParam.ToInt32(), windowText, 1024 );
if( windowText.ToString() == “” )
break;
// if wParam is 1 then window is a child of someone
if( msg.WParam.ToInt32() == 1 )
windowText.Insert( 0, “ “);
// add it to the listbox of the main form
mainForm.AddWindow( msg.LParam, windowText.ToString() );
break;
}
default:
{
break;
}
}
// Call the base class WndProc for default message handling.
base.WndProc(ref msg);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -