Solved

Common dialog controls using ATL

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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Best tools for Backup and restore of Wordpress site 6 57
lucky13 challenge 11 145
pre4 challenge 19 100
Updating statistics with error notification email in SQL server 4 95
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.
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

777 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