| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
共有 184 人关注过本帖
标题:求助: 自定义 MessageBoxButtons 。
只看楼主 加入收藏
追梦人zmrghy
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:195
专家分:101
注 册:2021-4-9
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:4 
求助: 自定义 MessageBoxButtons 。
图片附件: 游客没有浏览图片的权限,请 登录注册


图片附件: 游客没有浏览图片的权限,请 登录注册


如何把 ‘是’‘否’‘取消’  改成   ‘继续闯关’‘再来一遍’‘退出游戏’。。。。


图片附件: 游客没有浏览图片的权限,请 登录注册


倒霉的MessageBoxButtons 只有这6种按钮组合方式呀
搜索更多相关主题的帖子: 游戏 组合方式 退出 自定义 按钮 
2022-08-05 21:01
追梦人zmrghy
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:195
专家分:101
注 册:2021-4-9
收藏
得分:0 
图片附件: 游客没有浏览图片的权限,请 登录注册


图片附件: 游客没有浏览图片的权限,请 登录注册


图片附件: 游客没有浏览图片的权限,请 登录注册
2022-08-05 22:24
apull
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:三体星系
等 级:版主
威 望:133
帖 子:1204
专家分:7155
注 册:2010-3-16
收藏
得分:10 
图片附件: 游客没有浏览图片的权限,请 登录注册

图片附件: 游客没有浏览图片的权限,请 登录注册


程序代码:
#pragma once


using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;

/// <summary>
/// MsgBox 摘要
/// </summary>
public ref class MsgBox : public System::Windows::Forms::Form
{
public:

    MsgBox(void)
    {
        InitializeComponent();
        //
        //TODO: 在此处添加构造函数代码
        //
    }

    System::Windows::Forms::DialogResult static Show(System::String^ caption, System::String^ text )
    {
        MsgBox^ msgbox = gcnew MsgBox();
        msgbox->Text = caption;
        msgbox->label1->Text = text;
        msgbox->ShowDialog();
        msgbox->~MsgBox();

        return result;
    }

protected:
    /// <summary>
    /// 清理所有正在使用的资源。
    /// </summary>

    ~MsgBox()
    {
        if (components)
        {
            delete components;
        }
    }

protected:


private:
    System::Windows::Forms::DialogResult static  result=::DialogResult::Ignore; //默认忽略,继续闯关

private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::Button^ button2;
private: System::Windows::Forms::Button^ button3;
private: System::Windows::Forms::Label^ label1;


       /// <summary>
       /// 必需的设计器变量。
       /// </summary>
       System::ComponentModel::Container^ components;

#pragma region Windows Form Designer generated code
       /// <summary>
       /// 设计器支持所需的方法 - 不要
       /// 使用代码编辑器修改此方法的内容。
       /// </summary>
       void InitializeComponent(void)
       {
           this->button1 = (gcnew System::Windows::Forms::Button());
           this->button2 = (gcnew System::Windows::Forms::Button());
           this->button3 = (gcnew System::Windows::Forms::Button());
           this->label1 = (gcnew System::Windows::Forms::Label());
           this->SuspendLayout();
           // 
           // button1
           // 
           this->button1->Location = System::Drawing::Point(12, 85);
           this->button1->Name = L"button1";
           this->button1->Size = System::Drawing::Size(75, 43);
           this->button1->TabIndex = 0;
           this->button1->Text = L"退出";
           this->button1->UseVisualStyleBackColor = true;
           this->button1->Click += gcnew System::EventHandler(this, &MsgBox::button1_Click);
           // 
           // button2
           // 
           this->button2->Location = System::Drawing::Point(125, 85);
           this->button2->Name = L"button2";
           this->button2->Size = System::Drawing::Size(75, 43);
           this->button2->TabIndex = 1;
           this->button2->Text = L"重玩";
           this->button2->UseVisualStyleBackColor = true;
           this->button2->Click += gcnew System::EventHandler(this, &MsgBox::button2_Click);
           // 
           // button3
           // 
           this->button3->Location = System::Drawing::Point(236, 85);
           this->button3->Name = L"button3";
           this->button3->Size = System::Drawing::Size(75, 43);
           this->button3->TabIndex = 2;
           this->button3->Text = L"继续";
           this->button3->UseVisualStyleBackColor = true;
           this->button3->Click += gcnew System::EventHandler(this, &MsgBox::button3_Click);
           // 
           // label1
           // 
           this->label1->Location = System::Drawing::Point(12, 24);
           this->label1->Name = L"label1";
           this->label1->Size = System::Drawing::Size(299, 35);
           this->label1->TabIndex = 3;
           this->label1->Text = L"label1";
           // 
           // MsgBox
           // 
           this->ClientSize = System::Drawing::Size(338, 155);
           this->Controls->Add(this->label1);
           this->Controls->Add(this->button3);
           this->Controls->Add(this->button2);
           this->Controls->Add(this->button1);
           this->KeyPreview = true;
           this->MaximizeBox = false;
           this->MinimizeBox = false;
           this->Name = L"MsgBox";
           this->ShowInTaskbar = false;
           this->StartPosition = System::Windows::Forms::FormStartPosition::CenterParent;
           this->TopMost = true;
           this->ResumeLayout(false);

       }
#pragma endregion


private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
    result = System::Windows::Forms::DialogResult::Abort;
    this->Visible = false;

}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
    result = System::Windows::Forms::DialogResult::Retry;
    this->Visible = false;
}
private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {
    result = System::Windows::Forms::DialogResult::Ignore;
    this->Visible = false;
}
};






程序代码:
使用:

Form1.h中

#include "MsgBox.h"


private: System::Void pictureBox2_DoubleClick(System::Object^ sender, System::EventArgs^ e) {
        System::Windows::Forms::DialogResult re=MsgBox::Show("过关!", "顺利过关,是否继续闯关?");
        MessageBox::Show(re.ToString());
    }


[此贴子已经被作者于2022-8-5 23:22编辑过]

2022-08-05 22:51
追梦人zmrghy
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:195
专家分:101
注 册:2021-4-9
收藏
得分:0 
回复 3楼 apull
是俩个winform窗体吗?
如何是winform窗体,如何去掉,右上角的 最小化、最大化 只留下一个关闭按钮呀?
2022-08-05 23:18
apull
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:三体星系
等 级:版主
威 望:133
帖 子:1204
专家分:7155
注 册:2010-3-16
收藏
得分:10 
添加一个Form当做Messagebox用。
 this->MaximizeBox = false; //最大化
 this->MinimizeBox = false; //最小化
 this->TopMost = true; //窗口置顶
2022-08-05 23:19
快速回复:求助: 自定义 MessageBoxButtons 。
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.074904 second(s), 9 queries.
Copyright©2004-2022, BCCN.NET, All Rights Reserved