[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.
*/
|