Hi,

I am using visual C++ 2005 express edition. I created a window form application with several combobox. The combobox contain few default items (pictures for example). Now I wish to create a file browser which allow user to choose picture from others directory and added it into the combobox. How can I do this?

I look through the combobox properties for long but still unable to find such function. Besides, I also seached through many forums for file browser function but still not getting any respond.

Can any pro fren provide me some guide?? I need this urgently, Thanks in advance.

Regards,

Adrian

I know that compiler does not support MFC but you might browse www.codeproject.com because they probably have an mfc combo box class that does something like that and will give you ideas how to do it with win32 api functions.

Are you using Win32 API, MFC, WTL or Managed C++.

Hi,

I am using Win32 API, I created a few combobox using the toolbox and now I wish to add in a file browser function. It is something like the "attach file function" in this forum, we can browse the file in our PC and added it to the combobox.

How am I able to do this? Here I attached my code in the link (http://developer.sonyericsson.com/thread/44297) if my explanation is not clear.

Thanks.

Hmmm, Lets do it .
Your Combo must be Owner Drawn.

1. Handle the DrawItem Event of the ComboBox.
2. HICON hIcon = LoadImage (...); // this API will Load the icon(s).
3. Keep the icons in any collection. to fill the ComboBox.
4.In the DrawItem Event
DrawIconEx(...); use this API function... to draw the icon on ith item.

Follow the above steps. I prefer using ATL/WTL classes for the above TASK :). well you can do the same using WIN32 API.

Hi,

Thanks for your reply. In fact my combo is created from the toolbox. I am using VS C++ 2005 express edition, the window application provides GUI function, so I juz select the combobox and drag it out.

Besides, my combobox items are juz simple strings. This GUI that I am creating is juz a simple interface, I linked it up with other program.

So, I juz wan to make a simple file browser function to add the "name(string)" of file selected into the combobox.

Any help? For clearer explanation will be on the attached link. Thanks

Hi,

Thanks for your reply, I read through the function, i think visual C++2005 express edition provide a similar tool called FolderBrowserDialog.

I am quite new in C++ programming. I created a button beside my combobox and I link it to a new window form (or dialog) juz with the folderbrowserdialog. After that , I have no idea how to make the folderbrowserdialog works and how to link the string(name of file) it get back to the combobox.

Can you show me a simple example on that?

Million thanks in advance.

Regards,

Adrian

It is simple to use ...

// Invoke the dialog box...
folderBrowserDialog1->ShowDialog();
// User just closed the dialog ... display whatever was selected ...
System::Windows::Forms::MessageBox::Show(folderBrowserDialog1->SelectedPath);

However, note that it browses for folders (not files)

This article has been dead for over six months. Start a new discussion instead.