Author Topic: redefinition of wxFrame & wxApp  (Read 9895 times)

Offline Danishx83

  • Single posting newcomer
  • *
  • Posts: 5
redefinition of wxFrame & wxApp
« on: May 03, 2012, 06:21:02 pm »
I am trying wxWidgets ( 2.8 ) on C::B ( 10.5 ), created a new project, setup every thing as shown by many guides / tutorials. When I try to compile, it gives two warnings

  • error : redefinition of wxFrame
  • error : redefinition of wxApp

in  wxMain.h

Code
class wxFrame : public wxFrame {
  //constr
  //distor
  //few funct
  //few static const
  //a pointer
};

in wxApp.h

Code
class wxApp : public wxApp {
  //OnInit function
};

All the code is auto generated, as I am just starting to learn wxWidgets

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: redefinition of wxFrame & wxApp
« Reply #1 on: May 03, 2012, 06:25:34 pm »
Isn't it obvious?
Your derived class must not have the same name as the base class. Rename wxFrame to something else and it will be fine.
I guess you'll have to run the wxsmith wizard once again...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Danishx83

  • Single posting newcomer
  • *
  • Posts: 5
Re: redefinition of wxFrame & wxApp
« Reply #2 on: May 03, 2012, 06:58:32 pm »
Yes I tried that before but there were many more errors,  :-[

Now I changed them again

in  wxMain.h

Code
class MywxFrame : public wxFrame {
  //constr MywxFrame
  //distor MywxFrame
  //few funct
  //few static const
  //a pointer
};

in wxMain.cpp
respective changes


in wxApp.h

Code
class MywxApp : public wxApp {
  //OnInit function
};

in wxApp.cpp
respective changes

The thing that made it work was changing

Code
BEGIN_EVENT_TABLE(wxFrame, wxFrame){} //error (auto generated code)
to
Code
BEGIN_EVENT_TABLE(MywxFrame, wxFrame){} //Correct
which previously I did was
Code
BEGIN_EVENT_TABLE(MywxFrame, MywxFrame){} //error

in wxMain.cpp

So all this implies that the auto generated code has error, how do I correct it, so next time I create a new project and don't have to do all this.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: redefinition of wxFrame & wxApp
« Reply #3 on: May 03, 2012, 07:50:05 pm »
Please explain all the step you take to make a new project.
You've made an error somewhere and this will help us see what you're doing wrong.

Editing the existing project is a bit pointless. You can replace all the references to wxFrame and wxApp in the wxs files created by the wizard.
But this is not needed and creating project should work out of the box.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Danishx83

  • Single posting newcomer
  • *
  • Posts: 5
Re: redefinition of wxFrame & wxApp
« Reply #4 on: May 03, 2012, 08:27:22 pm »
File > New > Project
wxWidgets
wxWidgets 2.8.x
Project title "wx" <-------------Problem creator :o, caught it, but the template must cater for newbies like me
Auth Name "danishx83"
PrefGUIbuild -> wxSmith, Apptype -> FrameBased
wxWidgets Loc-> $(#wx) = "C:\wxWidgets2.8"
Compiler-> MinGW, Debug = Yes, Release = Yes
wxWidgetsLibSet-> Use DLL = Yes, monolithic = Yes, Unicode = Yes
Misc -> PCH = Yes

Files
wxApp.cpp
wxMain.cpp
wx_pch.h
wxApp.h
wxMain.h
resources.rc
xframe.wxs


@oBFusCATed: Thank You

« Last Edit: May 03, 2012, 08:31:29 pm by Danishx83 »

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: redefinition of wxFrame & wxApp
« Reply #5 on: May 04, 2012, 05:03:39 pm »
Project title "wx" <-------------Problem creator :o, caught it, but the template must cater for newbies like me
I don't think so, sorry,  but there is no way to check for all possible redefinitions in all toolkit we have wizards for.

Offline Danishx83

  • Single posting newcomer
  • *
  • Posts: 5
Re: redefinition of wxFrame & wxApp
« Reply #6 on: May 06, 2012, 07:43:52 pm »
the problem is that when I named my project as "wx", it created the class wxFrame for my application and was trying to extend the project wxFrame with base class wxFrame. I think a simple solution to it would be to append a "_" or some char between the project name and object type (Frame, Dialog etc) so that no project name could ever replicate the original base class identifiers.

Offline Danishx83

  • Single posting newcomer
  • *
  • Posts: 5
Re: redefinition of wxFrame & wxApp
« Reply #7 on: May 06, 2012, 07:46:33 pm »
My limited exposure to the world of coding says that such a change to the templets should be easy and improvement.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: redefinition of wxFrame & wxApp
« Reply #8 on: May 06, 2012, 09:16:51 pm »
the problem is that when I named my project as "wx", it created the class wxFrame for my application and was trying to extend the project wxFrame with base class wxFrame. I think a simple solution to it would be to append a "_" or some char between the project name and object type (Frame, Dialog etc) so that no project name could ever replicate the original base class identifiers.
Doesn't sound like a good solution...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]