最近遇到的一些问题

1.Button添加iCO

BOOL CMyDlg::OnInitDialog()

{

        

       HICON   hicon   =   AfxGetApp()-> LoadIcon(IDI_ICON1);

       m_button1.SetIcon(hicon);

       return TRUE;  // return TRUE  unless you set the focus to a control

}

2. 如何使用RichEdit控件,为什么我一加入这个控件则我的窗体就不能显示了?

在C...App的InitInstance()里初始化:AfxInitRichEdit();

3.动态分割字符串

SplitString(CString str, char split, int &iSubStrs)

{

    int iPos = 0; //分割符位置

    int iNums = 0; //分割符的总数

    CString strTemp = str;

    CString strRight;

    //先计算子字符串的数量

    while (iPos != -1)

    {

        iPos = strTemp.Find(split);

        if (iPos == -1)

        {

            break;

        }

        strRight = strTemp.Mid(iPos + 1, str.GetLength());

        strTemp = strRight;

        iNums++;

    }

    if (iNums == 0) //没有找到分割符

    {

        //子字符串数就是字符串本身

        iSubStrs = 1;

        return NULL;

    }

    //子字符串数组

    iSubStrs = iNums + 1; //子串的数量 = 分割符数量 + 1

    CString* pStrSplit;

    pStrSplit = new CString[iSubStrs];

    strTemp = str;

    CString strLeft;

    for (int i = 0; i < iNums; i++)

    {

        iPos = strTemp.Find(split);

        //左子串

        strLeft = strTemp.Left(iPos);

        //右子串

        strRight = strTemp.Mid(iPos + 1, strTemp.GetLength());

        strTemp = strRight;

        pStrSplit[i] = strLeft;

    }

    pStrSplit[iNums] = strTemp;

    return pStrSplit;

 

}

 

 

调用:

       CString zhibiao;

       m_zhibiao.GetWindowText(zhibiao);

 

       CString* pStr;

    int iSubStrs;

    pStr = SplitString(zhibiao, ',', iSubStrs);

       if (iSubStrs == 1)

    {

        //Convert CString to char

        char* pCh = (LPSTR)(LPCTSTR)zhibiao;

        //printf("%s\n", pCh);       

    }

    else

    {   

        //输出所有子字符串

        for (int i = 0; i < iSubStrs; i++)

        {

            //Convert CString to char

            char* pCh = (LPSTR)(LPCTSTR)pStr[i];

            

        }

        delete []pStr;

}

4先为这些Radio Button排个顺序(这个必须要做,比如你的一组控件有Radio1,Radio2,Radio3,就把它们的TAB顺序分别设为1,2,3,并将Radio1Group属性设为True,这样,当选中Radio1的时候和它关联的变量就是0,当选中Radio2的时候和它关联的变量就是1,依此类推),就是排列他们的TAB ORDER。在对话框资源面板上Ctrl+D,然后按你自己的理想顺序用鼠标逐个点击就可以了。不妨假设Radio1Radio2Radio3 Radio4分别是1234Radio1Radio3都选上Group属性,那么,12是一组,34是另外一组,因为分组的原则是在选上 Group属性的这一个开始直到碰到下一个选上Group属性的。你不妨再Ctrl+D,令Radio1Radio2Radio3Radio4分别是1324,那么Radio1Radio3是一组,如果m_nRadio1=1,此时是Radio3被选上而不是Radio2被选上。分好了组就分别使用它们吧。

在加入一个Button控件,并为其写入Click事件代码:
int iRadioButton;

iRadioButton="GetCheckedRadioButton"(IDC_RADIO1,IDC_RADIO3);
if(iRadioButton==IDC_RADIO1)
MessageBox("Click Button1");
if(iRadioButton==IDC_RADIO2)
MessageBox("Click Button2");
if(iRadioButton==IDC_RADIO3)
MessageBox("Click Button3");

其他说明:
Radio Button
成组使用时,只需保证在添加控件时资源号连续,并且第一个Radio Button的属性中Group被选中即可.

 

5.子窗体使用父窗体数据    参数传递

CBP::OnInitDialog()

{

       CDialog::OnInitDialog();

      

       // TODO: Add extra initialization here

        CSet   *pDlg   =   (CSet*)GetParent(); //Cset为父窗体类

       CString in;//指标数据个数

       CString out="5";

       CString hide;

    in.Format("%d",pDlg->iSubStrs);

       m_input_num.SetWindowText(in);//显示输入层数据

       m_output_num.SetWindowText(out);

 

       return TRUE;  // return TRUE unless you set the focus to a control

                     // EXCEPTION: OCX Property Pages should return FALSE

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值