Code::Blocks Forums

User forums => General (but related to Code::Blocks) => Topic started by: nishalns on July 24, 2013, 12:35:46 pm

Title: creating wxThread and wxFrame classes in seperate files.
Post by: nishalns on July 24, 2013, 12:35:46 pm
I am referring to the program given in the link: http://docs.wxwidgets.org/trunk/classwx_thread.html (http://docs.wxwidgets.org/trunk/classwx_thread.html). Now, in my program I want to write "MyFrame" and "MyThread" classes in seperate '.h' and '.cpp' files. How would I do that?

Also, is there a way by which I can add threads to my project in wxsmith just as I add wxFrame, wxDialog,etc. from the wxSmith menu.
Title: Re: creating wxThread and wxFrame classes in seperate files.
Post by: MortenMacFly on July 24, 2013, 03:49:36 pm
Title: Re: creating wxThread and wxFrame classes in seperate files.
Post by: nishalns on July 25, 2013, 02:07:18 pm
  • Create the frame using wxSmith, naming it as you like (i.e. MyFrame). This results in MyFrame.cpp and MyFrame.h being created.
  • Implement the Thread class into own files
  • Reference this class in your "MyFrame" class, or wherever needed. Notice that wxSmith has (by design) no interface to a wxThread, as it is not a GUI (related) class.


Can you give me a short example demonstrating this. I'm finding it a bit difficult to understand...
Title: Re: creating wxThread and wxFrame classes in seperate files.
Post by: ollydbg on July 25, 2013, 02:13:11 pm
Can you give me a short example demonstrating this. I'm finding it a bit difficult to understand...
Suppose you have a MyThread.h and MyThread.cpp which have class MyThread's declaration and implementation, then in the MyFrame.h or MyFrame.cpp, just use
Code
#include "MyThreads.h"
Put MyFrame.cpp into your project, that's all.
Title: Re: creating wxThread and wxFrame classes in seperate files.
Post by: nishalns on July 26, 2013, 05:57:37 am
Well, thanks all for answering my question. Actually, I included the 'MyThread.h' in 'MyFrame.h' and vice versa and also used forward declaration and the problem was solved.