How to Show the specified folder in the Open Dialog Box

Posted on 2003-03-06
Medium Priority
Last Modified: 2008-02-01
I am working in an SDI(formview) application.I had displayed the bitmaps on the screen through Open Dialog Box.Now the problem is that whenever i want to choose the bitmaps,i have to follow the number of paths to reach that specified folder in order to click on the actual bitmaps.Is it possible that whenever i click on the Open Dialog Box option,only the required folder open and all other paths vanish.The user should not be able to select any other bitmaps on the hard disk except the required one.

This is the work i have done.plz give me suggestions that what changes should i do in this....

public:CMyPicture m_ctrlBmp;
      CString m_strBmpFile;
      CString m_sBitmap;

void CPPCView::OnOpenbitmap()
static char BASED_CODE szFilter[]="Bitmap Files (*.bmp)|*.bmp||";
     CFileDialog filedlg(TRUE,".bmp",m_sBitmap,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,szFilter);
     if(filedlg.DoModal() == IDOK)
          m_ctrlBmp.MoveWindow (-10,-10,790,610,true);
          m_strBmpFile = filedlg.GetPathName();      
          m_pBmp = new CBitmap();      
HBITMAP hBitmap = (HBITMAP)LoadImage(AfxGetApp()->
               m_ctrlBmp.ShowWindow (SW_SHOW);

waiting for comments.
Question by:borntough
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 8086532
i don't use MFC but i've used the open file common dialog via win32 api and i think i can help
inside the CFileDialog is a data member called m_ofn, this is of type OPENFILENAME
you can set some of these attributes before you get the path name
im assuming here that some of this already is initialized by the CFileDialog object, things such as lStructSize and others that you included in the constructor
lpstrTitle is one you can change, you set it to the title you want to appear on the dialog window
lpstrInitialDir is the one you're looking for, it sets the initial directory to choose from.

LVL 12

Accepted Solution

Salte earned 200 total points
ID: 8087686
You can specify the directory that the open dialog starts in. You can also specify that it should only permit files in that directory and not any other.

I believe that is what you want. Just check out the methods for the open dialog, I am sure that one of the flags can be used to disallow changing directory.

Of course, for this to work you must set the directory to the correct one. The dialog box will by default use the process' current directory when opening the dialog box. If you want a different directory you must set the file path. You can also specify a default filename if you want.

There's a zillion various things you can set in that box, including show or not show hidden files, disallow opening of read-only files only allow filenames that already exist etc etc.

LVL 11

Expert Comment

ID: 9889692
No comment has been added lately, so it's time to clean up this TA. I will
leave a recommendation in the Cleanup topic area that this question is:

Answered: Points to Salte: Grade B

Please leave any comments here within the next seven days.

Experts: Silence means you don't care. Grading recommendations are made in light
of the posted grading guidlines (http://www.experts-exchange.com/help.jsp#hi73).


-bcl (bcladd)
EE Cleanup Volunteer

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question