Solved

Common dialog controls using ATL

Posted on 2002-04-12
3
265 Views
Last Modified: 2013-11-20
hi i have to use common dialog control using atl.
i used my code as below,
i got error as interface ICommonDialog not found.
is there any better way,
thanks in advance
What is the header file i have to use

#import "c:\winnt\system32\comdlg32.ocx"

CComPtr<ICommonDialog> sp_CmnDlg;

CoCreateInstance(__uuidof(CCommonDialog), ..., ...

sp_CmnDlg->ShowOpen();

ravi.
0
Comment
Question by:ravikirang
  • 2
3 Comments
 
LVL 23

Accepted Solution

by:
Roshan Davis earned 100 total points
ID: 6936371
If u need an Open File Common Dialog, u can do this

          OPENFILENAME ofn;
            TCHAR  szFile[5000] = "\0";
          strcpy(szFile, "");

          memset(&ofn, 0, sizeof (ofn));
          ofn.lpstrFile          = szFile;
          ofn.lStructSize          = sizeof(OPENFILENAME);
          ofn.hwndOwner          = NULL;
          ofn.nMaxFile          = 5000;
          ofn.lpstrFilter          = "Text Files (*.txt)\0*.txt\0Document Files (*.doc)\0*.doc\0All Files (*.*)\0*.*\0\0";
          ofn.lpstrTitle          = "Open a File";
        ofn.Flags               = OFN_EXPLORER|OFN_PATHMUSTEXIST|OFN_ENABLEHOOK|OFN_ALLOWMULTISELECT|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
          ofn.lpstrDefExt         = "txt";
          //ofn.lpfnHook          = (LPOFNHOOKPROC)OFNHookProc1;
          ofn.lpfnHook          = NULL;

        if(GetOpenFileName(&ofn))
          {
               if(NULL != ofn.lpstrFile)
               {
                    // to do
               }
          }


GOOD LUCK
0
 

Author Comment

by:ravikirang
ID: 6936516
thanks mr ramson, it worked for me. could u tell me changes for save dialog box.
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 6936519
For that u can use GetSaveFileName API

GOOD LUCK
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

746 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

14 Experts available now in Live!

Get 1:1 Help Now