zoukankan      html  css  js  c++  java
  • MFC中弹出对话框

    VS2010 C++ 中新的弹出对话框

    1 添加头函数

    #include "afxdialogex.h"
    #include "afxtaskdialog.h"

    2 代码如下

            //qiangguo 2010-5-26
    	CString message("My message to the user");
    	CString dialogTitle("My Task Dialog title");
    	CString emptyString;
    	// TODO: Add your control notification handler code here
    	CString expandedLabel("Hide extra information");
    	CString collapsedLabel("Show extra information");
    	CString expansionInfo("This is the additional information to the user,\nextended over two lines.");
    
    
    	if (CTaskDialog::IsSupported())
    	{
    		// 1 直接使用
    		HRESULT result2 = CTaskDialog::ShowDialog(L"My error message", L"Error", L"New Title", TEMP_LINE1, TEMP_LINE2);
    
    		// 2 详细设置
    	    CTaskDialog taskDialog(message, emptyString, dialogTitle, TDCBF_OK_BUTTON);
    		taskDialog.SetMainIcon(TD_WARNING_ICON);
    		//taskDialog.DoModal();
    
    		taskDialog.SetMainInstruction(L"Warning");
    		taskDialog.SetCommonButtons(TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON);
    		taskDialog.LoadCommandControls(TEMP_LINE1, TEMP_LINE2);
    		taskDialog.SetExpansionArea(expansionInfo, collapsedLabel, expandedLabel);
    		taskDialog.SetFooterText(L"This is the a small footnote to the user");
    		taskDialog.SetVerificationCheckboxText(L"Remember your selection");
    		INT_PTR result = taskDialog.DoModal();
    
    		if (taskDialog.GetVerificationCheckboxState() )
    		{
    		   // PROCESS IF the user selects the verification checkbox 
    		}
    		switch (result)
    		{
    		   case TEMP_LINE1:
    			  // PROCESS IF the first command line
    			  break;
    		   case TEMP_LINE2:
    			  // PROCESS IF the second command line
    			  break;
    		   case IDYES:
    			  // PROCESS IF the user clicks yes
    			  break;
    		   case IDNO:
    			  // PROCESS IF the user clicks no
    			  break;
    		   case IDCANCEL:
    			  // PROCESS IF the user clicks cancel
    			  break;
    		   default:
    			  // This case should not be hit because closing the dialog box results in IDCANCEL
    			  break;
    		}
    	}
    	else
    	{
    	   AfxMessageBox(message);
    	}
  • 相关阅读:
    微信打开网址添加在浏览器中打开提示遮罩
    Java内存分配之堆、栈和常量池
    腾讯面试题04.进程和线程的区别?
    cookie 和 session的区别
    jvm内存模型-回收算法-和内存分配以及jdk、jre、jvm是什么关系(阿里,美团,京东面试题)
    HTTP中GET与POST的区别
    Socket send函数和recv函数详解
    JSP九大内置对象及四个作用域
    JavaScript
    网页布局(html+css基础)
  • 原文地址:https://www.cnblogs.com/dbasys/p/1749839.html
Copyright © 2011-2022 走看看