Click here to Skip to main content
15,884,176 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Empty array problem?! how to know if array empty or not? Pin
Gofur Halmurat25-Oct-07 10:09
Gofur Halmurat25-Oct-07 10:09 
AnswerRe: Empty array problem?! how to know if array empty or not? Pin
S_Murali25-Oct-07 20:12
S_Murali25-Oct-07 20:12 
QuestionLoad a resource script Pin
Demian Panello25-Oct-07 7:50
Demian Panello25-Oct-07 7:50 
AnswerRe: Load a resource script Pin
Mattias G25-Oct-07 8:39
Mattias G25-Oct-07 8:39 
GeneralRe: Load a resource script Pin
Demian Panello25-Oct-07 9:13
Demian Panello25-Oct-07 9:13 
GeneralRe: Load a resource script Pin
Mattias G25-Oct-07 10:12
Mattias G25-Oct-07 10:12 
GeneralRe: Load a resource script Pin
Demian Panello25-Oct-07 10:27
Demian Panello25-Oct-07 10:27 
Questionin order read using ifstream, i have to add ofstream after than do not know why??? Pin
kreena25-Oct-07 6:58
kreena25-Oct-07 6:58 
I am getting problem in ofstream and ifstream but only in vista envirnment with my visual studio 6.0 Visual C++ application.

I am trying to support drag and drop feature for my application vista. Instead of vertual lization i tried to save the drag and drop object file in the physical memory but When i am trying to ready the file if I do not create one more ofstream object it want read properly in vista. I can not write this kind of unknown code in my application. I need help to understand why my code required ofstream again after ifstream in order to read.

Where in one .cpp file producer application is creating one .txt file that has information of objects that is going to be dragged to the consumer application. That text file is created in the virtual memory so I changed the location to physical memory. as seen below.

That is all I have changed in producer side

CString fileNameWithoutPath = dbObjTransferID + ".txt";

/*char tmpPath[_MAX_PATH];*/
CString cTempPath= "C:\\Program Files\\Common Files\\";

//VERIFY(GetTempPath(_MAX_PATH, ctmpPath));

CString fullyQualifiedTmpFile;

fullyQualifiedTmpFile.Format("%s%s", cTempPath, fileNameWithoutPath);

ofstream outStream(fullyQualifiedTmpFile, ios::out | ios::trunc);

if (outStream.good())
{
Am_Default_Load_Save_Context.Reset();

Am_Default_Load_Save_Context.Save(outStream, Am_Value(listOfItemsToSave));

outStream.close();

*phGlobal = GlobalAlloc(GMEM_FIXED | GMEM_SHARE | GMEM_ZEROINIT,
fullyQualifiedTmpFile.GetLength() + 1);

const char * pStr = fullyQualifiedTmpFile;

memcpy(*phGlobal, pStr, fullyQualifiedTmpFile.GetLength());

bSuccess = TRUE;
}
else
bSuccess = FALSE;

IN THE CONSUMER SIDE:
I am opening the filed that I have created wich has object information and trying to read that file but if I do not put some ambiguious code in it, it want work without it. Once I try to create ifstream object to read that file, I HAVE TO CREATE ONE MORE OFSTREAM TO LET DATA READ CORRECTLY USING THE IFSTREAM FILE.

// copy the pFileName so that we can free the global memory.
CString fileName = pFileName;

GlobalUnlock(stgMedium.hGlobal);
GlobalFree(stgMedium.hGlobal);

ifstream inFile;
inFile.clear();
inFile.open(fileName, ios::in);

// This is the code I have to add in order to make drag and drop work.
// I DO NOT WHY ????
CString copyfileName = "C:\\dndNonUsedfile.txt";
ofstream nFile(copyfileName, ios::out);


if(inFile.good())
{

Am_Value amVal;
if(ReadTransferredDataFromFile(inFile, amVal))
if(amVal.Valid())
{
versionObj = amVal;

}
inFile.close();
CFile::Remove(fileName);

}

nFile.close(); //Code to support vista

Kreena Amin
Sr. software engineer

QuestionUsing XML in MFC Pin
LCI25-Oct-07 6:54
LCI25-Oct-07 6:54 
AnswerRe: Using XML in MFC Pin
led mike25-Oct-07 7:06
led mike25-Oct-07 7:06 
GeneralRe: Using XML in MFC Pin
LCI25-Oct-07 7:12
LCI25-Oct-07 7:12 
GeneralRe: Using XML in MFC Pin
LCI25-Oct-07 7:13
LCI25-Oct-07 7:13 
GeneralRe: Using XML in MFC Pin
led mike25-Oct-07 7:38
led mike25-Oct-07 7:38 
AnswerRe: Using XML in MFC Pin
Chris Losinger25-Oct-07 7:21
professionalChris Losinger25-Oct-07 7:21 
QuestionRe: Using XML in MFC Pin
David Crow25-Oct-07 8:45
David Crow25-Oct-07 8:45 
AnswerRe: Using XML in MFC Pin
bob1697225-Oct-07 17:13
bob1697225-Oct-07 17:13 
GeneralRe: Using XML in MFC Pin
kanduripavan25-Oct-07 18:36
kanduripavan25-Oct-07 18:36 
GeneralRe: Using XML in MFC Pin
bob1697226-Oct-07 3:08
bob1697226-Oct-07 3:08 
GeneralRe: Using XML in MFC Pin
kanduripavan26-Oct-07 6:15
kanduripavan26-Oct-07 6:15 
QuestionCToolTipCtrl on key press? Pin
dsclee25-Oct-07 6:19
dsclee25-Oct-07 6:19 
AnswerRe: CToolTipCtrl on key press? Pin
led mike25-Oct-07 6:34
led mike25-Oct-07 6:34 
GeneralRe: CToolTipCtrl on key press? Pin
dsclee26-Oct-07 0:49
dsclee26-Oct-07 0:49 
GeneralRe: CToolTipCtrl on key press? Pin
led mike29-Oct-07 6:22
led mike29-Oct-07 6:22 
Questioncalling a c++ ATL dll from a c++ test program Pin
ns25-Oct-07 5:51
ns25-Oct-07 5:51 
AnswerRe: calling a c++ ATL dll from a c++ test program Pin
led mike25-Oct-07 6:30
led mike25-Oct-07 6:30 

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.