一开始框里显示c:\,当我选择d:\的时候,为什么要选2次才是正确的信息???
高手来改下吧。
                          
OnSelchangeDriver() 
{
// TODO: Add your control notification handler code here
//UpdateData(TRUE); //获得选择的驱动器
CString Driver;
CComboBox* pDriver = (CComboBox*)GetDlgItem(IDC_DRIVER);
pDriver->GetWindowText(Driver); //获得磁盘空间信息
ULARGE_INTEGER FreeAv,TotalBytes,FreeBytes;
if(GetDiskFreeSpaceEx(Driver,&FreeAv,&TotalBytes,&FreeBytes))
{
//格式化信息,并显示出来
CString strTotalBytes,strFreeBytes;
strTotalBytes.Format("%uGB",TotalBytes.QuadPart/1024/1024/1024);
strFreeBytes.Format("%uGB",FreeBytes.QuadPart/1024/1024/1024);
CStatic* pTotalStatic = (CStatic*)GetDlgItem(IDC_TOTAL);
CStatic* pFreeStatic = (CStatic*)GetDlgItem(IDC_FREE);
pTotalStatic->SetWindowText(strTotalBytes);
pFreeStatic->SetWindowText(strFreeBytes);
}
    
}

解决方案 »

  1.   

    pDriver->GetWindowText(Driver);
    ==这个获取组合框选中的内容不好。用GetCurSel(),然后用GetLBText()来获取选中项信息。
      

  2.   

    CString Driver;
    CComboBox* pDriver = (CComboBox*)GetDlgItem(IDC_DRIVER);
    pDriver->GetWindowText(Driver);改成:CString Driver;
    CComboBox* pDriver = (CComboBox*)GetDlgItem(IDC_DRIVER);
    pDriver->GetLBText(pDriver.GetCurSel(), Driver);
      

  3.   

    pDriver->GetWindowText(Driver);
    改成
    m_select.GetLBText(m_select.GetCurSel(),Driver);
    结果还那样!!怎么办??
      

  4.   

    pDriver.GetCurSel()改成
    pDriver->GetCurSel()
    笔误
      

  5.   

    ==================JonneyR(lxc)============== 
    left of '.GetCurSel' must have class/struct/union type
    不可能这样改
      

  6.   

    CComboBox* pDriver = (CComboBox*)GetDlgItem(IDC_DRIVER);
    是个指针啊
      

  7.   

    pDriver.GetCurSel()改成
    pDriver->GetCurSel()
    笔误
    但还是要选择2次才是正确的值。。
    问题是要解决只选择一次就是正确的~~
      

  8.   

    int index = pDriver->GetCurSel();
    pDriver->SetCurSel(index);
    int length = pDriver->GetLBTextLen(index);
    m_clottyGradeCmb.GetLBText(index, Driver.GetBuffer(length));