如何动态改变静态控件的内容,我在程序中做了一个无模式对话框,需要对二十多个警告信息进行对话框提示,基本样式就是创建的对话框,但说明文字不一样,该如何分别在对话框上显示不同的说明文字

解决方案 »

  1.   

    获得该对话框的句柄,hwnd->Static->SetWindowText("your message")
      

  2.   

    Static就是控件呀!你生成一个泥的控件的类实例,然后调用它的成员函数SetWindowText();
      

  3.   

    是吗,我这几天写的都不知道了,帮个忙。
    hwnd->Static这个怎么理解
      

  4.   

    窗口句柄指向窗口中的控件(类实例)如:CStatic *static; CEdit *edit; 等
      

  5.   

    ft
    CWnd *pw = GetDlgItem(IDC_STATIC**);
    pw->SetWindowText(_T("ggcua"));
      

  6.   

    改变字体(包括大小)用SetFont函数
      

  7.   

    你可以不用控件,得到窗口的DC,直接在上面写字.CDC* pDC = GetDC();
    CFont font;
    font.CreateFont();//可设置字体的属性,包括大小等
    CFont *pOldFont = pDC->SelectObject(&font);
    pDC->SetTextColor();//设置字体颜色
    ......
    pDC->TextOut();//输出文本
    ......
    pDC->SelectObject(pOldFont);//释放资源
      

  8.   

    能改变字的大小和Font,可以重载对话框的OnCtlColor()HBRUSH CXXXDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
    {
      // Call the base class implementation first! Otherwise, it may
      // undo what we are trying to accomplish here.
      HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);  // Are we painting the IDC_MYSTATIC control? We can use
      // CWnd::GetDlgCtrlID() to perform the most efficient test.
      if (pWnd->GetDlgCtrlID() == IDC_MYSTATIC)
      {
        // Set the text color to red.
        pDC->SetTextColor(RGB(255, 0, 0));    // Set the background mode for text to transparent 
        // so background will show thru.
        pDC->SetBkMode(TRANSPARENT);    // Return handle to our CBrush object.
        hbr = m_brush;
      }  return hbr;
    }