Monday, May 30, 2005

Selecting multiple files using an open file dialog

Its a pain to program using the MFC (Microsoft Foundation classes). Even people at microsoft use the Win32 API. MFC is a wrapper for Win32 API, and it is meant to be easy to use. I haven't really had the chance to look at the Win32 API.

My task was to implement a multiple select open file dialog. I found this forum post on the net, this is the simplest way i have found so far. Other implementations involve extending the CDocManager class which can get quite complicated, especially if you are not familiar with MFC.

Earlier, I was unable to properly construct a multiple file open dialog. My file open dialog would only open a limited number of files (usually 5-6). I soon realized that it was limited by the size of CString. Including a TCHAR, which is simply a pointer to a string, much like char* solves the problem. However, the only difference is that, if you compile a TCHAR using a uni-code compiler (compiler options set to uni-code), you end up with a wchar_t (used for i18n). MSDN's documentation on TCHAR is here.

No comments: