Click here to Skip to main content
15,920,217 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: A Major clue Pin
RandomMonkey30-Oct-05 6:10
RandomMonkey30-Oct-05 6:10 
QuestionIP range. Help Needed Pin
Radu Sorin28-Oct-05 20:40
Radu Sorin28-Oct-05 20:40 
AnswerRe: IP range. Help Needed Pin
Ghasrfakhri29-Oct-05 0:06
Ghasrfakhri29-Oct-05 0:06 
Questioncannot convert parameter 1 from 'CComboBox' to 'CComboBox' Pin
kevincwong28-Oct-05 19:31
kevincwong28-Oct-05 19:31 
AnswerRe: cannot convert parameter 1 from 'CComboBox' to 'CComboBox' Pin
RandomMonkey28-Oct-05 19:48
RandomMonkey28-Oct-05 19:48 
GeneralRe: cannot convert parameter 1 from 'CComboBox' to 'CComboBox' Pin
kevincwong28-Oct-05 20:10
kevincwong28-Oct-05 20:10 
QuestionSave/Open Dialog Pin
Tom Sapp28-Oct-05 17:22
Tom Sapp28-Oct-05 17:22 
AnswerRe: Save/Open Dialog Pin
RandomMonkey28-Oct-05 18:06
RandomMonkey28-Oct-05 18:06 
There may be a better way than the following in VC. I don't know, though, as I don't use VC. The following helper functions have worked for me, and you are welcome to them. Maybe somebody else can give us both that better way. 'wString' is a typedef for std::basic_string<tchar>, which becomes std::string, so you can just replace 'wString' with 'std::string', and it should work for you. If you find any errors in this, all I can say is that I never claimed to be perfect.

David

bool rmw::fileExists(const wString & fileName) {
   WIN32_FIND_DATA d;
   HANDLE file = FindFirstFile(fileName.c_str(), &d);
   bool retVal(true);
   if (file == INVALID_HANDLE_VALUE) retVal = false;
   FindClose(file);
   return retVal;
   }


wString rmw::getPathFromStr(const wString & str) {
   int pos = str.find_last_of(TEXT("\\"));
   return wString(str.substr(0, pos));
   }


wString rmw::extractFileName(const wString & str) {
   int pos = str.find_last_of(TEXT("\\"));
   return wString(str.substr(pos+1, str.length()));
   }


wString rmw::extractFileExt(const wString & str) {
   int pos = str.find_last_of(TEXT("."));
   if (pos == -1) return "";
   return wString(str.substr(pos, str.length()));
   }


wString rmw::trimFileExt(const wString & fileName) {
   wString fileExt = rmw::extractFileExt(fileName);
   int len = fileExt.length();
   return fileName.substr(0, fileName.length()-len);
   }


wString rmw::extractFileDir(const wString & fileName) {
   int pos(fileName.find_last_of(TEXT("\\")));
   wString t = fileName.substr(0, fileName.length()-pos);
   return t;
   }


(Gotta love that STL!)

Debugging - The high art and magic of cussing errors into 'features'
AnswerRe: Save/Open Dialog Pin
Gary R. Wheeler29-Oct-05 3:35
Gary R. Wheeler29-Oct-05 3:35 
QuestionWINVER and Graphics projects using glut Pin
adonisv28-Oct-05 15:40
adonisv28-Oct-05 15:40 
Questionneed help in speech recognitiion Pin
gr8coaster32928-Oct-05 13:22
gr8coaster32928-Oct-05 13:22 
AnswerRe: need help in speech recognitiion Pin
Ravi Bhavnani28-Oct-05 16:54
professionalRavi Bhavnani28-Oct-05 16:54 
QuestionRe: need help in speech recognitiion Pin
gr8coaster32929-Oct-05 7:01
gr8coaster32929-Oct-05 7:01 
AnswerRe: need help in speech recognitiion Pin
Ravi Bhavnani29-Oct-05 7:07
professionalRavi Bhavnani29-Oct-05 7:07 
Questionparallel port Pin
jama68728-Oct-05 12:57
jama68728-Oct-05 12:57 
AnswerRe: parallel port Pin
Indivara28-Oct-05 17:19
professionalIndivara28-Oct-05 17:19 
QuestionA couple of Reference Function questions Pin
j4express28-Oct-05 12:45
j4express28-Oct-05 12:45 
AnswerRe: A couple of Reference Function questions Pin
Prakash Nadar28-Oct-05 17:34
Prakash Nadar28-Oct-05 17:34 
AnswerRe: A couple of Reference Function questions Pin
ddupre28-Oct-05 22:54
ddupre28-Oct-05 22:54 
QuestionCompiling Errors Pin
RedDragon2k28-Oct-05 9:05
RedDragon2k28-Oct-05 9:05 
AnswerRe: Compiling Errors Pin
David Crow28-Oct-05 9:40
David Crow28-Oct-05 9:40 
AnswerRe: Compiling Errors Pin
Chris Losinger28-Oct-05 9:56
professionalChris Losinger28-Oct-05 9:56 
QuestionHow to sleep my displays (monitors)? Pin
bitpusher28-Oct-05 8:40
bitpusher28-Oct-05 8:40 
AnswerRe: How to sleep my displays (monitors)? Pin
Blake Miller28-Oct-05 11:54
Blake Miller28-Oct-05 11:54 
Questionruntime error Pin
hamavreg28-Oct-05 8:19
hamavreg28-Oct-05 8:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.