Author Topic: Efficient ways of getting code from wxFormBuilder into Code::Blocks  (Read 6574 times)


  • Guest
Hello all,

I'm trying to use Code::Blocks to develop a wxWidgets app using wxFormBuilder. I have created a new project  in Code::Blocks and selected wxFormBuilder as the preferred GUI builder, this creates a file called WxWizFrame.fbp which opens in form builder. Form builder upgrades this file and I can edit the form as expected.

The problem I have is that the only ways I can find to get the generated code back into code::blocks seem rather effort intensive and I suspect that there must be an easier, more automatic way. I've googled and haven't shown anything up. The process I use at present is as follows:
  • After making form changes, autogenerate code and generate the inherited class
  • Open the inherited class definition and copy the new functions across to filenameMain.h
  • Open the file containing the inherited class and copy any new functions into the filenameMain.cpp
  • Add code to the functions to make them work

I can't shake the feeling that I should be able to remove the middle two steps and I've tried changing the name of the generated file, the name of the frame and the name of the generated class to more closely match the ones used by Code::blocks when it creates the project but I can't seem to hit on a combination that works.

Can anybody suggest a better method to me? Sorry if this isn't the right forum to ask this question.

Thanks in advance


Offline vri

  • Multiple posting newcomer
  • *
  • Posts: 18
Re: Efficient ways of getting code from wxFormBuilder into Code::Blocks
« Reply #1 on: November 13, 2008, 03:36:21 pm »
Add the .cpp and h files generated by wxFormBuilder to your CodeBlocks project (using the menu Project->Add files...)


  • Guest
Re: Efficient ways of getting code from wxFormBuilder into Code::Blocks
« Reply #2 on: November 13, 2008, 04:07:05 pm »
I've done that but if I add code to the functions in the auto generated inherited class it never gets called though the code compiles fine. For example if I add a button and create an onclick event I get a line like this:

   m_button1->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( GUIFrame::buttonclicktest ), NULL, this );

in GUIframe.cpp. and a matching function in MyProjectGUIFrame.cpp. If I add this code to that function

void MyProjectGUIFrame::buttonclicktest( wxCommandEvent& event )
  static int count = 0;
  wxString temp_str = "clicked ";
  temp_str.Printf("clicked %d", count++);

it never gets called. If I copy the function I have written to form_builder_test2Main.cpp and change it to

void form_builder_test2Frame::buttonclicktest( wxCommandEvent& event )
<rest of code identical>

and add that to the class definition in form_builder_test2Main.h then it all works as expected and the label of the button changes every time I click on the button.