コンソール AP で,MFC(AfxWin.h など)に依存したコードを利用
新しく書いたものは,次の様なコードで可能.
#include "EnhMetaF.hxx" #include "i_trace.hxx" int _tmain(int argc, TCHAR* argv[]) { _tsetlocale(LC_ALL,_T("")) ; { EnhMetaF emf ; CMetaFileDC* mfdc = emf.GetDC() ; mfdc->Rectangle(10,10,30,20) ; } return 0 ; }
古いコードは,うまく対応できてないので…
#undef _CONSOLE
#include <AfxWin.h>
#include <AfxExt.h>
#include <AfxCmn.h>
#ifdef _WIN32
#define _WINDOWS
#endif
#include "MessCon.hxx"
#include "MessBar.hxx"
#ifdef MessageBar
#undef MessageBar
#define MessageBar MessageCon
#undef I_SUPPORT_MESSAGE_MFC
#endif
#include "MessWrap.hxx"
// ...
int _tmain(int argc, TCHAR* argv[])
{
#ifdef _MFC_VER
if (!::AfxWinInit(::GetModuleHandle(NULL),NULL,::GetCommandLine(),0)) {
return 1 ;
}
#else
_tsetlocale(LC_ALL,_T("")) ;
#endif
// ...
}
undef の幾つかは,自コードの対応のために必要.