Author Topic: How do I get rid of unwanted code?  (Read 231 times)

Offline Landslyde

  • Multiple posting newcomer
  • *
  • Posts: 43
How do I get rid of unwanted code?
« on: July 06, 2018, 08:58:51 pm »
I keep deleting this in main.cpp:
Code: [Select]
Connect(ID_TREEBOOK1,wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED,(wxObjectEventFunction)&Angela001Frame::OnTreebook1PageChanged);
I removed the code for this in main.h too. BUT, everytime I do anything to the form, the code I deleted in main.cpp comes back! I've deleted
Code: [Select]
Connect(ID_TREEBOOK1,wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED,(wxObjectEventFunction)&Angela001Frame::OnTreebook1PageChanged);more than twenty times. What do I need to do to permanently delete this? In Qt I've have to delete it from the .moc file. But I can't find anything like that here.
« Last Edit: July 06, 2018, 09:10:01 pm by Landslyde »
Linux Mint 18.3
Code::Blocks 17.12
G++ 8.0

Offline BlueHazzard

  • Lives here!
  • ****
  • Posts: 1883
Re: How do I get rid of unwanted code?
« Reply #1 on: July 06, 2018, 09:32:31 pm »
Do not modify the code in the wxSmith tags.... The code generator will add it again and again..

Have you removed the event in the wxSmith editor?
What kind of project are you using? XRC or cpp?

Offline Landslyde

  • Multiple posting newcomer
  • *
  • Posts: 43
Re: How do I get rid of unwanted code?
« Reply #2 on: July 06, 2018, 09:41:22 pm »
It's a *.cpp project

Quote
Do not modify the code in the wxSmith tags.... The code generator will add it again and again..

I didn't know this. There isn't a way to remove the reference to the unwanted code? I guess it doesn't hurt anything being there, but it sure don't look right.

Anyway, I did delete both the main.cpp.save and main.h.save files and the code hasn't came back since I made this post. If it comes back, I'll open a new project and c/p my code into it. Something about lingering code that just don't set right with me.

Thanks for your help, BlueHazzard.
« Last Edit: July 06, 2018, 09:43:41 pm by Landslyde »
Linux Mint 18.3
Code::Blocks 17.12
G++ 8.0

Offline BlueHazzard

  • Lives here!
  • ****
  • Posts: 1883
Re: How do I get rid of unwanted code?
« Reply #3 on: July 06, 2018, 10:38:32 pm »
It will come again as soon as you modify in the wxSmith editor or load the project...


Quote
There isn't a way to remove the reference to the unwanted code?
+
YES... remove it in the wxSmith editor.
You have to have added an event for the ID_TREEBOOK1 at one point...
Do you know how to add events in the wxSmith editor? it is the "{}" symbol...



There is a other way to remove this, but i do not want to share it if there is a other way to do it... If you can not find it at any circumstance : ask and i will tell you, but as far as i can tell it will create more problems than it solves (the most time)...

Offline Landslyde

  • Multiple posting newcomer
  • *
  • Posts: 43
Re: How do I get rid of unwanted code?
« Reply #4 on: July 06, 2018, 10:54:14 pm »
Quote
Do you know how to add events in the wxSmith editor? it is the "{}" symbol...

I do. But I think I got rid of it when I deleted the lines from the .cpp and .h and then deleted the two .save files for main.cpp and main.h. I've jacked around with the form, closed CB and opened it back up. So far, that code's staying away. Fingers crossed here!

What made me decide to delete the two .save files was the fact that when I'd delete the wx line of code that kept coming back, I was also changing my form size in the properties from 791 width to 825. And that also reflected in the wx code. But then when the deleted wx code wld come back, my form width was back to 791 again. That's why I'm sure deleting those two .save files did the trick.
« Last Edit: July 06, 2018, 11:02:57 pm by Landslyde »
Linux Mint 18.3
Code::Blocks 17.12
G++ 8.0

Offline BlueHazzard

  • Lives here!
  • ****
  • Posts: 1883
Re: How do I get rid of unwanted code?
« Reply #5 on: July 06, 2018, 11:12:17 pm »
Ok, lets clear things up, i think you have some confusion going on here....

Quote
I do. But I think I got rid of it when I deleted the lines from the .cpp and .h
No, all editor related things are stored in a xml file, that is only edited by the wxSmith plugin (the drawing thing in codeblocks you use to create the dialog)

Quote
the two .save files for main.cpp and main.h.
They are not used by codeblocks normally, only used if something went wrong. So do yourself a favor and DO NOT EDIT OR DELETE them...

Quote
closed CB and opened it back up. So far, that code's staying away. Fingers crossed here!
Ok, i thought that wxSmith loads it automatically. You will see as soon as you open wxSmith, edit something and save it will come back...

I absolutely do not understand where the problem is to remove the event handler within the wxSmith editor. Why people always have to workaround to problems that are not there. Use buggy solutions and think it will work.

Quote
Say, I'm using the wxTreebook. It works good for putting a lot on one form. But is there anything like a stacked widget for CB? It's abt the same as the wxTreebook...just doesn't have the tree.
Ok, now you talk about complete different?
Quote
But is there anything like a stacked widget for CB
codeblocks does not have anything of this... WxWidgets has it and wxSmith (a codeblocks plugin) probably has to support it.
I do not know what a stacked widget is. WxWidgets supports mostly only native window elements. So if your operating system supports it wxWidgets will have it. One possibility to share window elements across multiple pages is a notebook control. Yes wxSmith supports it. You can add new pages with a right click in the editor.
We do not support wxWidgets questions here... But if you have some problems creating some constellation of windows with wxSmith you can ask here...





Offline BlueHazzard

  • Lives here!
  • ****
  • Posts: 1883
Re: How do I get rid of unwanted code?
« Reply #6 on: July 06, 2018, 11:19:35 pm »
I think what you are searching for is a "wxListBook" and yes wxSmith supports it.
You can add panels by dropping a wxPanel over the wxListBook

Offline Landslyde

  • Multiple posting newcomer
  • *
  • Posts: 43
Re: How do I get rid of unwanted code?
« Reply #7 on: July 06, 2018, 11:31:24 pm »
Thanks for the good information, BlueHazzard.
Linux Mint 18.3
Code::Blocks 17.12
G++ 8.0