Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add personal code into wxFormBuilder-generated class

I play with Eclipse + wxWidgets + wxFormBuilder

I use wxFormBuilder for GUI-design. It generates 2 classes: first is base class; second inherits first to implement functionality like button clicks. But both of this files are regenerated every time I have changes in wxFormBuilder.

I wonder how to add some code to inherited class. For example, I have listbox, button and menu item. I want to do same action (add some string to listbox) when user presses button or selects menu item. For this reason I want to implement common function 'action'. I'll call this functuion in button and menu item handlers. Where I should declare this function and its implementation to avoid erasing manual code?

Thanks.

like image 969
fat Avatar asked Oct 31 '25 21:10

fat


1 Answers

wxFormbuilder has the ability to generate a derived class for you. Located under Tools->Generate Inherited Class.

This code is only generated when you invoke this tool, so most probably only once. It is derived from the automatically generated class. You use this class and can implement your stuff inside of it.

So, the usual workflow is like this:

  • build your frame/panel in formbuilder
  • generate inherited class
  • implement your handling code in inherited class
  • make changes to form/panel in wxFormbuilder -> will only affect generated class, not inherited class
like image 121
LiMuBei Avatar answered Nov 03 '25 11:11

LiMuBei



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!