• 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);
    	}
  • 相关阅读:
    windows测试模式
    架构设计之Spring-Session的分布式集群会话管理
    WPF集合
    java Socket Udp
    java Socket 获取本地主机ip
    快速排序
    java 正则举例
    JNI 在命令行窗口输入字符,不显所输入字符,显指定的掩饰符
    java 在控制台上输入密码时,密码不显示在控制台上
    java 获取对象大小
  • 原文地址:https://www.cnblogs.com/dbasys/p/1749839.html
Copyright © 2020-2023  润新知