I am writing a program in C++ and I want to add a GUI. This program
will be more of an application and the GUI will probably get fairly
complex.

I am using Microsoft Visual C++, version 6.0 (very old).

I would just as soon do it visually in the resource editor. I build a
dialogue window and MSVC++ creates a .rct file.

But now how do I call/instantiate this from my program?

The basic call appears to be

DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL,
DialogueProcess)

where IDD_DIALOG1 is the name I gave it in the resource builder
(original, huh?). When I try to compile though, IDD_DIALOG1 is
undefined.

Do I need to make a header file or .rc file by hand or something? Do
I reference the dialogue in a different way? Is it a setting in the
IDE somewhere? Am I going about this in altogether the wrong way?

***

<a little off topic>

Just for the sake of my pride if nothing else ... I'm not really a
beginner, I've programmed in C, C++ and Java for years and written
dozens of GUI applications in Java Swing. I googled for basic
tutorials on Windows GUI programming and found a pretty good one
(http://www.winprog.org/tutorial/) but the author dealt with this part
by hand-editing a .rc and resources.h file himself ... there aren't
really any docs on how he did this though.


--
Joe Cosby
http://joecosby.com/
Magister Mundi sum!

:: Currently listening to Cello Concerto No.1 in C Major Moderato, 1768, by Haydn, from "Cello Concertos"

Re: Beginner GUI question by David

David
Fri Dec 07 19:34:48 PST 2007

Zapanaz wrote:
>
> I am writing a program in C++ and I want to add a GUI. This program
> will be more of an application and the GUI will probably get fairly
> complex.
>
> I am using Microsoft Visual C++, version 6.0 (very old).
>
> I would just as soon do it visually in the resource editor. I build a
> dialogue window and MSVC++ creates a .rct file.
>
> But now how do I call/instantiate this from my program?
>
> The basic call appears to be
>
> DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL,
> DialogueProcess)
>
> where IDD_DIALOG1 is the name I gave it in the resource builder
> (original, huh?). When I try to compile though, IDD_DIALOG1 is
> undefined.
>
> Do I need to make a header file or .rc file by hand or something? Do
> I reference the dialogue in a different way? Is it a setting in the
> IDE somewhere? Am I going about this in altogether the wrong way?
>
> ***
>
> <a little off topic>
>
> Just for the sake of my pride if nothing else ... I'm not really a
> beginner, I've programmed in C, C++ and Java for years and written
> dozens of GUI applications in Java Swing. I googled for basic
> tutorials on Windows GUI programming and found a pretty good one
> (http://www.winprog.org/tutorial/) but the author dealt with this part
> by hand-editing a .rc and resources.h file himself ... there aren't
> really any docs on how he did this though.

Zapanaz:

The easiest way to write a GUI application in native (unmanaged) C++ is
to use MFC. You do not normally need to hand-edit the resource (.rc)
file. If you create an MFC application using the Wizard, you will have a
"working" application right out of the box.

If you have a later version of the compiler you can create .NET
(managed) applications using C# or C++/CLI or Visual Basic.

--
David Wilkinson
Visual C++ MVP

Re: Beginner GUI question by Igor

Igor
Fri Dec 07 19:47:30 PST 2007

"Zapanaz" <http://joecosby.com/code/mail.pl> wrote in message
news:hLydnT07P8mma8TanZ2dnUVZ_sejnZ2d@zhonka.net
> DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL,
> DialogueProcess)
>
> where IDD_DIALOG1 is the name I gave it in the resource builder
> (original, huh?). When I try to compile though, IDD_DIALOG1 is
> undefined.

#include "resource.h"

> Do I need to make a header file or .rc file by hand or something?

Resource editor maintains both for you.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925



Re: Beginner GUI question by Giovanni

Giovanni
Sat Dec 08 01:08:02 PST 2007


"David Wilkinson" <no-reply@effisols.com> ha scritto nel messaggio
news:ui8iJtUOIHA.5988@TK2MSFTNGP02.phx.gbl...

> The easiest way to write a GUI application in native (unmanaged) C++ is to
> use MFC.

I agree with David.

Another option would be WTL, but IMHO it is harder than MFC (WTL requires
that you master C++ templates, the Visual C++ IDE offers less support for
WTL than what is offered for MFC, and, moreover, it seems that there is lots
of MFC code available for free - e.g. on CodeProject - or commercial - e.g.
CodeJock).

If the OP would like to use managed programming languages, I would suggest
C# and WPF for GUI.

Giovanni



Re: Beginner GUI question by Tom

Tom
Sat Dec 08 14:13:32 PST 2007

Another problem with WTL is that subsequent releases don't support it at all
so I'd stay away from it if you have MFC available. I highly recommend
upgrading from Version 6.0 if you are just getting started.

Tom

