Solved

Open File Name mask

Posted on 2007-04-03
6
752 Views
Last Modified: 2012-05-05
Hi Experts. I have a Dir with filesnames like 123.fgm ; 124.fgm; 125;fgm and a Mask file containing the names of the xxx.fgm files. I know how to extract the names out of the Mask file. But now I want these extracted names to be visible in the OpenFileName dialog so a user can select the wanted file.
How do I make these filenames visible using the GetOpenFileName(ofn) dialog ?
Thanks again
0
Comment
Question by:Frits2
  • 2
  • 2
6 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 18846866
Are you thnking about

    BYTE            Filter  [ 100] = "FGM files (*.fgm)\0*.fgm\0\0";    
    char            acBuf   [ MAX_PATH];
    OPENFILENAME    ofName;

    ZeroMemory  (   &ofName,    sizeof( OPENFILENAME));
    ZeroMemory  (   acBuf,  MAX_PATH);
   
    ofName.hwndOwner        =   NULL;
    ofName.lStructSize      =   sizeof( OPENFILENAME);
    ofName.lpstrFile        =   acBuf;
    ofName.nMaxFile         =   MAX_PATH;
    ofName.lpstrInitialDir  =   NULL;
    ofName.Flags            =   OFN_HIDEREADONLY | OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_LONGNAMES;
    ofName.lpstrDefExt      =   "fgm";
    ofName.lpstrFilter      =   ( char *) Filter;
    ofName.nFilterIndex     =   1;
    ofName.lpstrTitle       =   "Choose FGM file";

?
0
 

Author Comment

by:Frits2
ID: 18847014
Hi jkr,

thanks for your fast reply!
Yes this code generates a standard OpenFileDialog with the 123.fgm; 124.fgm ..files visible.
Now the xxx.fgm filenames must be made visible in this dialogbox with there real names.
I don't know how to go from here:
Do I have to use a OFN_ENABLEHOOK procedure to add this hook to made the real names visible in the dialogbox and how do I do this. or is there a easier way to change the xxx.fgm names to their names which are hidden in the mask file.

Best regards
Frits
0
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 18848317
Hmm, it seems that I now understand what you want to do, and that is IMO not possible with the standard "File Open" dialog, youd rather have to write a replacement for that, which is not too hard. http://msdn2.microsoft.com/en-us/library/aa365200.aspx ("Listing the Files in a Directory") will give you the basics on how to get the file listing and http://www.codeproject.com/listctrl/ ("List Controls") should cover the rest.
0
 

Author Comment

by:Frits2
ID: 18849143
Hi jkr
Actaully I hoped to do the trick with a hook procedure in the GetOpenFileName(ofn) and could see an example of this hook procedure OFN_ENABLEHOOK.
Can't find anything leading to a solution within my capacities in these url's.

thanks agian and best regards
Frits
0
 
LVL 1

Expert Comment

by:Computer101
ID: 21156538
Forced accept.

Computer101
EE Admin
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
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 difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now