visual c++ - How to set last Unused drive letter to Combobox in MFC (VC++)? -
how set last unused drive letter combobox in mfc (vc++) ? code :
tchar g_szdrvmsg[] = _t("a:\n"); int main(int argc, char* argv[]) { ulong udrivemask = _getdrives(); if (udrivemask == 0) { printf( "_getdrives() failed failure code: %d\n", getlasterror()); //so getlasterror retuns sring or char*? } else { printf("the following logical drives being used:\n"); while (udrivemask) { if (!(udrivemask & 1)) m_objcmbdrive.addstring(g_szdrvmsg); ++g_szdrvmsg[0]; udrivemask >>= 1; }
} }
m_objcmbdrive.setcursel();
what value should pass setcursel set drive letter in descending order.
this code gives me drive drive letters being used in system. how unused 1 out ?
to select last item in combobox, can do:
m_objcmbdrive.setcursel(m_objcmbdrive.getcount() - 1);
to fill combobox unused drive letters in descending order, use insertstring() method:
for (int = 0; < 26; ++i) { if (!(udrivemask & 1)) { m_objcmbdrive.insertstring(0, g_szdrvmsg); } ++g_szdrvmsg[0]; udrivemask >>= 1; }
Comments
Post a Comment