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);
     
     




  • 相关阅读:
    结构化思考力
    对象序列化解析
    单元测试的规范
    关于CefSharp的坎坷之路
    构建基于Chromium的应用程序
    C# 面向切面编程(AOP)--监控日志记录方案
    CefSharp 中断点 已达到中断点
    用批处理命令实现激活office2016
    Winform开发中的困境及解决方案
    VUE+Element 前端应用开发框架功能介绍
  • 原文地址:https://www.cnblogs.com/xe2011/p/3885705.html
Copyright © 2011-2022 走看看