zoukankan      html  css  js  c++  java
  • C++ Caption

    主题

    1. 设置控件的标题文本

    2. 获取控件的标题文本

     
     

    Caption属性

    取得一个窗体的标题(caption)文字,或者一个控件的内容
     
    红色的部分就是 Caption 标题
     

    SetWindowText

    BOOL SetWindowText(          

        HWND hWnd,

        LPCTSTR lpString

    );

     

     

    SetDlgItemText

    void SetDlgItemText(
            int nID,           //控件的ID号
            LPCTSTR lpszString //字符串
     );
     

    设置控件的标题文本 使用API SetWindowText

    //使用CWnd
    CWnd *pWnd;
    pWnd = GetDlgItem( IDC_BUTTON1 ); //按钮1的ID
    pWnd->SetWindowText( "ABC" );
     
    //设置主窗体的标题
    SetWindowText(_T("MFC"));
     
    //设置按钮的文本
    GetDlgItem(IDC_BUTTON1)->SetWindowText(_T("BTN1"));
    //或
    SetDlgItemText(IDC_BUTTON1,"ABCD");
     
    //设置多选框的文字 (关联变量)
    m_CHK1.SetWindowText(_T("CheckBox1"));
    //或
    SetDlgItemText(IDC_CHECK1,"ABCD");
     
     
     
     
     

    GetWindowText

     
    int GetWindowText(         
        HWND hWnd,
        LPTSTR lpString,
        int nMaxCount
    );
     
     

    GetDlgItemText

    int GetDlgItemText(
        int nID,
        LPTSTR lpStr,
        int nMaxCount
    ) const;
     
    int GetDlgItemText(
         int nID,
         CString& rString
    ) const;
     
     

    获取控件的标题文本 使用API GetWindowText可以实现

     

    //获取到按钮1的文本 并设置给主窗体的标题
    CString str;
    this->GetDlgItem(IDC_BUTTON1)->GetWindowText(str);
    this->SetWindowText(str);
     
                    
    CString s;
    GetDlgItemText(IDC_BUTTON1,s);
    MessageBox(s);
     
     




  • 相关阅读:
    基于MongoDB.Driver的扩展
    通用查询设计思想
    API接口通讯参数规范
    lambda简单记录
    list去重精简代码版
    spring boot file上传
    fastjson过滤器简单记录
    java读取properties文件
    list循环删除单个元素
    MapReduce运行流程分析
  • 原文地址:https://www.cnblogs.com/xe2011/p/3885705.html
Copyright © 2011-2022 走看看