"Giovanni Dicanio" <giovanni.dicanio@invalid.it> wrote in message
news:%23mU2wnXOIHA.1188@TK2MSFTNGP04.phx.gbl...
>
> "David Wilkinson" <no-reply@effisols.com> ha scritto nel messaggio
> news:ui8iJtUOIHA.5988@TK2MSFTNGP02.phx.gbl...
>
>> The easiest way to write a GUI application in native (unmanaged) C++ is
>> to use MFC.
>
> I agree with David.
>
> Another option would be WTL, but IMHO it is harder than MFC (WTL requires
> that you master C++ templates, the Visual C++ IDE offers less support for
> WTL than what is offered for MFC, and, moreover, it seems that there is
> lots of MFC code available for free - e.g. on CodeProject - or
> commercial - e.g. CodeJock).
>
> If the OP would like to use managed programming languages, I would suggest
> C# and WPF for GUI.
>
> Giovanni
>
>


Re: Beginner GUI question by Zapanaz

Zapanaz
Sun Dec 09 13:31:54 PST 2007


On Fri, 7 Dec 2007 22:47:30 -0500, "Igor Tandetnik"
<itandetnik@mvps.org> wrote:

>"Zapanaz" <http://joecosby.com/code/mail.pl> wrote in message
>news:hLydnT07P8mma8TanZ2dnUVZ_sejnZ2d@zhonka.net
>> DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL,
>> DialogueProcess)
>>
>> where IDD_DIALOG1 is the name I gave it in the resource builder
>> (original, huh?). When I try to compile though, IDD_DIALOG1 is
>> undefined.
>
>#include "resource.h"
>

lol

Thanks, it's kind of funny when it turns out to be something so
simple.

>> Do I need to make a header file or .rc file by hand or something?
>
>Resource editor maintains both for you.

--
Joe Cosby
http://joecosby.com/
"I will be warned of the dangers of time travel!",
remembered Tilly, of the warning she was given in the
future, of the perils of the past, which she presently
thought had been both historic and foresighted, "though
knowing now what I will know then makes it somewhat
anachronistic".

:: Currently listening to Better Git It In Your Soul, 1959, by Charles Mingus, from "Mingus Ah Um"

Re: Beginner GUI question by Francis

Francis
Sun Dec 09 17:12:58 PST 2007

