I added a helpAbout menu item to my mfc app. I decided to make the ddlg derive from CDHTMLDialog.
I override the OnInitDialog() method in my derived class and the first thing I do is call the parent's OnInitDialog() method.
I then put in code that sets the title.
On some machines this works fine, but on others it crashes in the call to
CDHtmlDialog::OnInitDialog() - Trying to read a null pointer.
the call stack has nothing useful - it is in mfc90.dll
Is this a potential problem with mismatches of mfc/win32 dlls?
It works on my vista machines but crashes on a win2003 server box.
BOOL HTMLAboutDlg::OnInitDialog()
{
// CRASHES on the following line
CDHtmlDialog::OnInitDialog();
CString title = "my title"; // example of setting title
... other code
SetWindowText(title);
return TRUE; // return TRUE unless you set the focus to a control
}
And here is the relevant header file:
class HTMLAboutDlg : public CDHtmlDialog
{
DECLARE_DYNCREATE(HTMLAboutDlg)
public:
HTMLAboutDlg(CWnd* pParent = NULL); // standard constructor
virtual ~HTMLAboutDlg();
// Overrides
HRESULT OnButtonOK(IHTMLElement *pElement);
HRESULT OnButtonCancel(IHTMLElement *pElement);
// Dialog Data
enum { IDD = IDD_DIALOG_ABOUT, IDH = IDR_HTML_HTMLABOUTDLG };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual BOOL OnInitDialog();
DECLARE_MESSAGE_MAP()
DECLARE_DHTML_EVENT_MAP()
};
I can't figure out what is going on - specifically why it works on some machines and crashes on others.
Both have VS2008 installed
Visual Studio reports the following for each machine:
VISTA - no crashes 9.0.30729.1 SP
2003 server: (crashes) 9.0.21022.8 RTM
EDIT - html code
<HTML>
<BODY ID=HTMLAboutDlg BGCOLOR=WHITE>
<TABLE WIDTH=100%>
<TR WIDTH=100% HEIGHT=75>
<TD ALIGN=CENTER VALIGN=TOP>
<font color="#707880">by </font><a ID=LinkCP target=_blank href='http://www.mywebsite.com'><font color="#000000">my</font><font color="#2554C7">web</font><font color="#7093DB">site</font></a>
</TD>
</TR>
<TR>
<TD ALIGN=RIGHT ALIGN=BOTTOM>
<BUTTON STYLE="WIDTH:80" ID="ButtonOK">OK</BUTTON><BR>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>