Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Need help with SDI Open FIle Dialog.....PLEASE!

2 views
Skip to first unread message

Shadow

unread,
Jun 17, 2002, 3:25:05 AM6/17/02
to
To anyone who can help,

I am currently trying to write an app that uses an SDI framework created
with VC++6.0 AppWizard. Nothing fancy, just one view and a few dialogs. The
problem that I am running into has to do with the Open Dialog Box. I need
to have a control (lets say a button) that will do the same thing as
selecting File\Open on the menu bar. I just can't seem to find the correct
entry point, (i.e.. what is called when you select File\Open).

I have tried using the OnFileOpen() function in the CDocManager class, which
gets close to what I want, but it doesn't include my program's extension
filters, only (*.* all files). It seems that this should be an easy thing
to do, but for some reason I can't figure it out.

Any help in this matter would be greatly appreciated.

Thanks in advance,
RJB


Norman Bullen

unread,
Jun 17, 2002, 8:01:46 PM6/17/02
to

The File Open dialog box is one of so-called Common Dialogs. You can
open it by calling GetOpenFileName().

You need to #include <commdlg.h> and link with comdlg32.lib.

Norm

Scott McPhillips

unread,
Jun 17, 2002, 9:06:42 PM6/17/02
to

You should find this line in your app class message map:

ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)

That means CWinApp::OnFileOpen is called when File/Open is selected. It
is a protected function so you can't call it from your button. But you
can add your own public OnFileOpen function in your app class and change
the message map line to:

ON_COMMAND(ID_FILE_OPEN, OnFileOpen)

void CYourApp::OnFileOpen( )
{
CWinApp::OnFileOpen();
}

It should still work as before. But now your button handler can also
call your OnFileOpen:

void CYourView::OnButton()
{
CYourApp* pApp = (CYourApp*)AfxGetApp();
pApp->OnFileOpen();
}


--
Scott McPhillips [VC++ MVP]

Michael Daniloff

unread,
Jun 18, 2002, 12:38:17 AM6/18/02
to
"Shadow" <Sha...@inter.net> wrote in message news:<l9gP8.32080$yE.331...@newssvr11.news.prodigy.com>...

It's very easy if you use doc-view architecture.

Open String table in a resource view. Double-click IDR_MAINFRAME.
This string contains 7 substrings separated by newline character '\n'
For substring No 4 put something like: My Application files (*.XXX)
For substring No 5 put your extension: .XXX

Your File-Open dialog should work correctly now.

Regards,

Michael

Shadow

unread,
Jun 18, 2002, 3:01:09 AM6/18/02
to
> >
> > Any help in this matter would be greatly appreciated.
> >
> > Thanks in advance,
> > RJB
>
> The File Open dialog box is one of so-called Common Dialogs. You can
> open it by calling GetOpenFileName().
>
> You need to #include <commdlg.h> and link with comdlg32.lib.
>
> Norm

Norm,

Thanks for the input on my problem, but I used Mr. McPhillips solution.
It was more along the lines of how I think and program.

Thanks again for the effort.

Laters,
Robert


Shadow

unread,
Jun 18, 2002, 3:04:04 AM6/18/02
to
> >
> > Any help in this matter would be greatly appreciated.
> >
> > Thanks in advance,
> > RJB
>
> You should find this line in your app class message map:
>
> ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
>
> That means CWinApp::OnFileOpen is called when File/Open is selected. It
> is a protected function so you can't call it from your button. But you
> can add your own public OnFileOpen function in your app class and change
> the message map line to:
>
> ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
>
> void CYourApp::OnFileOpen( )
> {
> CWinApp::OnFileOpen();
> }
>
> It should still work as before. But now your button handler can also
> call your OnFileOpen:
>
> void CYourView::OnButton()
> {
> CYourApp* pApp = (CYourApp*)AfxGetApp();
> pApp->OnFileOpen();
> }
>
>
> --
> Scott McPhillips [VC++ MVP]

Scott,

Thank so much for your input. Your solution was a perfect fit for my
problem. You are definitely an MVP!.\

Thanx again,

Laters,
Robert


Shadow

unread,
Jun 18, 2002, 3:08:22 AM6/18/02
to

"Michael Daniloff" <mdan...@yahoo.com> wrote in message
news:f9947151.0206...@posting.google.com...


Michael,

Thanks for the reply to my problem, but Mr. McPhillips had the correct
solution for me. BTW I had already taken care of your suggestion in my
String Table before my first post. Thanks again for the reply.

Laters,
Robert

0 new messages