Click here to Skip to main content
16,005,552 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Reading blank lines Pin
ThatsAlok15-Apr-05 18:11
ThatsAlok15-Apr-05 18:11 
GeneralRe: Reading blank lines Pin
eli1502197916-Apr-05 0:03
eli1502197916-Apr-05 0:03 
GeneralRe: Reading blank lines Pin
nilkn16-Apr-05 5:40
sussnilkn16-Apr-05 5:40 
GeneralRe: Reading blank lines Pin
eli1502197916-Apr-05 20:45
eli1502197916-Apr-05 20:45 
GeneralRe: Reading blank lines Pin
ng kok chuan17-Apr-05 15:23
ng kok chuan17-Apr-05 15:23 
GeneralNon-trivial Image Display Pin
LighthouseJ15-Apr-05 12:55
LighthouseJ15-Apr-05 12:55 
GeneralShared Memory Residue Pin
Grahamfff15-Apr-05 11:44
Grahamfff15-Apr-05 11:44 
GeneralC++ Interop Debugger Issue Pin
Chip Patton15-Apr-05 11:37
Chip Patton15-Apr-05 11:37 
Apparently the Visual Studio 2003 debugger sometimes has trouble keeping up with what's happening in memory. I was trying to do some Interop via C++ Managed Extensions to some legacy code (unmanaged) that allocates an object and returns a pointer to it. While stepping through in the debugger it appears that the data is not returned, when in fact it is. If you build and run the following code, put in a breakpoint where indicated and try to look at what pData points to, it will appear to be undefined, but in fact it is there.

(GetData2() shows it properly, it is effected by what should be a superfluous "new"; if anyone knows that something else is going on, please tell me. Thanks.)

// This is the main project file for VC++ application project
// generated using an Application Wizard.

#include "stdafx.h"
#include <time.h>

#pragma unmanaged

class CData
{
public:

int nId;
int nData;

CData()
{
nId = time(0);
nData = 14;
}
};


class DataAccess
{
public:

void ReadData(CData ** data)
{
CData *pUnmanData = new CData();

*data = pUnmanData;
}

};

#pragma managed

using namespace System;
using namespace System::Threading;
using namespace System::Runtime::InteropServices;

[CLSCompliant(true)]
public __gc class Data_Managed
{
public:

int nId_Managed;

void GetData()
{
DataAccess dataAccess;

CData *pData;

//pData = NULL;

dataAccess.ReadData(&pData);

nId_Managed = pData->nId; // Put Break Point Here <<<<<<


}

void GetData2()
{
DataAccess dataAccess;

CData *pData;

pData = new CData();

dataAccess.ReadData(&pData);

nId_Managed = pData->nId;


}
};

#using <mscorlib.dll>

using namespace System;

int _tmain()
{
// TODO: Please replace the sample code below with your own.
Console::WriteLine(S"Hello World");

Data_Managed * data_Managed;

data_Managed = new Data_Managed();

data_Managed->GetData();

Console::Write(S"Id= " );
Console::WriteLine( data_Managed->nId_Managed.ToString() );


data_Managed->GetData2();

Console::Write(S"Id= " );
Console::WriteLine( data_Managed->nId_Managed.ToString() );

return 0;
}

-- Chip Patton
GeneralHID class Pin
trupgmtuf15-Apr-05 11:13
susstrupgmtuf15-Apr-05 11:13 
GeneralMenu Item capture Pin
Al_Pennyworth15-Apr-05 10:35
Al_Pennyworth15-Apr-05 10:35 
GeneralRe: Menu Item capture Pin
Ravi Bhavnani15-Apr-05 10:49
professionalRavi Bhavnani15-Apr-05 10:49 
GeneralRe: Menu Item capture Pin
Al_Pennyworth15-Apr-05 11:45
Al_Pennyworth15-Apr-05 11:45 
GeneralRe: Menu Item capture Pin
Ravi Bhavnani15-Apr-05 11:57
professionalRavi Bhavnani15-Apr-05 11:57 
GeneralRe: Menu Item capture Pin
liquid_15-Apr-05 21:21
liquid_15-Apr-05 21:21 
GeneralCHTMLView again Pin
#realJSOP15-Apr-05 9:58
professional#realJSOP15-Apr-05 9:58 
GeneralRe: CHTMLView again Pin
Ravi Bhavnani15-Apr-05 10:55
professionalRavi Bhavnani15-Apr-05 10:55 
GeneralRe: CHTMLView again Pin
dabs15-Apr-05 15:34
dabs15-Apr-05 15:34 
GeneralChange Colour of CEdit on Dialog Bar Pin
Cliff Hatch15-Apr-05 9:52
Cliff Hatch15-Apr-05 9:52 
GeneralRe: Change Colour of CEdit on Dialog Bar Pin
Jack Puppy15-Apr-05 13:43
Jack Puppy15-Apr-05 13:43 
GeneralRe: Change Colour of CEdit on Dialog Bar Pin
Cliff Hatch16-Apr-05 2:07
Cliff Hatch16-Apr-05 2:07 
GeneralCustomDraw issue in XP Pin
Brad Bruce15-Apr-05 8:27
Brad Bruce15-Apr-05 8:27 
GeneralNew .cpp/.h files in Microsoft Visual C++ .NET Pin
Dr Dan15-Apr-05 8:11
Dr Dan15-Apr-05 8:11 
GeneralRe: New .cpp/.h files in Microsoft Visual C++ .NET Pin
Alex Korchemniy15-Apr-05 8:35
Alex Korchemniy15-Apr-05 8:35 
QuestionOwnerdraw Listbox won't send WM_DRAWITEM??? Pin
KellyR15-Apr-05 7:50
KellyR15-Apr-05 7:50 
AnswerRe: Ownerdraw Listbox won't send WM_DRAWITEM??? Pin
KellyR15-Apr-05 8:24
KellyR15-Apr-05 8:24 

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.