如何打开一个新的对话框

点击某按钮,在单击事件里编写代码,打开新的对话框

方法:

(1)    首先为该对话框建立一个类。

(2)    然后在旧窗口里包含该类的头文件

(3)    然后为按钮增加如下事件:

void CDemoRadioCheckBoxDlg::OnBnClickedOpennewdlg()

{

   this->OnOK();//关闭旧窗口

   CAboutDlg dlg; //CAboutDlg为新类的名称

   dlg.DoModal();

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
当然可以!以下是一个使用uni-app编写的简单对话框示例: 1. 创建一个的uni-app项目。 2. 在需要使用对话框的页面的vue文件中,添加以下代码: ```html <template> <view> <button @click="showDialog">打开对话框</button> <dialog v-if="dialogVisible" @close="closeDialog"> <text slot="title">对话框标题</text> <view slot="content"> <text>这是对话框的内容</text> </view> <view slot="footer"> <button @click="closeDialog">关闭</button> </view> </dialog> </view> </template> <script> export default { data() { return { dialogVisible: false } }, methods: { showDialog() { this.dialogVisible = true; }, closeDialog() { this.dialogVisible = false; } } } </script> <style> </style> ``` 3. 在项目的components文件夹下创建一个名为"dialog"的文件夹,并在该文件夹中创建一个名为"dialog.vue"的vue组件文件。 4. 在dialog.vue文件中,添加以下代码: ```html <template> <view class="dialog-mask" @click.self="$emit('close')"> <view class="dialog-container"> <slot name="title"></slot> <slot name="content"></slot> <slot name="footer"></slot> </view> </view> </template> <script> export default { } </script> <style scoped> .dialog-mask { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0, 0, 0, 0.5); display: flex; justify-content: center; align-items: center; } .dialog-container { width: 80%; background-color: #fff; padding: 16px; } </style> ``` 5. 在需要使用对话框的页面的vue文件中,引入dialog组件: ```html <script> import dialog from '@/components/dialog/dialog.vue'; export default { components: { dialog } } </script> ``` 现在你就可以在页面中点击按钮,打开和关闭自定义的对话框了。你可以根据自己的需求修改对话框的样式和内容。希望对你有所帮助!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值