Click here to Skip to main content
15,921,837 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow to recognize a word under mouse position? Pin
14-Nov-01 21:53
suss14-Nov-01 21:53 
AnswerRe: How to recognize a word under mouse position? Pin
Christian Graus15-Nov-01 8:48
protectorChristian Graus15-Nov-01 8:48 
AnswerRe: How to recognize a word under mouse position? Pin
Joaquín M López Muñoz15-Nov-01 9:41
Joaquín M López Muñoz15-Nov-01 9:41 
AnswerRe: How to recognize a word under mouse position? Pin
Kind15-Nov-01 15:03
Kind15-Nov-01 15:03 
GeneralRe: How to recognize a word under mouse position? Pin
Saeed Torabi18-Dec-01 23:37
Saeed Torabi18-Dec-01 23:37 
GeneralAbout MSHTML Pin
14-Nov-01 21:34
suss14-Nov-01 21:34 
QuestionSearch a file? Pin
Rickard Andersson2014-Nov-01 20:59
Rickard Andersson2014-Nov-01 20:59 
AnswerRe: Search a file? Pin
Rassman15-Nov-01 2:47
Rassman15-Nov-01 2:47 
use FindFirstFile and findNextFile.

If you want to use them to recurse through directories then have a self calling function. In this case the function is SearchDir(). I used this particular method because my app always knows the sort of files it is looking for. From this you will see how easy it is to write a single class that does all such searches for you.

Self recursive functions take a little extra care to design. Remember that each instance of the function is entirely independant as far as it's local data is concerned, so any changed data needed in a child has to be passed to the child. Also, the instances will likely trip over each other if you have the function touch global data, I would say to not do this at all, but I can't because I have done it myself deliberately, using 'volatile' data types.

This isn't the fastest method in the world, but its not bad, and it at least shows how the goal is reached. I have left it sort of spread out so its easier to see whats going on.

On my Linux file server I cheat something chronic, I have a process that gathers changes in the /home directory/sub directories so that there are always ready for me to pick up from a text file.

void View::FindMyFiles()
{
CString lString;
lString = "don*.xml" ;
if(FindFile( lString ))
{
//put them through my wonderfull xml parser
//ok, so it occasionally misses a field or
//two, but otherwise, its ok.
}
}

//I like this one seperate from FindMyFiles() so that I can call it
//from other places in my code
bool View::FindFile(CString &FName)
{
CString lString;
m_FindThis = FName;
//change this to recurse or set a/each drive
lString.Format("C:");
//we don't return from this until all of the directories from "C:" have been recursed.
//So you need a way out when what your after is found.
SearchDir(lString);
return TRUE; //TODO: error checking
}

void View::SearchDir(CString sPath)
{
CString sFind,sTemp;
CString sBase,sBase2;
int Done;
WIN32_FIND_DATA lpFindFileData;

HANDLE SearchHandle;

sBase = sPath;

sFind.Format("%s\\*.*",sBase);
SearchHandle = FindFirstFile(sFind,&lpFindFileData);
if( SearchHandle != INVALID_HANDLE_VALUE)
Done = 0;
else
Done = 1;
while( !Done )
{
do
{
if( lpFindFileData.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY )
{
sTemp = lpFindFileData.cFileName;
if( (sTemp.Find("..") != -1) || (sTemp.GetLength()==1) )
;
else
{//this is a dir so call SearchDir with modified path
sBase2.Format("%s\\%s",sBase,lpFindFileData.cFileName);
SearchDir(sBase2);
}
}
else
{//do whatever you want to do with a file name
sTemp = lpFindFileData.cFileName;
//if this first is all you wanted then put a getout point here
}
}
while(FindNextFile(SearchHandle,&lpFindFileData));
Done = 1;
}
}

In reality, I nearly always put my file finder as a seperate thread and let it go in the background long before I may need it, updateing a CFileList type data class. Its so impressive to open a dialog and all drives/files even fileserver dirs/files are instantly accessible. Well to me it is, the users don't tend to know its meant to be slower so no one makes me a coffee or brings me a donut....




We do it for the joy of seeing the users struggle.
GeneralImplementing plugins Pin
Nevidimka14-Nov-01 20:28
Nevidimka14-Nov-01 20:28 
GeneralRe: Implementing plugins Pin
moliate16-Nov-01 5:39
moliate16-Nov-01 5:39 
GeneralRe: Implementing plugins Pin
Nevidimka18-Nov-01 18:26
Nevidimka18-Nov-01 18:26 
GeneralShellExecute Pin
Ralfy14-Nov-01 18:40
Ralfy14-Nov-01 18:40 
GeneralRe: ShellExecute Pin
Nish Nishant14-Nov-01 19:15
sitebuilderNish Nishant14-Nov-01 19:15 
GeneralRe: ShellExecute Pin
Ralfy14-Nov-01 21:01
Ralfy14-Nov-01 21:01 
GeneralRe: ShellExecute Pin
Nish Nishant15-Nov-01 2:10
sitebuilderNish Nishant15-Nov-01 2:10 
GeneralRe: ShellExecute Pin
Ralfy15-Nov-01 17:53
Ralfy15-Nov-01 17:53 
GeneralRe: ShellExecute Pin
Nish Nishant15-Nov-01 18:01
sitebuilderNish Nishant15-Nov-01 18:01 
GeneralRe: ShellExecute Pin
Carlos Antollini15-Nov-01 3:02
Carlos Antollini15-Nov-01 3:02 
GeneralChanging the font of the CTabCtrl Pin
Mark Donkers14-Nov-01 17:16
Mark Donkers14-Nov-01 17:16 
GeneralRe: Changing the font of the CTabCtrl Pin
Nish Nishant14-Nov-01 18:28
sitebuilderNish Nishant14-Nov-01 18:28 
GeneralRe: Changing the font of the CTabCtrl Pin
Mark Donkers15-Nov-01 3:07
Mark Donkers15-Nov-01 3:07 
GeneralRe: Changing the font of the CTabCtrl Pin
Nish Nishant15-Nov-01 3:25
sitebuilderNish Nishant15-Nov-01 3:25 
Generalredirecting display to go to printer Pin
14-Nov-01 14:59
suss14-Nov-01 14:59 
QuestionHow to get and set colors of the each pixel in a bitmap? Pin
chen14-Nov-01 14:25
chen14-Nov-01 14:25 
AnswerRe: How to get and set colors of the each pixel in a bitmap? Pin
Christian Graus14-Nov-01 14:29
protectorChristian Graus14-Nov-01 14:29 

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.