News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

redefinition of wxFrame & wxApp

Started by Danishx83, May 03, 2012, 06:21:02 PM

Previous topic - Next topic

Danishx83

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

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


in wxApp.h

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


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

oBFusCATed

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!]

Danishx83

Yes I tried that before but there were many more errors,  :-[

Now I changed them again

in  wxMain.h

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


in wxMain.cpp
respective changes


in wxApp.h

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


in wxApp.cpp
respective changes

The thing that made it work was changing

BEGIN_EVENT_TABLE(wxFrame, wxFrame){} //error (auto generated code) to BEGIN_EVENT_TABLE(MywxFrame, wxFrame){} //Correct which previously I did was 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.

oBFusCATed

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!]

Danishx83

#4
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


Jenna

Quote from: Danishx83 on May 03, 2012, 08:27:22 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.

Danishx83

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.

Danishx83

My limited exposure to the world of coding says that such a change to the templets should be easy and improvement.

oBFusCATed

Quote from: Danishx83 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.
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!]