
Signature
Scott McPhillips [VC++ MVP]
> It's only hard if you have no idea what you are doing. If you are using
> MFC then the DialogBox API call is not applicable.
I never said I knew what I was doing. I have only been using MFC for a
couple months, after 32 years programming other environments. No need
to be insulting though...
Why is DialogBox not applicable for MFC? Is that another of the
'managed memory model' (or whatever it is called) routines? If so, how
the heck can I tell the difference when reading MSDN. I have led down
that path a couple times now, and it is frustrating, to say the least.
> In Visual C++ the IDE 'class wizard' writes the new class derived from
> CDialog for you. Right click on your dialog template and select Class
[quoted text clipped - 5 lines]
> DoModal returns IDOK or IDCANCEL. Detecting your unique button requires
> you to do something, like set a bool when it is clicked.
Yeah, I know how to go through that hoop. Just seems silly to have to
add a whole new class just to get something simple like this. In other
environments I have programmed in, it was a simple one-line call with
the addition of a resource to define the appearance (which I have
created).

Signature
- Burt Johnson
MindStorm, Inc.
http://www.mindstorm-inc.com/software.html
William DePalo [MVP VC++] - 28 Jun 2005 05:39 GMT
>> It's only hard if you have no idea what you are doing. If you are using
>> MFC then the DialogBox API call is not applicable.
[quoted text clipped - 4 lines]
>
> Why is DialogBox not applicable for MFC?
DialogBox() is a function in the Win32 API. MFC provides a CDialog class to
simplify things and hide some of the details.
> Is that another of the 'managed memory model' (or whatever
> it is called) routines? If so, how the heck can I tell the
> difference when reading MSDN.
No, it is not. MFC is a class library used by and large to build native
applications.
> I have led down that path a couple times now, and it is frustrating,
> to say the least.
Well, it is at worst an embarassment of choices. There is the native API,
MFC, ATL, WTL, .Net Framework, etc
> Yeah, I know how to go through that hoop. Just seems silly to have to
> add a whole new class just to get something simple like this.
I guess that depends on one's perspective and expectations.
> In other environments I have programmed in, it was a simple one-line call
> with
> the addition of a resource to define the appearance (which I have
> created).
Well, there is the MessageBox() function which can put up a dialog in one
line but you'll have to settle for predefined sets of buttons such as ok, or
yes and no or yes and no and cancel etc
Back to your problem ... One thing you can do is to pass the ID of the
button used to close the dialog to the EndDialog() call that dismisses the
dialog. EndDialog() sees to it that that value is returned by the call to
DialogBox(). Since control IDs are small positive numbers, if you get 0 or a
negative result then the call failed. In that case call GetlastError() to
determine the reason why the call failed. If you don't understand the code -
they are defined in <winerror.h> - you can post it here.
Regards,
Will