• 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);
    	}
  • 相关阅读:
    javascript有用小技巧—实现分栏显示
    在Apk应用程序内,查找某个Activity。
    NodeJS系列~第一个小例子,实现了request.querystring功能
    IOS开发(objective-c)~开篇有理
    爱上MVC3~布局页的继承与扩展
    我心中的核心组件(可插拔的AOP)~第五回 消息组件
    基础才是重中之重~方法override详解
    数据结构 练习 20-查找 算法
    cocos2d-x适配多分辨率
    VS2010中使用CL快速 生成DLL的方法
  • 原文地址:https://www.cnblogs.com/dbasys/p/1749839.html
Copyright © 2020-2023  润新知