1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
CMyApp theApp; // The one and only one application object
BOOL CMyApp::OnIdle(LONG lCount){
CWinApp::OnIdle(lCount) ;
return(FALSE);
}
BOOL CMyApp::PreTranslateMessage(MSG* pMsg){
return CWinApp::PreTranslateMessage(pMsg) ;
}
void RunMessagePump()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
// Handle dialog messages
MSG msg;
BOOL bRet ;
// GetMessage() returns :
// 1..n if there is a message
// 0 if the message is WM_QUIT (end of application)
// -1 if there is an error
//****************************************************
while( (bRet = GetMessage( &msg, NULL, 0, 0 )) != 0 )
{
if (bRet == -1){
fprintf(stderr, "Error while receiving messages : %u\n", GetLastError() ) ;
break ;
}else{
//fprintf(stderr, "Message = %u \n", msg.message ) ;
if (!theApp.PreTranslateMessage(&msg)){
//fprintf(stderr, "theApp a pretranslate le message\n" ) ;
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
theApp.OnIdle(0); // updates user interface
theApp.OnIdle(1); // frees temporary objects
}
}
fprintf(stderr, "exiting message pump\n" ) ;
theApp.ExitInstance() ;
}
/********************************************************************
* extern "C" BOOL __declspec(dllexport) Start()
*
* the entry point of the DLL.
* 'Start' is the function that is called by the external executable.
* It initialize a MyApp object and by this mean
* lauch a instance of the program.
*********************************************************************/
extern "C" BOOL __declspec(dllexport) Start()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState()); // for handles safety
RunMessagePump() ; // simulate a main message loop
return FALSE;
}
/********************************************************************
* MyApp
*
* This class declares, initializes and manage the
* application through a MDI architecture
*********************************************************************/
CMyApp::CMyApp()
: CWinApp( "Target Builder" )
{
fprintf(stderr, "Constructeur MyApp()..\n") ;
/* init ptr members here */
}
/********************************************************************
* BOOL InitInstance()
*
* CWinApp overriden method
* Used as the application entry point
*********************************************************************/
BOOL CMyApp::InitInstance(){
if( !CWinApp::InitInstance() )
return FALSE ;
/* init your instance here */
return TRUE;
} |
Partager