這是運行結果:
using System; using System.Runtime.InteropServices; using System.Windows.Forms; namespace HoverTreeWinForm { public partial class FormHewenqi : Form { /// <summary> /// http://hovertree.com/h/bjaf/v4y0b2l6.htm /// </summary> /// <param name="h"></param> /// <param name="m"></param> /// <param name="c"></param> /// <param name="type"></param> /// <returns></returns> [DllImport("User32.dll")] public static extern int MessageBox(int h, string m, string c, int type); public FormHewenqi() { InitializeComponent(); } private void button_hewenqi_Click(object sender, EventArgs e) { MessageBox(0, "Hello Win32 API HoverTree", "何問起網", 4); } private void linkLabel_help_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { System.Diagnostics.Process.Start("http://hovertree.com/h/bjaf/v4y0b2l6.htm"); } } }
轉載自:http://hovertree.com/h/bjaf/psjdasa2.htm
源碼下載:http://pan.baidu.com/s/1bnPPgL5
http://roucheng.cnblogs.com/
上面的示例,彈出信息框窗口並沒有指定父窗口句柄,所以彈出後,不用關掉就可以操作主窗體,比如你可以多次點擊按鈕彈出多個信息框。如果要彈出模式對話框,需先獲取當前窗體的句柄,請參考:http://hovertree.com/h/bjaf/8vw6i2yr.htm
模式對話框演示: http://pan.baidu.com/s/1bnNN2b1 密碼: dq8u
源碼下載:https://github.com/shangyuxian/HoverTree