Click here to Skip to main content
15,921,840 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionCSplitterWnd with MDI Child Windows Pin
Member 1327791131-Jul-17 3:25
Member 1327791131-Jul-17 3:25 
QuestionRe: CSplitterWnd with MDI Child Windows Pin
David Crow31-Jul-17 3:49
David Crow31-Jul-17 3:49 
AnswerRe: CSplitterWnd with MDI Child Windows Pin
Member 1327791131-Jul-17 5:49
Member 1327791131-Jul-17 5:49 
AnswerRe: CSplitterWnd with MDI Child Windows Pin
Member 1327791131-Jul-17 19:45
Member 1327791131-Jul-17 19:45 
QuestionGood or Bad Idea: C++ OpenGL Application using PureMVC? Pin
DBPatric29-Jul-17 5:38
DBPatric29-Jul-17 5:38 
AnswerRe: Good or Bad Idea: C++ OpenGL Application using PureMVC? Pin
leon de boer30-Jul-17 3:52
leon de boer30-Jul-17 3:52 
GeneralRe: Good or Bad Idea: C++ OpenGL Application using PureMVC? Pin
DBPatric9-Aug-17 13:49
DBPatric9-Aug-17 13:49 
GeneralRe: Good or Bad Idea: C++ OpenGL Application using PureMVC? Pin
leon de boer11-Aug-17 16:29
leon de boer11-Aug-17 16:29 
QuestionDeclare member variable on stack or heap Pin
_Flaviu24-Jul-17 21:06
_Flaviu24-Jul-17 21:06 
AnswerRe: Declare member variable on stack or heap Pin
Richard MacCutchan24-Jul-17 22:22
mveRichard MacCutchan24-Jul-17 22:22 
GeneralRe: Declare member variable on stack or heap Pin
_Flaviu24-Jul-17 23:03
_Flaviu24-Jul-17 23:03 
GeneralRe: Declare member variable on stack or heap Pin
Richard MacCutchan24-Jul-17 23:09
mveRichard MacCutchan24-Jul-17 23:09 
GeneralRe: Declare member variable on stack or heap Pin
_Flaviu25-Jul-17 0:13
_Flaviu25-Jul-17 0:13 
GeneralRe: Declare member variable on stack or heap Pin
Richard MacCutchan25-Jul-17 0:31
mveRichard MacCutchan25-Jul-17 0:31 
AnswerRe: Declare member variable on stack or heap Pin
Victor Nijegorodov24-Jul-17 23:15
Victor Nijegorodov24-Jul-17 23:15 
GeneralRe: Declare member variable on stack or heap Pin
_Flaviu25-Jul-17 0:09
_Flaviu25-Jul-17 0:09 
GeneralMessage Closed Pin
9-Aug-17 0:50
professionalHometurph Indi9-Aug-17 0:50 
GeneralRe: Declare member variable on stack or heap Pin
Victor Nijegorodov9-Aug-17 1:21
Victor Nijegorodov9-Aug-17 1:21 
QuestionIDirect3DSurface9 Problem after Windows 10 Update Creator Pin
002comp24-Jul-17 19:42
002comp24-Jul-17 19:42 
AnswerRe: IDirect3DSurface9 Problem after Windows 10 Update Creator Pin
Jochen Arndt24-Jul-17 21:19
professionalJochen Arndt24-Jul-17 21:19 
GeneralRe: IDirect3DSurface9 Problem after Windows 10 Update Creator Pin
002comp24-Jul-17 23:03
002comp24-Jul-17 23:03 
GeneralRe: IDirect3DSurface9 Problem after Windows 10 Update Creator Pin
002comp25-Jul-17 19:36
002comp25-Jul-17 19:36 
GeneralRe: IDirect3DSurface9 Problem after Windows 10 Update Creator Pin
Jochen Arndt25-Jul-17 20:57
professionalJochen Arndt25-Jul-17 20:57 
GeneralRe: IDirect3DSurface9 Problem after Windows 10 Update Creator Pin
002comp25-Jul-17 21:19
002comp25-Jul-17 21:19 
QuestionC++ ActiveX project worked with VB6, broken in later versions Pin
Burl Rice22-Jul-17 10:30
Burl Rice22-Jul-17 10:30 
I have an ActiveX control (written originally in VC6, and later upgraded to VC 2010). When we first released it, I included a VB6 demo program to show how to use it. This all still works.

Recently, a customer requested sample code in VB 2017, and I have found that it crashes in this environment. I have also checked VB 2015 and VB 2010, and they also crash in the same place.

Here is a simplified overview of the ActiveX library:

library BoxWriter
{
    interface ILine : IDispatch 
    {
        [propget, id(8), helpstring("property m_lCount")] HRESULT m_lCount([out, retval] long *pVal);
    };
    interface IPrinter : IDispatch
    {
        [propget, id(1), helpstring("property m_line")] HRESULT m_line([optional, defaultvalue ("")] BSTR strLine, [out, retval] ILine* *pVal);
    };
};


Here is a VB code snippet that causes the crash:

Dim printer As New BoxWriter.PRINTER
printer.Connect("192.168.1.3")
MsgBox(m_printer.m_line.m_lCount)    ‘ <—crashes here


This is the error it gives:
An unhandled exception of type 'System.AccessViolationException' occurred in demo.exe
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.



The reference returned by CPrinter::get_m_line seems to be what it is complaining about. When I debug, I see the reference is set correctly by CPrinter::get_m_line, but after the function returns, something is calling the destructor for the CLine class.

STDMETHODIMP CPrinter::get_m_line(BSTR bstrLine, ILine **pVal)
{ 
    AFX_MANAGE_STATE(AfxGetStaticModuleState())

    CString strLine = (LPCTSTR)_bstr_t (bstrLine);
    CComObject <CLine>* pLine = GetLine (strLine);

    if (!pLine) {
        return E_INVALIDARG;
    }

    * pVal = pLine;

    return S_OK;
}


I have tried creating a new ActiveX project in VC2010, and it also exhibits the same behavior. I tried returning the reference in several different ways (property vs method), and still have not been able to solve this. Surely I am not the first person to encounter this. Can anyone suggest how to fix this?

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.