就是自己新建立一个窗体,然后自己在上面画几个BUTTON.要用的时候就弹出来.很简单.消息框跟普通窗体没区别。

解决方案 »

  1.   

    哈哈,
    就是自己建立一个form,比如叫做form5,在form5上放你想要的按钮如“重试”写成“再来一次”,然后当点击这个按钮时:
    this.DiologResult=DiologResult.OK   (好像英文拼写不太对,反正就是这个意思,呵呵)在你要调用这个所谓信息框的界面中:
    form5 f5 =new form5;
    f5.ShowDiolog();就可以了。
    要判断是否按钮被点击,只要判断:
    if (f5.DiologResult==DiologResult.OK)    \\注意判断中用==,而不要写成=
     .....不知道说清楚了么,(好像英文拼写不太对,反正就是这个意思,再次,呵呵)
      

  2.   

    通过截获消息实现,参考如下代码:
    public delegate IntPtr HookProc(int nCode, IntPtr wParam, IntPtr lParam);[DllImport("user32.dll")]
    public static extern IntPtr SetWindowsHookEx(int hookid,
        HookProc pfnhook, IntPtr hinst, int threadid);[DllImport("user32.dll")]
    public static extern IntPtr CallNextHookEx(IntPtr hhook,
        int code, IntPtr wparam, IntPtr lparam);[DllImport("kernel32.dll")]
    public static extern IntPtr GetModuleHandle(string modName);[DllImport("user32.dll")]
    public static extern bool UnhookWindowsHookEx(IntPtr hhook);public const int WH_CBT = 5;
    public const int HCBT_ACTIVATE = 5;
    IntPtr hookHandle = IntPtr.Zero;public delegate bool WNDENUMPROC(IntPtr hwnd, int lParam);[DllImport("user32.dll")]
    public static extern int EnumChildWindows(IntPtr hWndParent,
        WNDENUMPROC lpEnumFunc, int lParam);[DllImport("user32.dll")]
    public static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName,
        int nMaxCount);[DllImport("user32.dll")]
    public static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString,
        int nMaxCount);[DllImport("user32.dll")]
    public static extern void SetWindowText(IntPtr hwnd, string lpString);public bool EnumChild(IntPtr hwnd, int lParam)
    {
        StringBuilder vBuffer = new StringBuilder(256);
        GetClassName(hwnd, vBuffer, vBuffer.Capacity);
        if (vBuffer.ToString().ToLower() == "button") // 按钮
        {
            StringBuilder vText = new StringBuilder(256);
            GetWindowText(hwnd, vText, vText.Capacity);
            if (vText.ToString().ToLower().IndexOf("&a") >= 0) // 终止
                SetWindowText(hwnd, "停不要动");
            if (vText.ToString().ToLower().IndexOf("&r") >= 0) // 重试
                SetWindowText(hwnd, "再来一次");
            if (vText.ToString().ToLower().IndexOf("&i") >= 0) // 忽略
                SetWindowText(hwnd, "就这样吧");
        }
        return true;
    }private IntPtr CBTHookCallback(int nCode, IntPtr wParam, IntPtr lParam)
    {
        switch (nCode)
        {
            case HCBT_ACTIVATE:
                EnumChildWindows(wParam, new WNDENUMPROC(EnumChild), 0);
                UnhookWindowsHookEx(hookHandle);
                break;
        }
        return CallNextHookEx(hookHandle, nCode, wParam, lParam);
    }
    private void button1_Click(object sender, EventArgs e)
    {
        hookHandle = SetWindowsHookEx(WH_CBT, new HookProc(CBTHookCallback),
            GetModuleHandle(null), 0);
        MessageBox.Show("Zswang 路过", "提示", MessageBoxButtons.AbortRetryIgnore);
    }
    再蹭点分