Thread: [Dev-C++] What have I done this time? A wxDevC++ adventure.
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Roger F. <ra...@ha...> - 2004-12-04 01:31:01
|
Aloha from Honolulu,
I started doing a tutorial I found on the wxWidgets site under
Documentation: A
comprehensive wxWidgets tutorial by David Beech. There isn't much to
it. I copied the
code and pressed Compile & Run...
The first time (I had pre-compiled headers) it came back with an
error message: could
not find /wx/msw/hand.cur. I got upset. I mean-I can find that file!
What's going on?
I remembered about not using copy and paste, because of unprintable
characters.
Aha! I erased the files in my tutorial/basic01 directory and typed them
in again by
hand.
As I'm typing away I start getting the "Code Completion" feature
horning in, but I can't
do anything with it. I looked it up in Help, but it has yet to be
implemented. So I bang
my head a few times and eventually get it disabled. Now can get the
typing done. I
save the basic.c file. Type the basic.h & basic.rc files. Attach them
all to a project
basic01.dev file. Save the project and close everything.
Then I open the basic01.dev project. I click on the c-source file
(basic.c) and I
noticed at the lower left bottom of the window the word "Parsing:'
followed by an ever
changing bunch of messages. This is all happening before I'm able to do
anything to
the file I just opened. It goes on and on. I click on the close-window
X top screen right,
but nothing happens except (Not Responding) appears in the window title
bar. So I do
Control/Alt/Delete and exit the program.
I try the whole thing again with the same result. Then I uninstall
wxDevC++ and do a
brand new install. Things go OK, but it doesn't ask if I want to
precompile the headers.
I open my basic01.dev project and click the basic.c file. It goes on
OK. I hit Compile &
Run and it begins compiling. It goes on and on. I've decided to out
wait it. I go to the
bathroom, get a cup of coffee. Walk out to the street and collect the
mail. Put my
laundry in the washer...etc. An hour later I come back. It has the
file "String.h" open
and lists something like 497 errors followed by: too many errors aborting.
I'm now ready to scream at anyone--someone please let me scream at
you!!! But of
course no one else is around, so I once again uninstall the wxDevC++
program. This
time I turn the machine off and let it sit before powering it back on.
Then I reinstall
wxDevC++. Again it doesn't ask about precompiling headers. Again I
open basic.c
and again it starts Parsing the file before I can do anything else.
After it finishes I close
the project and try opening an earlier one. This goes normally. So I
don't know what to
make of it.
My first question is: how do I precompile the headers?
Second question is : does anybody else have a similar experience with
this code?
Mahalo (Thank You),
Roger Furer
Here is the code and comments from:
A comprehensive wxWidgets tutorial by David Beech.
*/
The source code for the first example is shown below.
*/
//file: basic.h
#ifndef BASIC_H
#define BASIC_H
class BasicApplication : public wxApp
{
public:
virtual bool OnInit();
};
class BasicFrame : public wxFrame
{
public:
BasicFrame( const wxChar *title,
int xpos, int ypos,
int width, int height);
~BasicFrame();
};
#endif
// end file: basic.h
/* This is the header file. In this basic application we declare two
classes:
* BasicApplication which inherits from wxApp and
* BasicFrame which inherits from wxFrame
We declare a constructor and destructor for BasicFrame but the only
thing we do for
BasicApplication is to override the OnInit() method. Note that since we
are overriding
we declare the method to be virtual.
*/
//file: basic.c
#include <wx/wx.h>
#include "basic.h"
IMPLEMENT_APP(BasicApplication)
bool BasicApplication::OnInit()
{
BasicFrame
*frame = new BasicFrame("Basic", 50, 50, 450, 300);
frame->Show(TRUE);
SetTopWindow(frame);
return TRUE;
}
BasicFrame::BasicFrame
(const wxChar *title,
int xpos, int ypos,
int width, int height)
: wxFrame
( (wxFrame *) NULL,
-1,
title,
wxPoint(xpos, ypos),
wxSize(width, height)
)
{
}
BasicFrame::~BasicFrame()
{
}
// end file: basic.c
/*
This is the implementation, the definition of the classes declared in
basic.h. The first
thing to notice is the macro:
IMPLEMENT_APP(BasicApplication)
which, from our point of view, constructs the BasicApplication object
and provides the
main entry point for our application. It replaces virtually all of the
work we did in the
previous lesson in the int WINAPI WinMain( ... ) function.
The OnInit() method creates an instance of BasicFrame with some default
x and y,
width and height values and a title. It then calls the Show() method to
show the frame. If
you look at the wxFrame class you won't find a Show() method, wxFrame
inherits from
wxWindow and Show() is a wxWindow member function. As a beginner you
might need
to keep this is mind - since many of the classes are derived from other
classes don't
overlook the methods that are available in parent classes.
OnInit() also calls SetTopWindow() which is a member of wxApp.
The constructor and destructor don't add any new behaviors to our
BasicFrame class.
The last relevant file is the resource file. In this simple example
we don't add any
of our own resources but you should always use a resource file that
contains at least
the line:
*/
// file: basic.rc
#include "wx/msw/wx.rc"
// end file: basic.rc
/*
In later examples we add our own resources.
All that remains is for you to build and run the program.
*/
|
|
From: Malcolm N. <m.n...@wa...> - 2004-12-04 10:54:05
|
Hello Roger,
On 04 December 2004, 02:30:28, you wrote:
> =A0Aloha from Honolulu,
> =A0=A0 I started doing a tutorial I found on the wxWidgets site under Do=
cumentation: A
> comprehensive wxWidgets tutorial by David Beech.=A0 There isn't much to =
it.=A0 I copied the
> code and pressed Compile & Run...
> =A0=A0 The first time (I had pre-compiled headers)
And how did you get them into wxDevCpp? wxDevCpp uses an older version
of the gcc compiler which doesn't support precompiled headers. Perhaps
the next distribution will support it, but beta 6.4 doesn't (if it
does and I am wrong here then I would love to know how you got them in
there.
> it came back with an error message: could
> not find /wx/msw/hand.cur.=A0 I got upset.=A0 I mean=96I can find that f=
ile!=A0 What's going on?
What is probably going on is that you created a new project (or
perhaps didn't even do that) without choosing one of the preset
wxWidget projects which should have the correct paths set up.
When working with wxDevCpp for working with tutorials I have found, I
create an empty wxWidgets template. Basically File - New - Project -
wxWidgets Frame. Chose a location for the files, then once the project
is open in the ide, in the properties bar, right click on every file
there and choose -remove file- and dont save the file contents. Then
once you have the project empty (perhaps you might want to keep the
.rc file - I don't) choose File - New - Template file in the dialog
and save.
Then add your files for the project (in your case you would create two
new files one named basic.h the other basic.cpp, copy the text from
the example into the respective windows. Save all, (I close the
project then reopen it - allowing the ide to parse the files to create
the class browser window contents), then press F9 it compiles and
runs.
> =A0=A0 I remembered about not using copy and paste, because of unprintab=
le characters.
> Aha!=A0 I erased the files in my tutorial/basic01 directory and typed th=
em in again by
> hand.
I used copy/paste and it still compiles correctly. It may of course
that you inadvertantly copied text other than the program code, it is
very easy to do when working from multi column web pages.
> =A0=A0 As I'm typing away I start getting the "Code Completion" feature =
horning in, but I can't
> do anything with it.=A0 I looked it up in Help, but it has yet to be imp=
lemented.=A0 So I bang
> my head a few times
Been there, done that, bought the paracetamol.
> and eventually get it disabled.=A0 Now can get the typing done.=A0 I
> save the basic.c file.=A0 Type the basic.h & basic.rc files.=A0 Attach t=
hem all to a project
> basic01.dev file.=A0 Save the project and close everything.
Check out my comment above.
> =A0=A0 Then I open the basic01.dev project.=A0 I click on the c-source f=
ile (basic.c) and I
> noticed at the lower left bottom of the window the word "Parsing:' follo=
wed by an ever
> changing bunch of messages.=A0 This is all happening before I'm able to =
do anything to
> the file I just opened.=A0 It goes on and on.=A0
It does indeed go on and on, but leave it alone and it will stop
eventually. I have seen this take from several seconds (the code from
the example you quote actually took 0.9 seconds, but I have had it
parse the files for up to two minutes)
> I click on the close-window X top screen right,
> but nothing happens except (Not Responding) appears in the window title =
bar.=A0 So I do
> Control/Alt/Delete and exit the program.
Not needed, so long as the text in the status bar is being updated,
then the program is simply busy.
> =A0=A0 I try the whole thing again with the same result.=A0 Then I unins=
tall wxDevC++ and do a
> brand new install.=A0 Things go OK, but it doesn't ask if I want to prec=
ompile the headers.
This isn't what it asks, it asks for the class browser code completion
features. Something totally different to precompiled headers.
> I open my basic01.dev project and click the basic.c file.=A0 It goes on =
OK.=A0 I hit Compile &
> Run and it begins compiling.=A0 It goes on and on.=A0 I've decided to ou=
t wait it.=A0 I go to the
> bathroom, get a cup of coffee.=A0 Walk out to the street and collect the=
mail.=A0 Put my
> laundry in the washer...etc.=A0 An hour later I come back.=A0 It has the=
file "String.h" open
> and lists something like 497 errors followed by: too many errors abortin=
g.
> =A0=A0 I'm now ready to scream at anyone--someone please let me scream a=
t you!!!=A0
Hell if you want to scream at me GO AHEAD, my wife does it all the
time, i guess i'm immune, I KNOW I'm deaf.
> But of
> course no one else is around, so I once again uninstall the wxDevC++ pro=
gram.=A0
Would you elaborate how you uninstalled the program? You must also
remove the devcpp.cfg and devcpp.ini files from your computer (they
are hidden somewhere, documents and settings somewhere) and for totall
safety delete the devcpp directory too (I always have my projects
under a seperate folder c:\Projects so that I can always delete the
devcpp directory without losing anything important)
> This
> time I turn the machine off and let it sit before powering it back on.=
=A0 Then I reinstall
> wxDevC++.=A0 Again it doesn't ask about precompiling headers.=A0 Again I=
open basic.c
> and again it starts Parsing the file before I can do anything else.=A0 A=
fter it finishes I close
> the project and try opening an earlier one.=A0 This goes
> normally.=A0 So I don't know what to
> make of it.
> =A0=A0 My first question is: how do I precompile the headers?
At the moment it means you have to install a newer version of GCC. I
believe that you are being confused between precompiling headers and
Class Completion.
> =A0=A0 Second question is : does anybody else have a similar experience =
with this code?
No, and just to show you, here is my code, copied and pasted from the
webpage into wxDevCpp and now from wxDevCpp into this mailing.
//basic.h
#ifndef BASIC_H
#define BASIC_H
class BasicApplication : public wxApp
{
public:
virtual bool OnInit();
};
class BasicFrame : public wxFrame
{
public:
BasicFrame( const wxChar *title,=20
int xpos, int ypos,=20
int width, int height);
~BasicFrame();
};
#endif
//basic.cpp
#include <wx/wx.h>
#include "basic.h"
IMPLEMENT_APP(BasicApplication)
bool BasicApplication::OnInit()
{
BasicFrame
*frame =3D new BasicFrame("Basic", 50, 50, 450, 300);
frame->Show(TRUE);
SetTopWindow(frame);
return TRUE;
}
BasicFrame::BasicFrame
(const wxChar *title,
int xpos, int ypos,
int width, int height)
: wxFrame
( (wxFrame *) NULL,
-1,
title,
wxPoint(xpos, ypos),
wxSize(width, height)
)
{
}
BasicFrame::~BasicFrame()
{
}
I did notice that your copied text begins
*/
The source code for the first example is shown below.
*/
If that is correct it SHOULD be :
/*
The source code for the first example is shown below.
*/
And that could explain why you have so many errors.
Since these are questions related to wxDevCpp and not just DevCpp with
respect to a DevPak I would suggest you take a look at the wxWidgets
Forum http://www.solidsteel.nl/users/wxwidgets/index.php under the
Compiler/IDE section (I frequent the forum too) and place your
questions there, I could understand it if the pure DevCpp users get a
little steamed about this (wxDevCpp) topic, since often questions
related to wxDevCpp are totally seperate to those for DevCpp.
--=20
Best regards,
Malcolm mailto:m.n...@wa...
|