Click here to Skip to main content
15,920,031 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: AfxGetResourceHandle() assertion failure on LoadFrame() Pin
Mark Salsbery10-Aug-07 4:49
Mark Salsbery10-Aug-07 4:49 
GeneralRe: AfxGetResourceHandle() assertion failure on LoadFrame() Pin
p_47310-Aug-07 7:53
p_47310-Aug-07 7:53 
QuestionRe: AfxGetResourceHandle() assertion failure on LoadFrame() Pin
p_47311-Aug-07 1:24
p_47311-Aug-07 1:24 
QuestionRe: AfxGetResourceHandle() assertion failure on LoadFrame() Pin
p_47315-Aug-07 4:57
p_47315-Aug-07 4:57 
AnswerRe: AfxGetResourceHandle() assertion failure on LoadFrame() Pin
Mark Salsbery15-Aug-07 5:23
Mark Salsbery15-Aug-07 5:23 
QuestionRe: AfxGetResourceHandle() assertion failure on LoadFrame() Pin
p_47324-Aug-07 7:50
p_47324-Aug-07 7:50 
QuestionRe: AfxGetResourceHandle() assertion failure on LoadFrame() Pin
p_47327-Aug-07 6:17
p_47327-Aug-07 6:17 
GeneralRe: AfxGetResourceHandle() assertion failure on LoadFrame() Pin
pbor17-Aug-08 21:40
pbor17-Aug-08 21:40 
I have search, read, and tried a lot of directions and finally got a sample that works. I'm posting it here hoping to receive feedback, i cannot oversee it all and this code is only running for a couple of hours now....

One explicit wish that i had is that i do not want to initialize MFC nor show a gui when the ATL Local COM server is only processing commandline arguments (like regserver/unregserver).

Code:

// TestStub.cpp : Implementation of WinMain
#include "stdafx.h"
#include "resource.h"
#include "TestStub.h"
#include "TestDlg.h"

//
// The MFC Module
//

class CTestStubApp : public CWinApp
{
public:
// Overrides
virtual BOOL InitInstance();
virtual int ExitInstance();
virtual int Run();

DECLARE_MESSAGE_MAP()
};

BOOL CTestStubApp::InitInstance()
{
CWinApp::InitInstance();

AfxEnableControlContainer();

//Create a modeless dialog
m_pMainWnd = new CTest();
dynamic_cast<ctest*>(m_pMainWnd)->Create(IDD_TEST, 0);
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
m_pMainWnd->SetFocus();

return TRUE;
}

int CTestStubApp::ExitInstance()
{
//Cleanup
delete m_pMainWnd;
m_pMainWnd = 0;

return CWinApp::ExitInstance();
}

int CTestStubApp::Run()
{
//Do not invoke MFC CWinApp::Run(), messages for MFC are handled through the ATL message handler (RunMessageLoop)
//CWinApp::Run()
return 0;
}

BEGIN_MESSAGE_MAP(CTestStubApp, CWinApp)
END_MESSAGE_MAP()

CTestStubApp theApp;

//
// The ATL Module
//

class CTestStubModule
: public CAtlExeModuleT<cteststubmodule>
{
public :
DECLARE_LIBID(LIBID_TestStubLib)
DECLARE_REGISTRY_APPID_RESOURCEID(IDR_TestSTUB, "{45383526-A2CD-4CA4-9170-AE3DBF5EFB8E}")

HRESULT PreMessageLoop(int nShowCmd) throw();
void RunMessageLoop() throw();
HRESULT PostMessageLoop() throw();
};

HRESULT CTestStubModule::PreMessageLoop(int nShowCmd) throw()
{
//Initialize the MFC module
theApp.InitInstance();
return CAtlExeModuleT<cteststubmodule>::PreMessageLoop(nShowCmd);
}

void CTestStubModule::RunMessageLoop() throw()
{
MSG msg;
while (GetMessage(&msg, 0, 0, 0) > 0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);

//Route msg to MFC
theApp.PreTranslateMessage(&msg);
}
}

HRESULT CTestStubModule::PostMessageLoop() throw()
{
//Deinitialize the MFC module
theApp.ExitInstance();
return CAtlExeModuleT<cteststubmodule>::PostMessageLoop();
}

CTestStubModule _AtlModule;

extern "C" int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nShowCmd)
{
//Initialize the MFC library
AfxWinInit(hInstance, hPrevInstance, lpCmdLine, nShowCmd);
return _AtlModule.WinMain(nShowCmd);
}


Some keywords for searchengines on this topic:
ATL, local COM server, CAtlExeModuleT, AfxWinInit, RunMessageLoop, AfxGetResourceHandle assert
Questioni need to use a ddk Pin
javad_20057-Aug-07 6:13
javad_20057-Aug-07 6:13 
AnswerRe: i need to use a ddk Pin
Sam_c7-Aug-07 6:42
Sam_c7-Aug-07 6:42 
QuestionSimilar Images Pin
Maynka7-Aug-07 4:03
Maynka7-Aug-07 4:03 
AnswerRe: Similar Images Pin
led mike7-Aug-07 4:42
led mike7-Aug-07 4:42 
GeneralRe: Similar Images Pin
Jim Crafton7-Aug-07 9:36
Jim Crafton7-Aug-07 9:36 
GeneralRe: Similar Images Pin
led mike7-Aug-07 10:14
led mike7-Aug-07 10:14 
GeneralRe: Similar Images Pin
David Crow7-Aug-07 10:24
David Crow7-Aug-07 10:24 
GeneralRe: Similar Images Pin
led mike7-Aug-07 10:51
led mike7-Aug-07 10:51 
AnswerRe: Similar Images Pin
Hamid_RT7-Aug-07 19:12
Hamid_RT7-Aug-07 19:12 
QuestionVS 2008 Beta 2 with VS 2003/2005 Pin
redWingBB7-Aug-07 3:30
redWingBB7-Aug-07 3:30 
AnswerRe: VS 2008 Beta 2 with VS 2003/2005 Pin
toxcct7-Aug-07 3:57
toxcct7-Aug-07 3:57 
AnswerRe: VS 2008 Beta 2 with VS 2003/2005 Pin
Mark Salsbery7-Aug-07 5:09
Mark Salsbery7-Aug-07 5:09 
AnswerRe: VS 2008 Beta 2 with VS 2003/2005 Pin
#realJSOP8-Aug-07 0:10
professional#realJSOP8-Aug-07 0:10 
Questionabout RutTime Classes Pin
mt_samiei7-Aug-07 2:47
mt_samiei7-Aug-07 2:47 
Questionabout Runtime Class Pin
mt_samiei7-Aug-07 2:38
mt_samiei7-Aug-07 2:38 
AnswerRe: about Runtime Class Pin
Mark Salsbery7-Aug-07 5:10
Mark Salsbery7-Aug-07 5:10 
GeneralRe: about Runtime Class Pin
led mike7-Aug-07 6:06
led mike7-Aug-07 6:06 

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.