我想你没弄清楚我说的意思,2002pine() 说的就有点意思了sendMessage(),是的,这个时候只能用消息了,可是你在MessageBox中找不到可以用来处理消息的方法,所以你必须用自己的窗体来实现然后投递一个close消息.这里我给个代码片段你public class Win32 { public const int WM_SYSCOMMAND = 0x0112; public const int SC_CLOSE= 0x004A; [DllImport("user32.dll")] public static extern int SendMessage( int hWnd, // handle to destination window uint Msg, // message int wParam, // first message parameter int lParam // second message parameter ); } 这是你要实现的sendmessage然后,将是你的窗体中实现关闭 然后满足具体条件发送消息 int j=Win32.SendMessage(iHandle, Win32.WM_SYSCOMMAND, Win32.SC_CLOSE, 0);
int hwnd=FindWindow("","caption"); DestroyWindow(hwnd);but you cannot shut MessageBox Window in the same function with MessageBox, you can in other function use ,such as timer()
[DllImport("user32.dll")] public static extern int SendMessage( int hWnd, // handle to destination window uint Msg, // message int wParam, // first message parameter int lParam // second message parameter ); }
这是你要实现的sendmessage然后,将是你的窗体中实现关闭
然后满足具体条件发送消息
int j=Win32.SendMessage(iHandle, Win32.WM_SYSCOMMAND, Win32.SC_CLOSE, 0);
DestroyWindow(hwnd);but you cannot shut MessageBox Window in the same function with MessageBox, you can in other function use ,such as timer()
不是吧?????那样既过多的占用处理线程,有做了很多不必要的事情如果是在一个事实交互的系统中,显然更行不通,而消息是windows系统的循环,处理这样的事情是份内的.