User forums > General (but related to Code::Blocks)

creating wxThread and wxFrame classes in seperate files.

(1/1)

nishalns:
I am referring to the program given in the link: 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.

MortenMacFly:

* 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.

nishalns:

--- Quote from: MortenMacFly on July 24, 2013, 03:49:36 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.


--- End quote ---

Can you give me a short example demonstrating this. I'm finding it a bit difficult to understand...

ollydbg:

--- Quote from: nishalns on July 25, 2013, 02:07:18 pm ---Can you give me a short example demonstrating this. I'm finding it a bit difficult to understand...

--- End quote ---
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"
--- End code ---
Put MyFrame.cpp into your project, that's all.

nishalns:
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. 

Navigation

[0] Message Index

Go to full version