Click here to Skip to main content
15,912,069 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Listctrl validation Pin
Ravi Bhavnani27-Mar-03 2:27
professionalRavi Bhavnani27-Mar-03 2:27 
GeneralWord and MailingLabel question Pin
Gunnar Mätzler26-Mar-03 3:17
Gunnar Mätzler26-Mar-03 3:17 
GeneralAssigning a class name to a dialog based app Pin
jerry0davis26-Mar-03 1:17
jerry0davis26-Mar-03 1:17 
GeneralRe: Assigning a class name to a dialog based app Pin
Cristi26-Mar-03 3:13
Cristi26-Mar-03 3:13 
GeneralRe: Assigning a class name to a dialog based app Pin
jerry0davis26-Mar-03 4:57
jerry0davis26-Mar-03 4:57 
GeneralRe: Assigning a class name to a dialog based app Pin
Cristi26-Mar-03 21:34
Cristi26-Mar-03 21:34 
Generalread the recording volume Pin
Willem B26-Mar-03 0:41
Willem B26-Mar-03 0:41 
GeneralWhy i am getting ASSERT file name: WinCore.cpp linenumber: 312 Pin
Member 10566626-Mar-03 0:29
Member 10566626-Mar-03 0:29 
I am getting an assertion error at file WinCore.cpp at linenumber 312 while subclassing the frame window. This frame window is single document view widows which contain the Rich edit view and document. This Framewindow is in a exe module. I am trying to subclass this window with a class that is declared in a dll and derived from CWnd class.
The dll is a extension dll which is loaded at run time and there is one exportable function “AddplugIn” and class declaration derived form CWnd class.

Here is the code, where the dll is loaded at runtime using AfxLoadLibrary method and the call of the AddPlugIn method.

The address of the main frame window is passed to the dll. The code is as fallows
BOOL CNCStudioUIApp::InitInstance()
{
// Initialize OLE libraries
if (!AfxOleInit())
{
AfxMessageBox(IDP_OLE_INIT_FAILED);
return FALSE;
}

const char* plugin = "NCStudioPluginD.dll";
hPlugin = AfxLoadLibrary(plugin);
if(hPlugin == NULL)
{
MessageBox(“Failed to load the dll”);
Return FALSE;
}

AfxEnableControlContainer();

#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif

// Change the registry key under which our settings are stored.
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings(); // Load standard INI file options (including MRU)

// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.

CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CNCStudioUIDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CNCStudioUIView));
pDocTemplate->SetContainerInfo(IDR_CNTR_INPLACE);
AddDocTemplate(pDocTemplate);

// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);

// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;

CMenu* pMenu = m_pMainWnd->GetMenu();
NCStudio::CNCStudioDLL uiDll;

typedef BOOL (PLUGINPROC)(NCStudio::CNCStudioDLL&);
m_pMainWnd->ShowWindow(SW_SHOW);
uiDll.setMenu(pMenu);
uiDll.setFrameWnd(GetMainWnd());

PLUGINPROC* pFunction = (PLUGINPROC *)GetProcAddress(hPlugin, "AddPlugin");
if(pFunction != NULL)
{
BOOL bSuccess = (*pFunction)(uiDll); //AddPlugin method call
if(bSuccess)
{
m_pMainWnd->DrawMenuBar();
TRACE("Successfully added the plugin");
}
}
// The one and only window has been initialized, so show and update it.
m_pMainWnd->UpdateWindow();
return TRUE;
}

In the dll I am subclassing the frame window the code like this


extern "C"
{ PLUGIN_EXP_IMP BOOL AddPlugin(CNCStudioDLL& ui)
{
//subclassing window

CWnd* pMainWnd = ui.getFrameWnd();

if (!ncPlugIn.SubclassWindow(pMainWnd->GetSafeHwnd()))
// ncPlugIn is the object declared globally in the dll it is the object of a class derived from CWnd. Here I am getting the above assertion error
{
TRACE("Failed to subclass client window\n");
return -1; // fail to create
}
return true
}

Please, Can any body tell me why I am getting this assertion and what is the wrong in my code and tell me how I can avoid it.

GeneralRe: Why i am getting ASSERT file name: WinCore.cpp linenumber: 312 Pin
Roger Allen26-Mar-03 2:24
Roger Allen26-Mar-03 2:24 
Questionhas ANYBODY ever written an addin in VS.NET???? Pin
schaereran@gmx.net25-Mar-03 22:53
schaereran@gmx.net25-Mar-03 22:53 
GeneralMultiple Views in a SDI project Pin
Anonymous25-Mar-03 22:37
Anonymous25-Mar-03 22:37 
GeneralRe: Multiple Views in a SDI project Pin
DREVET Olivier26-Mar-03 0:53
DREVET Olivier26-Mar-03 0:53 
GeneralMultiple Views in a SDI project Pin
Anonymous25-Mar-03 22:15
Anonymous25-Mar-03 22:15 
QuestionHow To Detect Proxy Settings and Manipulate them Pin
Vikrant Kapoor25-Mar-03 21:49
Vikrant Kapoor25-Mar-03 21:49 
AnswerRe: How To Detect Proxy Settings and Manipulate them Pin
Joaquín M López Muñoz25-Mar-03 22:13
Joaquín M López Muñoz25-Mar-03 22:13 
GeneralRe: How To Detect Proxy Settings and Manipulate them Pin
John-theKing26-Mar-03 2:06
John-theKing26-Mar-03 2:06 
GeneralRe: How To Detect Proxy Settings and Manipulate them Pin
Joaquín M López Muñoz26-Mar-03 2:28
Joaquín M López Muñoz26-Mar-03 2:28 
GeneralRe: How To Detect Proxy Settings and Manipulate them Pin
John-theKing26-Mar-03 20:00
John-theKing26-Mar-03 20:00 
GeneralRe: How To Detect Proxy Settings and Manipulate them Pin
Joaquín M López Muñoz26-Mar-03 20:10
Joaquín M López Muñoz26-Mar-03 20:10 
GeneralRe: How To Detect Proxy Settings and Manipulate them Pin
John-theKing26-Mar-03 20:15
John-theKing26-Mar-03 20:15 
Questionhow to add entry to personnel address book programatically Pin
Alfred25-Mar-03 21:38
Alfred25-Mar-03 21:38 
GeneralProblem drawing transparent bitmap using DrawTransparentBitmap exisitng ONLY in Win98 16bit color Pin
lob25-Mar-03 21:12
lob25-Mar-03 21:12 
GeneralRe: Problem drawing transparent bitmap using DrawTransparentBitmap exisitng ONLY in Win98 16bit color Pin
lob27-Mar-03 0:54
lob27-Mar-03 0:54 
GeneralRe: Problem drawing transparent bitmap using DrawTransparentBitmap exisitng ONLY in Win98 16bit color Pin
John R. Shaw28-Mar-03 18:13
John R. Shaw28-Mar-03 18:13 
GeneralRe: Problem drawing transparent bitmap using DrawTransparentBitmap exisitng ONLY in Win98 16bit color Pin
lob28-Mar-03 22:48
lob28-Mar-03 22:48 

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.