Click here to Skip to main content
15,902,492 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Trying to capture video using Visual C++ (MFC) Please help Pin
Andrew Walker9-Nov-03 9:37
Andrew Walker9-Nov-03 9:37 
GeneralHelp Making a Slope Function in C Pin
Anonymous8-Nov-03 14:07
Anonymous8-Nov-03 14:07 
GeneralI need help about how to use OpenSSL library. Pin
Artem Moroz8-Nov-03 11:39
Artem Moroz8-Nov-03 11:39 
GeneralRe: I need help about how to use OpenSSL library. Pin
Johnny ²9-Nov-03 3:37
Johnny ²9-Nov-03 3:37 
GeneralRe: I need help about how to use OpenSSL library. Pin
cperdana28-Mar-10 20:00
cperdana28-Mar-10 20:00 
GeneralLonghorn programming and WinFX Pin
Snyp8-Nov-03 10:03
Snyp8-Nov-03 10:03 
GeneralI want to open NEXT or PREV file. with button control Pin
gaesabal8-Nov-03 8:58
gaesabal8-Nov-03 8:58 
GeneralRe: I want to open NEXT or PREV file. with button control Pin
Antti Keskinen8-Nov-03 10:44
Antti Keskinen8-Nov-03 10:44 
Analysis of the posted code:

The 'GetStartPosition' and 'GetNextPathName' methods are used to run through a list of selected file names. To enable this kind of behaviour, your FileDialog must sport the 'OFN_ALLOWMULTISELECT' style. Now, when the dialog is shown, you must select multiple files by holding CTRL or SHIFT down when clicking names.

After the call to DoModal returns (you click Ok), the file list is ready, and can be browsed through by using the above mentioned methods. Remember to check the return values of GetStartPosition and GetNextPathName. First one returns NULL if there is no file list, and the latter returns NULL if the list has ended.

From your description, however, I understood that you wanted to create a quick file preview/browser application. For this purpose, you should approach the problem from a bit different perspective: create a list of existing files in a directory, and move through this list when the user is clicking the buttons.

The MFC class CFileFind is perfect for this purpose: first use it to enumerate the file names in the current directory, and save these to e.g. a list of CString objects (CString strList[MAX_NUMBER]). Now, at the start of the browsing, initialize the position integer (iPos) to zero, and open the file pointed to by strList[0]. When user clicks 'prev' or 'next', increase or decrease the iPos value and re-open the file. Remember to close the currently open file first, though, or you might end up with a HUGE memory leak of open file handles.

Here is a code fragment to get you started. It will enumerate through the current directory, accepting all files. These file names are written to a static CString list. This list must be a member of your application class, so it doesn't go out of scope after the enumeration returns.

void EnumerateFiles(void)
{
   int iPos = 0;
   CFileFind cfFinder;

   BOOL bContinue = cfFinder.FindFile("*.*");

   while (bContinue)
   {
       bContinue = cfFinder.FindNextFile();
       strList[iPos] = cfFinder.GetFileName();

       iPos++;
   }

   cfFinder.CloseSearch();

   // End call
   return;
}


-Antti Keskinen

----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
QuestionHow do I handle Single and Double Mouse Clicks? Pin
jasonmgeorge8-Nov-03 8:30
jasonmgeorge8-Nov-03 8:30 
AnswerRe: How do I handle Single and Double Mouse Clicks? Pin
Antti Keskinen8-Nov-03 9:58
Antti Keskinen8-Nov-03 9:58 
GeneralRe: How do I handle Single and Double Mouse Clicks? Pin
jasonmgeorge8-Nov-03 10:33
jasonmgeorge8-Nov-03 10:33 
GeneralRe: How do I handle Single and Double Mouse Clicks? Pin
Antti Keskinen8-Nov-03 11:06
Antti Keskinen8-Nov-03 11:06 
AnswerRe: How do I handle Single and Double Mouse Clicks? Pin
Michael Dunn8-Nov-03 14:30
sitebuilderMichael Dunn8-Nov-03 14:30 
GeneralBITMAPV4HEADER & BITMAPV5HEADER Pin
John R. Shaw8-Nov-03 7:34
John R. Shaw8-Nov-03 7:34 
GeneralRe: BITMAPV4HEADER & BITMAPV5HEADER Pin
J. Dunlap8-Nov-03 13:22
J. Dunlap8-Nov-03 13:22 
GeneralWindows Address Book Pin
PJ Arends8-Nov-03 7:17
professionalPJ Arends8-Nov-03 7:17 
GeneralRe: Windows Address Book Pin
cmk8-Nov-03 9:45
cmk8-Nov-03 9:45 
GeneralRe: Windows Address Book Pin
PJ Arends9-Nov-03 6:58
professionalPJ Arends9-Nov-03 6:58 
GeneralRe: Windows Address Book Pin
Peter Molnar8-Nov-03 9:45
Peter Molnar8-Nov-03 9:45 
GeneralRe: Windows Address Book Pin
PJ Arends9-Nov-03 6:59
professionalPJ Arends9-Nov-03 6:59 
Questionhow to find the number of same items in two STL vectors Pin
hesham_16820018-Nov-03 6:47
hesham_16820018-Nov-03 6:47 
AnswerRe: how to find the number of same items in two STL vectors Pin
ZoogieZork8-Nov-03 8:03
ZoogieZork8-Nov-03 8:03 
GeneralSend Sms using visaul c++ 6 Pin
nolanl8-Nov-03 3:04
nolanl8-Nov-03 3:04 
GeneralRe: Send Sms using visaul c++ 6 Pin
Peter Molnar8-Nov-03 5:28
Peter Molnar8-Nov-03 5:28 
GeneralRe: Send Sms using visaul c++ 6 Pin
nolanl9-Nov-03 23:31
nolanl9-Nov-03 23:31 

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.