Click here to Skip to main content
16,011,383 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalreading window messages Pin
Anonymous20-May-04 9:25
Anonymous20-May-04 9:25 
GeneralRe: reading window messages Pin
vladfein20-May-04 14:40
vladfein20-May-04 14:40 
GeneralRe: reading window messages Pin
Anonymous21-May-04 5:26
Anonymous21-May-04 5:26 
Generalstarting with MFC adding stuff to the MainFrame Pin
kfaday20-May-04 9:22
kfaday20-May-04 9:22 
GeneralRe: starting with MFC adding stuff to the MainFrame Pin
Antti Keskinen20-May-04 11:19
Antti Keskinen20-May-04 11:19 
GeneralRe: starting with MFC adding stuff to the MainFrame Pin
kfaday21-May-04 1:59
kfaday21-May-04 1:59 
GeneralWindows/Unix (platform independence) code Pin
Mash20-May-04 8:39
Mash20-May-04 8:39 
GeneralRe: Windows/Unix (platform independence) code Pin
Giles20-May-04 8:58
Giles20-May-04 8:58 
Mash wrote:
1. Do we need to explicity #define these?

Yes.

Mash wrote:
2. If yes, where in the code do we do that and how?

The actual defines are passed to the compiler. In the code you then do a

#ifdef WIN32<br />
... Do stuff, that is specific to windows, say an optimised verison of a socket class.<br />
class Socket...<br />
class ThreadWrapper<br />
#else<br />
... Do stuff for Unix in here, if you are only working with 2 platforms.<br />
class Socket...<br />
class ThreadWrapper<br />
#endif


Each class will have the same public methods, but depending on the comiler you use will then only compile the code wrapped by the defines passed to it.

A good example of using the defines can be seen when writting plain C++ dll library classes where the classes need to be exported into the function table with a __declspec(dllexport) and need to be imported by the code that used the library with the class headers preceeded by a __declspec(dllimport)

To see this in VS.NET, create a new Win32 project, and make it a dll class library project, and select export symbols, which is where the defines are used for the liker.

#ifdef MYLIB_EXPORTS	// specified in compiler options<br />
#define MYLIB_API __declspec(dllexport)<br />
#else<br />
#define MYLIB_API __declspec(dllimport)<br />
#endif<br />
<br />
// This class is exported from the mylib.dll<br />
class MYLIB_API CSampleClass {<br />
public:<br />
	CSampleClass(void);<br />
	// TODO: add your methods here.<br />
};


A good thing to do would be to have a look an an existing cross platform library like wxWindows, which is an MFC like gui library for Linux and Windows.

http://www.wxwindows.org/[^]




"Je pense, donc je mange." - Rene Descartes 1689 - Just before his mother put his tea on the table.

Shameless Plug - Distributed Database Transactions in .NET using COM+

GeneralRe: Windows/Unix (platform independence) code Pin
Mash20-May-04 9:48
Mash20-May-04 9:48 
GeneralRe: Windows/Unix (platform independence) code Pin
Curi0us_George20-May-04 10:17
Curi0us_George20-May-04 10:17 
GeneralRe: Windows/Unix (platform independence) code Pin
Henry miller21-May-04 2:34
Henry miller21-May-04 2:34 
Generalimage pixels Pin
deniz79s20-May-04 8:37
deniz79s20-May-04 8:37 
GeneralRe: image pixels Pin
Member 42102521-May-04 11:52
Member 42102521-May-04 11:52 
GeneralVStudio; Property Wnd Pin
kylur20-May-04 8:15
kylur20-May-04 8:15 
GeneralRe: VStudio; Property Wnd Pin
Antti Keskinen20-May-04 11:22
Antti Keskinen20-May-04 11:22 
Generalsetting the size of a CFrameWnd Pin
kfaday20-May-04 8:05
kfaday20-May-04 8:05 
GeneralRe: setting the size of a CFrameWnd Pin
kylur20-May-04 8:21
kylur20-May-04 8:21 
GeneralRe: setting the size of a CFrameWnd Pin
oleg6320-May-04 8:24
professionaloleg6320-May-04 8:24 
GeneralRe: setting the size of a CFrameWnd Pin
kfaday20-May-04 8:32
kfaday20-May-04 8:32 
GeneralSetting the delay time for ToolTips control Pin
Cyrus Dang20-May-04 6:58
Cyrus Dang20-May-04 6:58 
GeneralCListBox problem... Pin
Mirelutza20-May-04 6:43
Mirelutza20-May-04 6:43 
GeneralRe: CListBox problem... Pin
David Crow20-May-04 9:20
David Crow20-May-04 9:20 
GeneralRe: CListBox problem... Pin
Mirelutza20-May-04 10:28
Mirelutza20-May-04 10:28 
GeneralRe: CListBox problem... Pin
*Dreamz20-May-04 18:38
*Dreamz20-May-04 18:38 
GeneralRe: CListBox problem... Pin
Mirelutza20-May-04 21:16
Mirelutza20-May-04 21:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.