Solved

Common dialog controls using ATL

Posted on 2002-04-12
3
270 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
[X]
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
  • 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

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Suggested Courses

617 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