• MFC笔记7


    1.VS中显示行号

    工具 -> 选项 -> 文本编辑器 -> C/C++ -> 行号

    2.VS中调整字体大小

    工具 -> 选项 -> 环境->字体和颜色

    3.VS中调试编译按钮

    在VS工具窗口右键->生成

    4.消息对话框

      1)MessageBox(_T("你好!"),MB_OK);

      

      2)MessageBox(_T("你好!"),_T("你好!"),MB_YESNO);

    5.MFC中find函数用法

    CString::Find()函数

    注:CString::Find函数,如果给定的参数是一个字符串,那么它必须与此字符串中的某一个子字符串完全匹配才能返回相匹配的子字符串第一个字符的索引。

    CString::Find

    作用

      在一个较大的字符串中查找字符或子字符串
      int Find( TCHAR ch ) const;
      int Find( LPCTSTR lpszSub ) const;
      int Find( TCHAR ch, int nStart ) const;
      int Find( LPCTSTR lpszSub, int nStart ) const;
     

    返回值

      返回此CString对象中与需要的子字符串或字符匹配的第一个字符的从零开始的索引;如果没有找到子字符串或字符则返回-1。

    参数

      ch 要搜索的单个字符。
      lpszSub 要搜索的子字符串。
      nStart 字符串中开始搜索的字符的索引,如果是0,则是从头开始搜索。如果nStart不是0,则位于nStart处的字符不包括在搜索之内。
      pstr 指向要搜索的字符串的指针

    说明

      此成员函数用来在此字符串中搜索子字符串的第一个匹配的字符。函数的重载可以接收单个字符(类似于运行时函数strchr)和字符串(类似于strstr)。
        //下面演示第一个例子
    
      // CString::Find( TCHAR ch )
      CString s( "abcdef" );
      int n = s.Find( 'c' ); // 结果 n = 2
      int f = s.Find( "de" ) ; // 结果 f = 3
      ASSERT( n == 2 );
      ASSERT( f == 3 );
      // 下面演示第二个例子
      // CString::Find(TCHAR ch,int nStart)
      CString str("The stars are aligned");
      int n = str.Find('e',5); //结果 n = 12
      ASSERT(n == 12)

    6.

    //错误的
            int num1,num2,num3;
    	char ch1[10], ch2[10], ch3[10];
    
    	GetDlgItem(IDC_EDIT2)->GetWindowText(ch1,10);
    	GetDlgItem(IDC_EDIT3)->GetWindowText(ch2,10);
    
    	num1 = atoi (ch1);
    	num2 = atoi (ch2);
    	num3 = num1 + num2;
    
    	atoi (num3,ch3,10);
    	GetDlgItem(IDC_EDIT4)->SetWindowText(ch3);    
    

     

    //正确的
    #include <shlwapi.h>// 添加头文件  
    
        int num1,num2,num3;
        CString ch1, ch2;
        CString ch3;
    
        GetDlgItem(IDC_EDIT2)->GetWindowText(ch1);
        GetDlgItem(IDC_EDIT3)->GetWindowText(ch2);
    
        num1=StrToInt(ch1);
        num2=StrToInt(ch2);
        num3 = num1 + num2;
    
        ch3.Format(L"%d",num3);
        GetDlgItem(IDC_EDIT4)->SetWindowText(ch3);   

     

     

      

  • 相关阅读:
    Azure Cognitive Service 访问优化
    Azure Managed Disk 共享不灵,EventGrid + LogicApp 来搞
    AZURE ACI -- 无服务器化容器解决方案
    Global Azure 与 China Azure 互联
    小总结
    存储过程及Comm.cs类的创建
    DataGrid1
    根据经纬度和半径计算经纬度范围
    CheckBoxJS选中与反选得到Value
    每天学一点-Jquery判断checkbox是否为选中状态
  • 原文地址:https://www.cnblogs.com/zhangerxiaoma/p/5005427.html
Copyright © 2020-2023  润新知