Console lädt MFC Dynamisch



  • Hi,

    wenn ein Konsoleprogramm eine MFC DLL Lädt, erhält diese keine
    Fensternachrichten.

    Ist es möglich in der DLL selber eine Nachrichten-Pumpe zu betreiben
    ohne das dies die Konsoleanwendung tut ?

    Beispiel wie es nicht geht :

    #include <process.h>
    static unsigned __stdcall Client(void *ptr)
    {
    	CWnd *pWnd((CWnd *)ptr);
    	MSG msg;
    
    	while (PeekMessage(&msg, 0, WM_USER, WM_USER, PM_NOREMOVE))
    	{
    		TranslateMessage(&msg);
    		DispatchMessage(&msg);
    	}
    
    	return FALSE;
    }
    
    CJenoptikApp theApp;
    BOOL CJenoptikApp::InitInstance()
    {
    	CWinApp::InitInstance();
    
    	LPCTSTR pszClassName;
    	pszClassName = AfxRegisterWndClass(CS_VREDRAW | CS_HREDRAW, ::LoadCursor(NULL, IDC_ARROW), (HBRUSH)(COLOR_BTNFACE + 1));
    	DWORD dwStyle = WS_POPUP | WS_DLGFRAME | WS_VISIBLE |WS_THICKFRAME;
    	m_pMainWnd = new CWnd;
    	if (m_pMainWnd)
    	 m_pMainWnd->CreateEx(0, pszClassName, _T("Test"), dwStyle, CRect(0,0,100,100), 0, 0);
    
    	DWORD ret; _beginthreadex(0, 0, Client, (void*)AfxGetMainWnd(), 0, (unsigned *)&ret);
    
    	return TRUE;
    }
    

    Danke für Hinweise:
    Karsten



  • OMG erledigt CWinThread...


Anmelden zum Antworten