![]() |
Re: SDL and MFC | ![]() |
contact access-dev
Guest
![]() |
![]() |
Carlos Alvarez <citrouille <at> wanadoo.fr> writes:
you can add this code to your program, it works but unfortunalety your program would quit when you close the MFC main windows int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { int nReturnCode = -1; CWinThread* pThread = AfxGetThread(); CWinApp* pApp = AfxGetApp(); if (!AfxWinInit(hInstance, hPrevInstance, lpCmdLine, nCmdShow)) goto InitFailure; if (pApp != NULL && !pApp->InitApplication()) goto InitFailure; if (!pThread->InitInstance()) { if (pThread->m_pMainWnd != NULL) { TRACE0("Warning: Destroying non-NULL m_pMainWnd\n"); pThread->m_pMainWnd->DestroyWindow(); } nReturnCode = pThread->ExitInstance(); goto InitFailure; } nReturnCode = pThread->Run(); InitFailure: AfxWinTerm(); SDL_Quit(); return nReturnCode; }
Yes the project is Multithreadad DLL and the MFC is in shared DLL too. Since we include SDL library, when we build the project we have this error during the linking operation: sdlmain.lib(SDL_win32_main.obj) : error LNK2001: unresolved external symbol _SDL_main It's normal because we don't have main or WinMain function, it's the MFC who run the classes. If we put a main or a WinMain function, we don't have error but it's this main function that starts the program! So the question is: Can we say to SDL that our main function IS the MFC main function? or What must we put in the main function for the program boot normally (i think something like the code of the MFC main function but i'm not sure and i'm not a pro in MFC...) Access-Dev.Com http://www.access-dev.com Montpellier - France T?l : +33 (0) 4 67 58 37 90 Fax : +33 (0) 4 67 58 37 90 Mobile : +33 (0) 6 08 16 61 11 SIRET : 482 737 889 00014 |
||||||||||||||||||||||
|
![]() |
Re: SDL and MFC | ![]() |
ibrahim
Guest
![]() |
![]() |
Hi,
you can add this code to your program, it works but unfortunalety your program would quit when you close the MFC main windows int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { int nReturnCode = -1; CWinThread* pThread = AfxGetThread(); CWinApp* pApp = AfxGetApp(); if (!AfxWinInit(hInstance, hPrevInstance, lpCmdLine, nCmdShow)) goto InitFailure; if (pApp != NULL && !pApp->InitApplication()) goto InitFailure; if (!pThread->InitInstance()) { if (pThread->m_pMainWnd != NULL) { TRACE0("Warning: Destroying non-NULL m_pMainWnd\n"); pThread->m_pMainWnd->DestroyWindow(); } nReturnCode = pThread->ExitInstance(); goto InitFailure; } nReturnCode = pThread->Run(); InitFailure: AfxWinTerm(); SDL_Quit(); return nReturnCode; } Carlos Alvarez <citrouille <at> wanadoo.fr> writes:
Yes the project is Multithreadad DLL and the MFC is in shared DLL too. Since we include SDL library, when we build the project we have this error during the linking operation: sdlmain.lib(SDL_win32_main.obj) : error LNK2001: unresolved external symbol _SDL_main It's normal because we don't have main or WinMain function, it's the MFC who run the classes. If we put a main or a WinMain function, we don't have error but it's this main function that starts the program! So the question is: Can we say to SDL that our main function IS the MFC main function? or What must we put in the main function for the program boot normally (i think something like the code of the MFC main function but i'm not sure and i'm not a pro in MFC...) Access-Dev.Com http://www.access-dev.com Montpellier - France T?l : +33 (0) 4 67 58 37 90 Fax : +33 (0) 4 67 58 37 90 Mobile : +33 (0) 6 08 16 61 11 SIRET : 482 737 889 00014 |
||||||||||||||||||||||
|