|
- 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 WindowsFormsApplication2
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- [DllImport("user32.DLL", EntryPoint = "MessageBoxA")]
- public static extern int MessageBoxA(int 窗口句柄, string 提示信息, string 窗口标题, int 按钮值);
- [DllImport("user32.DLL", EntryPoint = "FindWindowA")]
- public static extern int FindWindowA(string 窗口类名, string 窗口标题);
- /*[System.Runtime.InteropServices.DllImport("user32.dll")]
- public static extern int MessageBoxA(int 窗口句柄, string 提示信息, string 窗口标题, int 按钮值);*/
- private void Form1_Load(object sender, EventArgs e)
- {
- button1.Text = "按钮 One";
- label1.Text = "C# 信息框小案例";
- }
- private void button1_Click(object sender, EventArgs e)
- {
- int Hwnd = 0;
- string[] ClassName = new string[2]
- { "", "" };
- ClassName[1] = Text;
- Hwnd = FindWindowA(ClassName[0], ClassName[1]);
- MessageBoxA(Hwnd, "信息框小案例", "提示", 64);
- }
- }
- }
复制代码
WindowsFormsApplication2.rar
(37.87 KB, 下载次数: 13)
|
|