windows api一个窗体激活的时候给另外一个发消息 using System; using SystemWindowsForms; using SystemRuntimeInteropServices; namespace WindowsApplication { public partial class Form : Form { Form frm =null; public Form() { InitializeComponent(); thisActivated += Form_Activated; } const int WM_NCACTIVATE = x; const int WA_ACTIVE = x; [DllImport(userdll EntryPoint = SendMessage)] public static extern int SendMessage(IntPtr hWnd int wMsg int wParam int lParam); private void button_Click(object sender EventArgs e) { frm = new Form(); frmText = jinjazz; frmActivated += Form_Activated; frmShow(); frmLocation = new SystemDrawingPoint(thisLeft + thisWidth thisTop); SendMessage(thisHandle WM_NCACTIVATE WA_ACTIVE ); } void Form_Activated(object sender EventArgs e) { SendMessage(thisHandle WM_NCACTIVATE WA_ACTIVE ); if (frm != null) SendMessage(frmHandle WM_NCACTIVATE WA_ACTIVE ); } } } |