我如何产生一个消息关闭form

icwin 2008-08-31 10:48:17
谢谢
...全文
77 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
walkingmu 2008-09-01
  • 打赏
  • 举报
回复
this.Close();
ZengHD 2008-08-31
  • 打赏
  • 举报
回复
        using System.Runtime.InteropServices;
[DllImport("User32.dll")]
private static extern IntPtr SendMessage(IntPtr hwnd, int msg, int wParam, int lParam);

private const int WM_CLOSE = 0x0010;
private void button1_Click(object sender, EventArgs e)
{
SendMessage(this.Handle, WM_CLOSE, 0, 0);
}
brallow 2008-08-31
  • 打赏
  • 举报
回复
需要引用空间:
using System.Runtime.InteropServices;
brallow 2008-08-31
  • 打赏
  • 举报
回复

public const int WM_CLOSE = 0x0010;

[DllImport("User32.dll")]
public static extern Int32 SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);


//调用此代码即发送关闭消息到指定的窗口
public void SendCloseWindow(Form f)
{
SendMessage(f.Handle,WM_CLOSE,0,0);
}
brallow 2008-08-31
  • 打赏
  • 举报
回复
public const int WM_CLOSE = 0x0010;

[DllImport("User32.dll")]
public static extern Int32 SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);


//调用此代码即发送关闭消息到指定的窗口
public void SendCloseWindow(Form f)
{
SendMessage(f.Handle,WM_CLOSE,0,0);
}

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