Solved

Common dialog controls using ATL

Posted on 2002-04-12
3
268 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

Independent Software Vendors: 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: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

756 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