On 8 dec, 02:41, Zapanaz <http://joecosby.com/code/mail.pl> wrote:
> I am writing a program in C++ and I want to add a GUI. This program
> will be more of an application and the GUI will probably get fairly
> complex.
>
> I am using Microsoft Visual C++, version 6.0 (very old).
>
> I would just as soon do it visually in the resource editor. I build a
> dialogue window and MSVC++ creates a .rct file.
>
> But now how do I call/instantiate this from my program?
>
> The basic call appears to be
>
> DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL,
> DialogueProcess)
>
> where IDD_DIALOG1 is the name I gave it in the resource builder
> (original, huh?). When I try to compile though, IDD_DIALOG1 is
> undefined.
>
> Do I need to make a header file or .rc file by hand or something? Do
> I reference the dialogue in a different way? Is it a setting in the
> IDE somewhere? Am I going about this in altogether the wrong way?
>
> ***
>
> <a little off topic>
>
> Just for the sake of my pride if nothing else ... I'm not really a
> beginner, I've programmed in C, C++ and Java for years and written
> dozens of GUI applications in Java Swing. I googled for basic
> tutorials on Windows GUI programming and found a pretty good one
> (http://www.winprog.org/tutorial/) but the author dealt with this part
> by hand-editing a .rc and resources.h file himself ... there aren't
> really any docs on how he did this though.
>
> --
> Joe Cosbyhttp://joecosby.com/
> Magister Mundi sum!
>
> :: Currently listening to Cello Concerto No.1 in C Major Moderato, 1768, by Haydn, from "Cello Concertos"

Hey it's funny because I have been starting to use Win32 API since
September, having been a professional C++ programmer 2 years before
that. I have used the same tutorial! It's a good one indeed. I used
Visual C++ Express Edition and hand edited the rc file. I tried to put
as few as possible in the rc file and create windows and components at
runtime as much as possible. This is just out of personal preference
because I don't really like the resource editor, and also because I
was more used to designing GUIs programmatically using layout
managers.

So if you want I could help you out a bit with developing GUI's pro
grammatically in Win32, but not really with the resource editor.

Grtz,
Francis

Re: Beginner GUI question by Zapanaz

Zapanaz
Sun Dec 09 17:46:41 PST 2007


On Fri, 07 Dec 2007 22:34:48 -0500, David Wilkinson
<no-reply@effisols.com> wrote:

>Zapanaz:
>
>The easiest way to write a GUI application in native (unmanaged) C++ is
>to use MFC. You do not normally need to hand-edit the resource (.rc)
>file. If you create an MFC application using the Wizard, you will have a
>"working" application right out of the box.
>
>If you have a later version of the compiler you can create .NET
>(managed) applications using C# or C++/CLI or Visual Basic.

Thanks

That led to a different problem, I tried this tutorial on MFC

http://www.codersource.net/samples/mfc_tutorial_5.zip

To make a long story short ... I edited a dialog box resource, saved
it, then went through the class wizard to create a new class.
Basically step by step through that web page. It generated
NewDialog.cpp and NewDialog.h, but didn't generate stdafx.h or
script3.h . (The resource is named script3).

I googled on this, stdafx.h is apparently supposed to be generated by
the class wizard, I wasn't able to find anybody else with the same
problem, do you know what might be causing this (a project setting
maybe?) or an alternate way to generate them?

I could probably use a generic stdafx.h like this

http://tinyurl.com/yvpl7o

from reading about it, it looks like it is usually pretty standard,
but script3.h should have some necessary things in it, I don't know
what.

Thanks for any help, sorry for the newbie type questions ...

--
Joe Cosby
http://joecosby.com/
`He shuddered, awash in adrenaline, his sphincter pulling unpleasantly tight as he recognized his own youthful scrawl on the outside tab. ... and he felt an ache, a curse of time racing across the ridge of his knuckles.' -- Derek Van Arman, Just Killing Time

:: Currently listening to Op. 74 in E flat: I. Poco Adagio - Allegro, 1809, by Beethoven, from "Beethoven: Quartets - 2"

Re: Beginner GUI question by Zapanaz

Zapanaz
Sun Dec 09 17:53:26 PST 2007


On Sun, 9 Dec 2007 17:12:58 -0800 (PST), Francis
<francis.rammeloo@gmail.com> wrote:

>Hey it's funny because I have been starting to use Win32 API since
>September, having been a professional C++ programmer 2 years before
>that. I have used the same tutorial! It's a good one indeed. I used
>Visual C++ Express Edition and hand edited the rc file. I tried to put
>as few as possible in the rc file and create windows and components at
>runtime as much as possible. This is just out of personal preference
>because I don't really like the resource editor, and also because I
>was more used to designing GUIs programmatically using layout
>managers.
>
>So if you want I could help you out a bit with developing GUI's pro
>grammatically in Win32, but not really with the resource editor.
>
>Grtz,
>Francis

I might take you up on that actually ... most of my GUI applications
in the past were in Java, and I am more used to creating a GUI
programmatically.

Are you familiar with Java? The thing that stopped me from taking
this approach is that I haven't really been able to find a resource,
online anyway, like the Sun Javadocs. With Java it was pretty easy to
look up the Swing GUI class, their arguments and uses, everything was
all pretty well-documented.

Windows has MSDN but it just isn't laid out the same way; i.e., here
are your classes:

JTable
JTabbedPane

etc., click on one to see how it works.

I think getting a comprehensive book might do it but at least online I
couldn't find a nice class/API encyclopedia.


Really in general I don't like having anything in a project which I
can't save in CVS, I prefer programmatic GUIs too ...

--
Joe Cosby
http://joecosby.com/
`He shuddered, awash in adrenaline, his sphincter pulling unpleasantly tight as he recognized his own youthful scrawl on the outside tab. ... and he felt an ache, a curse of time racing across the ridge of his knuckles.' -- Derek Van Arman, Just Killing Time

:: Currently listening to Op. 74 in E flat: II. Adagio ma non troppo, 1809, by Beethoven, from "Beethoven: Quartets - 2"

Re: Beginner GUI question by Francis

Francis
Mon Dec 10 00:36:00 PST 2007

> I might take you up on that actually ... most of my GUI applications
> in the past were in Java, and I am more used to creating a GUI
> programmatically.

Yeah I got that, I didn't use Java, but I too developed GUI's
programmatically using a object oriented library that the company had
developed on top of Win32 and Carbon (for MacOSX).


> I think getting a comprehensive book might do it but at least online I
> couldn't find a nice class/API encyclopedia.

A good starting point is the Windows reference:
http://msdn2.microsoft.com/en-us/library/ms674883.aspx . The function
that you will need most (if you make your components programmatically)
is CreateWindowEx: http://msdn2.microsoft.com/en-us/library/ms632680.aspx
.
A good newsgroup for pure Win32 development is comp.os.ms-
windows.programmer.win32 .

The most tricky for me was to find out how to make GUI components as C+
+ classes with their own proc function. But once you have that you can
program in a way that is (more or less) similar to the Java way.

However, considering the time I spent setting up such a system, it may
be more economic to just use MFC... (My colleagues must have thought
that I was crazy to set up something like this.)

Another option is WxWidgets, which is a mature open-source OO library
that allows you to build GUIs programmatically in a way that is very
similar to Swing.

I didn't choose that option however because I really wanted to learn
Win32, since thought that this knowledge would be very valuable.

> Really in general I don't like having anything in a project which I
> can't save in CVS, I prefer programmatic GUIs too ...
>

You can save your resource files in CVS. Resource files are plain
text, so diffing and tracking your changes is no more difficult than
any other type of source code.


Grtz,
Francis