c# 无法通过sendmessage为WM_SYSCOMMAND传值
我想在程序中通过点击按钮实现窗体的最小化,相当于一个最小化按钮,但是我在调用SendMessage(this.Handle,WM_SYSCOMMAND,SC_MINIMIZE, 0);时程序没有任何反应,哪位朋友能告诉我问题出在哪里了我的开发环境为vs2010
我的代码如下(我做的是一个鼠标手势的软件,下面的代码是简化版,也出现了同样的问题):
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace send
{
public partial class Form1 : Form
{
[DllImportAttribute("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
const int SC_MINIMIZE=61472;
const int WM_SYSCOMMAND = 274;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
SendMessage(this.Handle,WM_SYSCOMMAND,SC_MINIMIZE, 0); //这里不能正常工作
}
}
}
菜鸟一枚,出现的问题还很低级,让大家见笑了 c# sendmessage() vs2010
补充:.NET技术 , C#