Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How to Show the specified folder in the Open Dialog Box

Posted on 2003-03-06
4
Medium Priority
?
261 Views
Last Modified: 2008-02-01
Hi
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();      
     }
     if(!m_strBmpFile.IsEmpty())
     {
          m_pBmp = new CBitmap();      
HBITMAP hBitmap = (HBITMAP)LoadImage(AfxGetApp()->
   m_hInstance,m_strBmpFile,IMAGE_BITMAP,0,0,LR_DEFAULTSIZE|LR_LOADFROMFILE);
          if(hBitmap)
               m_pBmp->Attach(hBitmap);
                      m_ctrlBmp.SetBitmap(m_pBmp);
               m_ctrlBmp.ShowWindow (SW_SHOW);
                   
               }
     
     m_ctrlBmp.Invalidate();

}
waiting for comments.
thanks
borntough
0
Comment
Question by:borntough
3 Comments
 
LVL 6

Expert Comment

by:PlanetCpp
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.


0
 
LVL 12

Accepted Solution

by:
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.

Alf
0
 
LVL 11

Expert Comment

by:bcladd
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).

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

-bcl (bcladd)
EE Cleanup Volunteer
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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…
Suggested Courses

581 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