Hi, I have an application built on VS2005 which uses a static library built using VS6.0. I have noticed an issue of incorrect function getting called from a static library linked at compiled time. Note that this static library was built using Visual Studio 6.0. Whereas my application which is using the static library for linking at compile time is built using VS2005. At run time, I see that incorrect/different functions are getting called rather than the ones which are supposed to get called. To solve this issue: I rebuilt the static library (.lib) using VS2005. Then this newly built static library was used for compilation along with my application on VS2005. Then the functions are getting called correctly. I have 2 questions here: :confused: 1) This means that if there is any static library built with older version of VS6.0, then it will not work correctly with an application built with VS2005. We need to rebuild it with the same compiler as the application is built with. Is this true? why this happens in case of static libraries? 2) If above point-1 is true, then isn't it necessary to rebuild DDLs also with VS2005? If no, then why it is ok that a DLL built with older version of compiler works fine with application built with newer compiler version?
funwithdolphin
Posts
-
Libraries and compiler compatibility -
OnInitDialog is not getting called from DoModal in VS2005 [modified]It is working fine now. I unregistered the ocx control, then rebuilt the control and then registered it with regsvr32.exe. Now OnInitDialog of CPpSelectDn is getting called. Also, the UI controls for LDAP directory browse are shown correctly on the page. It looks like earlier it had old incorrect version of ocx file registered, which needed unregistering and reregistering the new one. ;)
-
OnInitDialog is not getting called from DoModal in VS2005 [modified]Here is what I did with VS6.0: - As I mentioned earlier, it was working fine with VS6.0. So What I did now is , I created a fresh VS6.0 setup on a new machine and built the code. But when I tested, again I was facing same display problem as I was getting with VS2005. However, I saw below warnings in the VS6.0 output window:
CoCreateInstance of OLE control {395262A9-51B1-11D2-BA1B-00A02489AC7A} failed.
Result code: 0x800401f0
Is the control is properly registered?
Warning: CreateDlgControls failed during dialog init.So I registered the IsoDirB.ocx file using regsvr32.exe manually. Then when I tested the application with VS6.0, it worked correctly and the UI problem with Directory browser display was not there and everything worked just nicely. So this meant that if IsoDirB.ocx control is not registered, then I see UI problem with Directory browser display. ------------------------------------------------------------------- From above findings, I also registered the IsoDirB.ocx file using regsvr32.exe manually on VS2005 machine too. It didn't give any error when I registered IsoDirB.ocx using regsvr32.exe on VS2005 machine. Then when I tested the application. However, I am still seeing the same display problem with Directory browser display with VS2005. I see below warnings in the VS2005 output window:
'mm.exe': Loaded 'C:\Program Files\CriticalPath\Manager\IsoDirB.ocx', No symbols loaded.
First-chance exception at 0x77fac57c in mm.exe: 0xC0000139: Entry Point Not Found.
'mm.exe': Unloaded 'C:\Program Files\CriticalPath\Manager\IsoDirB.ocx'I am not sure how much important/relevance above warning has with the UI problem; but this might be important. I remember I made changes in build of IsoDirB.ocx code project and not sure if it is causing this first chance exception. Any inputs on investigating about this "Entry Point Not Found" warning are highly appreciated.
-
OnInitDialog is not getting called from DoModal in VS2005 [modified]I debugged. I see that it calls 'INT_PTR CPropertySheet:: DoModal()' which internally calls CPropertySheet::OnInitDialog(). Here is the stack trace in case this helps you in pointing out any clues: Code:
> mfc80u.dll!CPropertySheet::OnInitDialog() Line 1437 C++
mfc80u.dll!CPropertySheet::HandleInitDialog(unsigned int __formal=1052816, unsigned int __formal=1052816) Line 1455 C++
mfc80u.dll!CWnd::OnWndMsg(unsigned int message=272, unsigned int wParam=1052816, long lParam=1519392, long * pResult=0x00129744) Line 2194 + 0x8 bytes C++
mfc80u.dll!CWnd::WindowProc(unsigned int message=272, unsigned int wParam=1052816, long lParam=1519392) Line 1741 + 0x17 bytes C++
mfc80u.dll!AfxCallWndProc(CWnd * pWnd=0x84c820c4, HWND__ * hWnd=0x00171098, unsigned int nMsg=272, unsigned int wParam=1052816, long lParam=1519392) Line 243 C++
mfc80u.dll!AfxWndProc(HWND__ * hWnd=0x00171098, unsigned int nMsg=272, unsigned int wParam=1052816, long lParam=1519392) Line 388 + 0x10 bytes C++
mfc80u.dll!AfxWndProcBase(HWND__ * hWnd=0x00171098, unsigned int nMsg=272, unsigned int wParam=1052816, long lParam=1519392) Line 411 + 0x16 bytes C++
USER32.DLL!77e3a454()
[Frames below may be incorrect and/or missing, no symbols loaded for USER32.DLL]
USER32.DLL!77e14750()
USER32.DLL!77e155b0()
NTDLL.DLL!77f91baf()
USER32.DLL!77e16408()
USER32.DLL!77e29da0()
USER32.DLL!77e2cc1e()
USER32.DLL!77e3ed99()
SHLWAPI.DLL!70a9af09()
comctl32.dll!7176b0d7()
comctl32.dll!7174b366()
mfc80u.dll!AfxPropPageCallback(HWND__ * __formal=0x00000000, unsigned int message=0, _PROPSHEETPAGEW * pPropPage=0x00174648) Line 52 + 0x5 bytes C++
comctl32.dll!7174b959()
comctl32.dll!7174b5ef()
comctl32.dll!7174b601()
mfc80u.dll!CComCtlWrapper::_PropertySheetW(const _PROPSHEETHEADERW * unnamed1=0x00129bc4) Line 342 + 0x6e bytes C++
mfc80u.dll!CPropertySheet::DoModal() Line 961 C++
IsoGenU.dll!GetDistinguishedName(tagSELECTDN * lpsdn=0x0012a800) Line 137 + 0xb bytes C++I also saw that CPropertyPage::OnSetActive() was called by CPropertySheet:: DoModal(). As can be seen above, CPropertySheet::OnInitDialog() is getting called. However, OnInitDialog function of CPpSelectDn class is not getting called.
-
Customized BEGIN_TEMPLATE_MESSAGE_MAP with 2 template arguments for VS2005I looked at it. But it has Customized BEGIN_TEMPLATE_MESSAGE_MAP only for VC7. It doesn't have mention of Customized BEGIN_TEMPLATE_MESSAGE_MAP for VS2005/VC8.
-
Customized BEGIN_TEMPLATE_MESSAGE_MAP with 2 template arguments for VS2005Hi, I am getting below compiler error on Visual Studio 2005: isodirbrowserlistctrl.cpp(46) : error C2906: 'const AFX_MSGMAP *CListDataCtrl<B,T>::GetThisMessageMap(void)' : explicit specialization requires 'template <>' with [B=CListCtrl,T=CBrowserListCtrlData Here is the code with .h and .cpp files. This code used to compile and run fine on Visual Studio 6.0. I guess I need to use BEGIN_TEMPLATE_MESSAGE_MAP. But BEGIN_TEMPLATE_MESSAGE_MAP can not handle more than one template arguments. In my case, there are 2 template arguments.
// ListDataCtrl.h : header file
//
class CListDataBase
{
public:
CListDataBase() : m_iItem(-1), m_pCtl(0) {};
void SetControl(CListCtrl* pCtl) { m_pCtl = pCtl; }
CListCtrl* GetControl() { return m_pCtl; }
void SetItemNumber(int iItem) { m_iItem = iItem; }
int GetItemNumber() { return m_iItem; }protected:
int m_iItem;
CListCtrl *m_pCtl;
};
////////////////////////////////////////////////////////////////////////////
// CListDataCtrl windowtemplate <class B, class T>
class CListDataCtrl : public B
{
// Construction
public:
CListDataCtrl() {};
// Attributes
public:
// Operations
public:
T* GetListData(int iItem)
{
T *pResult = (T*) GetItemData(iItem);
return pResult;
}void DeleteListDataPrim(int iItem) { T\* pData = (T\*) GetItemData(iItem); delete pData; pData = 0; SetItemData(iItem, 0); } void DeleteListData(int iItem) { DeleteListDataPrim(iItem); } BOOL DeleteListNode(int iItem) { DeleteListData(iItem); return DeleteItem(iItem); } void SetListData(int iItem, T\* pData) { pData->SetItemNumber(iItem); pData->SetControl(this); DeleteListData(iItem); SetItemData(iItem, (DWORD) pData); } void DeleteAllListData() { int cMax = GetItemCount(); for (int i=0; i<cMax; i++) { delete (T\*) GetItemData(i); SetItemData(i, 0); } } void DeleteEntireList() { DeleteAllListData(); DeleteAllItems(); } T\* InsertItemData(LPCTSTR ptszText, int iItem, T\* pData = 0) { if (!pData) { pData = new T; } int iNewItem = InsertItem(iItem, ptszText); SetListData(iNewItem, pData); return pData; }
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CListDataCtrl)
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CListDataCtrl() {};
// Generated message map functions
protected:
//{{AFX_MSG(CListDataCtrl)
// NOTE - the ClassWizard will add and remove member -
OnInitDialog is not getting called from DoModal in VS2005 [modified]GenUtilLoadPropPage loads the Property Page having pageSelect.IDD. When I debugged, it was able to find the resource needed and FindResource() was successful. Wonder why it still does not call the OnInitDialog of CPpSelectDn class though.
ISOGENUTILS_DECL void GenUtilLoadPropPage(HINSTANCE hInst, CPropertyPage *pPage, int /*UINT*/ nIDTemplate)
{
ASSERT(hInst);
HRSRC hResInfo = ::FindResource(hInst, (LPCTSTR)nIDTemplate, (LPCTSTR)RT_DIALOG);
ASSERT(hResInfo);
HGLOBAL hDialogTemplate = ::LoadResource(hInst, hResInfo);
ASSERT(hDialogTemplate);
LPCDLGTEMPLATE pTemplate = (LPCDLGTEMPLATE)LockResource(hDialogTemplate);
ASSERT(pTemplate);
pPage->m_psp.dwFlags |= PSP_DLGINDIRECT;
pPage->m_psp.pResource = pTemplate;
pPage->SetHelpID(LOWORD((DWORD)nIDTemplate));
} -
OnInitDialog is not getting called from DoModal in VS2005 [modified]Hi, I am porting code from VS 6.0 to VS2005. However I am seeing that OnInitDialog() function is not getting called from DoModal() in VS2005. I already tried adding breakpoints and messagebox to see if OnInitDialog function of CPpSelectDn class is getting called. However I found that it is not getting called.
// PpSelectDn.h : header file
//
#include "isodirbrowser.h"
#include "IsoCommonCtl.h"/////////////////////////////////////////////////////////////////////////////
// CPpSelectDn dialogclass CPpSelectDn : public CPropertyPage
{
DECLARE_DYNCREATE(CPpSelectDn)public:
class CContextInfo
{
public:
SELECTDN sdn;
};// Construction
public:
CContextInfo* m_pInfo;
CPpSelectDn();
CPpSelectDn(CContextInfo *pInfo);
~CPpSelectDn();// Dialog Data
//{{AFX_DATA(CPpSelectDn)
enum { IDD = IDD_ISOCMN_SELECTDN };
CStatic m_edtBrowserPrompt;
CString m_csBrowserPrompt;
CIsoDirBrowser m_ctlBrowser;
//}}AFX_DATA// Overrides
// ClassWizard generate virtual function overrides
//{{AFX_VIRTUAL(CPpSelectDn)
public:
virtual BOOL OnApply();
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL// Implementation
protected:
virtual BOOL OnInitDialog();
DECLARE_MESSAGE_MAP()};
// PpSelectDn.cpp : implementation file
//#include "stdafx.h"
#include "resource.h"
#include "PpSelectDn.h"
#include "IsoGenericMfc.h"
IMPLEMENT_DYNCREATE(CPpSelectDn, CPropertyPage)CPpSelectDn::CPpSelectDn() :
CPropertyPage(CPpSelectDn::IDD)
{
}CPpSelectDn::CPpSelectDn(CContextInfo *pInfo) :
CPropertyPage(CPpSelectDn::IDD),
m_pInfo(pInfo)
{
//{{AFX_DATA_INIT(CPpSelectDn)
m_csBrowserPrompt = _T("");
}CPpSelectDn::~CPpSelectDn()
{
}void CPpSelectDn::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPpSelectDn)
DDX_Control(pDX, IDC_ISOCMN_SELDNPROMPT, m_edtBrowserPrompt);
DDX_Text(pDX, IDC_ISOCMN_SELDNPROMPT, m_csBrowserPrompt);
DDX_Control(pDX, IDC_ISOCMN_DIRBROWSER, m_ctlBrowser);
//}}AFX_DATA_MAP
}BEGIN_MESSAGE_MAP(CPpSelectDn, CPropertyPage)
//{{AFX_MSG_MAP(CPpSelectDn)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
// CPpSelectDn message handlersBOOL CPpSelectDn::OnInitDialog()
{
CPropertyPage::OnInitDialog();
SetFontDynamically(this -
delete or delete [ ]??In the following code snippet which delete should I use?? char *ptr1=new char[100]; char arr[10]="abcdefghi"; strcpy(ptr1,arr); //delete ptr1; delete []ptr1; Should I use delete ptr1; or delete []ptr1;
-
Virtual constructors...Why Virtual constructors are not allowed in C++??
-
Abstract Base classes vs InterfacesCan anybody tell me the difference between Abstract Base classes vs Interfaces??