Click here to Skip to main content
15,909,193 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CWinApp::OnIdle in Dll - is NOT called Pin
Michael Dunn21-Nov-01 6:20
sitebuilderMichael Dunn21-Nov-01 6:20 
GeneralDialog buttons Pin
et20-Nov-01 23:17
et20-Nov-01 23:17 
GeneralRe: Dialog buttons Pin
Christian Graus21-Nov-01 0:39
protectorChristian Graus21-Nov-01 0:39 
GeneralScope of try...catch constructions (over threads) Pin
EiSl20-Nov-01 21:42
EiSl20-Nov-01 21:42 
GeneralRe: Scope of try...catch constructions (over threads) Pin
Joaquín M López Muñoz20-Nov-01 23:11
Joaquín M López Muñoz20-Nov-01 23:11 
GeneralRe: Scope of try...catch constructions (over threads) Pin
Rui Lopes20-Nov-01 23:15
Rui Lopes20-Nov-01 23:15 
QuestionCFindFile? Pin
20-Nov-01 20:57
suss20-Nov-01 20:57 
AnswerRe: CFindFile? Pin
Rassman20-Nov-01 22:03
Rassman20-Nov-01 22:03 
Findfile like that is only searching your current directory. (doth it search the PATH too? I can't remember.). But it isn't going to search your entire drive as you would want it to.

I use findfile in a self recursive function (it calls itself). Like this,


If you don't want the tree just chop those bits out.
This is a version that fills a tree with directories.

void CExIncView::FillDirTree()
{
char DRIVES[33];
DWORD DriveNumbers;
DWORD j;
int k,Image,ImageSelected;
CString lString;
HTREEITEM ParentList[33];
unsigned lDriveType;
m_Messages = " ";
UpdateData(FALSE);

//For each drive collect all directories
DriveNumbers = GetLogicalDrives();
j=1;
for(j=1,k=0;k<32;k++,j*=2)
{
if( DriveNumbers & j )
{
DRIVES[k] = 'A' + k;
}
else
{
DRIVES[k] = ' ';
}
}
//TEMP Put drives into tree
for(k=0;k<32;k++)
{
if( DRIVES[k] != ' ')
{
lString.Format("%c:",DRIVES[k]);
lDriveType = GetDriveType(lString);
switch(lDriveType)
{
case DRIVE_UNKNOWN ://The drive type cannot be determined.
Image = 2;
ImageSelected = 3;
break;
case DRIVE_NO_ROOT_DIR ://The root directory does not exist.
Image = 2;
ImageSelected = 3;
break;
case DRIVE_REMOVABLE ://The disk can be removed from the drive.
Image = 0;
ImageSelected = 1;
break;
case DRIVE_FIXED ://The disk cannot be removed from the drive.
Image = 2;
ImageSelected = 3;
break;
case DRIVE_REMOTE ://The drive is a remote (network) drive.
Image = 2;
ImageSelected = 3;
break;
case DRIVE_CDROM ://The drive is a CD-ROM drive.
Image = 4;
ImageSelected = 5;
break;
case DRIVE_RAMDISK ://The drive is a RAM disk.
Image = 2;
ImageSelected = 3;
break;
default:
Image = 2;
ImageSelected = 3;
break;
}
//ParentList[k] = m_pDirTree.InsertItem(lString,TVI_ROOT,TVI_SORT);
ParentList[k] = m_pDirTree.InsertItem(lString,Image,ImageSelected,TVI_ROOT,TVI_LAST);
m_pDirTree.SetItemData( ParentList[k], (DWORD) 50 );
}
else
{
ParentList[k] = NULL;
}
}
//For each parent traverse directory tree
for(k=0;k<32;k++)
{
if(ParentList[k] != NULL)
{
lString.Format("%c:",DRIVES[k]);
SearchDir(lString,ParentList[k]);
}
}

}

SearchDir is the self recursive function.

void CExIncView::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
{
sBase2.Format("%s\\%s",sBase,lpFindFileData.cFileName);
SearchDir(sBase2);
}
}
else
{
sTemp = lpFindFileData.cFileName;
if( sTemp.Find(m_FindThis ) != -1 )
{
if( m_iFind == 0 )
m_DatabaseLocation = sBase;
else
m_SourceFileDir = sBase;
}
}
}
while(FindNextFile(SearchHandle,&lpFindFileData));
Done = 1;
}

}

This FindFile can now be used to search for particular files (in this case on CSmile | :)

bool CExIncView::FindFile(CString &FName)
{
CString lString;
m_FindThis = FName;
lString.Format("C:");
SearchDir(lString);
return TRUE;
}

We do it for the joy of seeing the users struggle.
GeneralOwndraw scrollbars question Pin
Osykin Roman20-Nov-01 20:40
Osykin Roman20-Nov-01 20:40 
GeneralRe: Owndraw scrollbars question Pin
moliate21-Nov-01 5:42
moliate21-Nov-01 5:42 
GeneralRe: Owndraw scrollbars question Pin
Osykin Roman21-Nov-01 11:39
Osykin Roman21-Nov-01 11:39 
GeneralClock display Pin
smeckenfill20-Nov-01 19:34
smeckenfill20-Nov-01 19:34 
GeneralRe: Clock display Pin
Member 2362220-Nov-01 19:53
Member 2362220-Nov-01 19:53 
GeneralRe: Clock display Pin
kakuni27-Nov-01 9:11
kakuni27-Nov-01 9:11 
GeneralRe: Clock display Pin
Andrew Peace21-Nov-01 14:44
Andrew Peace21-Nov-01 14:44 
GeneralRe: Clock display Pin
kakuni27-Nov-01 9:14
kakuni27-Nov-01 9:14 
GeneralCEdit - A Simple Question Pin
Xavier Shay20-Nov-01 19:20
Xavier Shay20-Nov-01 19:20 
GeneralRe: CEdit - A Simple Question Pin
Fredrik Skog3-Dec-01 22:31
Fredrik Skog3-Dec-01 22:31 
Generaldifferent outlook on different pc. Pin
zecodela20-Nov-01 16:41
zecodela20-Nov-01 16:41 
GeneralRe: different outlook on different pc. Pin
Alvaro Mendez20-Nov-01 17:59
Alvaro Mendez20-Nov-01 17:59 
GeneralCode bloat! Pin
Todd Smith20-Nov-01 14:12
Todd Smith20-Nov-01 14:12 
Generalcreating a new doc, the sequel Pin
robbied20-Nov-01 12:51
robbied20-Nov-01 12:51 
GeneralRe: creating a new doc, the sequel Pin
Christian Graus20-Nov-01 13:07
protectorChristian Graus20-Nov-01 13:07 
GeneralRe: creating a new doc, the sequel Pin
robbied20-Nov-01 15:15
robbied20-Nov-01 15:15 
GeneralRe: creating a new doc, the sequel Pin
Christian Graus20-Nov-01 15:24
protectorChristian Graus20-Nov-01 15:24 

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.