// JP opened flex table

Click to See Complete Forum and Search --> : Using Dialog Box in VC++


deck42
July 6th, 2008, 07:22 AM
Hello,

I know this is a really dumb question for most, but I have been messing around for days now and I am getting desperate:

How the heck can I use some standard dialog class instead of fabricating my own?
I thought that I should be able to use the "CommonDialog" Classes like "OpenFileDialog" by including "commdlg.h". But It's just not defined in there, compiler still moans about not knowing any of the needed functions and I can't find it.
(btw: using VC++ 8.0 for standard Win32 App)

Help! Where to find that CommonDialog classes??

Igor Vartanov
July 6th, 2008, 03:46 PM
Help! Where to find that CommonDialog classes??
Definitely, the classes belong in MFC (http://msdn.microsoft.com/en-us/library/dk77e5e7(VS.71).aspx). Or ATL/WTL. Or any other C++ library :D

Man, what made you think commdlg.h can contain classes? PlatformSDK provides you with pure C programming interface to Windows. ;)

deck42
July 8th, 2008, 04:47 PM
Ok but what header or whatsoever do I have to include to be able to use that MFC Class?
I have searched all header files etc. and it's defined nowhere..

I thought it would be enough to include afxwin.h but its not..

Paul McKenzie
July 8th, 2008, 06:09 PM
I thought that I should be able to use the "CommonDialog" Classes
(btw: using VC++ 8.0 for standard Win32 App)The Windows API knows nothing about "classes". The only classes are the ones you happen to create in your program.

The API functions you're looking for are GetOpenFileName(), GetSaveFileName(), PrintDlg(), etc. When you write a Win32 App, any communication to the Windows API uses straight 'C' function calls, not classes.

Regards,

Paul McKenzie

Igor Vartanov
July 9th, 2008, 04:35 AM
Ok but what header or whatsoever do I have to include to be able to use that MFC Class?
I have searched all header files etc. and it's defined nowhere..

I thought it would be enough to include afxwin.h but its not..Okay, that was the test for your attention and thoroughness. And you failed. :)

The MFC (http://msdn.microsoft.com/en-us/library/dk77e5e7(VS.71).aspx) link I gave you actually points to CFileDialog (http://msdn.microsoft.com/en-us/library/dk77e5e7(VS.71).aspx) MFC class article, which gives you an unambiguous instruction:
Requirements

Header: afxdlgs.h

FYI, there is no such a class OpenFileDialog, so you've been searching in "all header files" in vain. ;)

Besides, I can see no reason to use any class (and therefore, make yourself to be bound to MFC) for merely opening an Open File dialog. Beacause GetOpenFileName (http://msdn.microsoft.com/en-us/library/ms646927(VS.85).aspx) and GetSaveFileName (http://msdn.microsoft.com/en-us/library/ms646928(VS.85).aspx) APIs look pretty simple and straightforward to me. :D

deck42
July 9th, 2008, 05:57 PM
Well thanks alot guys, quiet much the hint I needed. Although it still don't work for me, now the Dialogbox won't appear just without any comment.. gonna look into the returned error (hopefully if any) tomorrow..

thx!

(btw: I did look at your link and I already had looked at that page many times)

Igor Vartanov
July 10th, 2008, 04:42 AM
(btw: I did look at your link and I already had looked at that page many times)And?.. :)

Okay, take a look at the sample, hope that helps.

deck42
July 10th, 2008, 06:00 PM
Thanks alot for your example!
I zeroed the memory using "ZeroMemory(&ofn,sizeof(ofn))" and that helped, guess I forgot to set something to NULL.

Works now! Thanks to you!

//JP added flex table