|
Hi, in my application,when i opened my application i have to enter in tot that by using username.After i closed the application it will create a bacttrack file with the details of user name and timings.For each entry it will write the details in file.And i will show this details in my dialog in ListControl.It reads the details from file and displayed it.Its working fine.But my problem is when the same user entered in to application the file should write all the users.But ListControl shows only the new user.I mean if "A" entered first time and if he enterd second time the ListControl should shows only the updated timings that is last entry only.How can i do this?
Anu
|
|
|
|
|
can you show code, how you are reading from file ?
|
|
|
|
|
You want a name and a detail of each user
for example user1 1:20 user1 1:22 user1 1:23
but in the listbox you want last time of user user1 1:23,right?
|
|
|
|
|
yes, I want to update already entry user.My code is
void CLogFileInfo::UpdateListCtrl()
{
FILE *fpLogInfo;
Fname=_T("");
Instr=_T("");
ModelPeriod=_T("");
Model=_T("");
sno=1;
cnt=1;
char Sno[10];
CString GlbFNamePath2;
char LogList[200];
pCtrl->DeleteAllItems();
GlbFNamePath2 = gsInstallPath + "\\Esim\\sys\\" + "LogInfo.txt";
if ((fpLogInfo=fopen((LPCTSTR)GlbFNamePath2, "r"))!=NULL)
{
while(fgets(LogList,100,fpLogInfo)!=NULL)
{
RowIndex=sno-1;
sprintf(Sno,"%d",sno);
ReadStr =LogList;
ReadStr.TrimRight();
if (cnt==1)
Fname=ReadStr;
if (cnt==2)
Instr=ReadStr;
if (cnt==3)
Traine=ReadStr;
if (cnt==4)
ModelName=ReadStr;
if (cnt==5)
Model=ReadStr;
if(cnt>=5)
{
Index=pCtrl->InsertItem(RowIndex,Sno);
pCtrl->SetItemText(Index,1,Fname);//"LogFile" or "LogFIle_username"
pCtrl->SetItemText(Index,2,Instr);//Instructor name
pCtrl->SetItemText(Index,3,Traine);//Trainee name
pCtrl->SetItemText(Index,4,ModelPeriod);//2 hours
pCtrl->SetItemText(Index,5,Model);//Boiler or Suction...
cnt=1;
sno+=1;
newsno=sno;
}
else
{
cnt=cnt+1;
}
}
fclose(fpLogInfo);
}
}
In this coding it list all entries in to ListControl..
Here FName is for users entry identification.Common users entry with just "LogFile" FName and some registered people enter with "LogFile_username"... i want to replace the LogFile entry at each entry and LogFile_username is entered as it is ..ok I hope u get my points
Anu
|
|
|
|
|
well for this purpose when you want to insert a value to exist values first check is this value exist in this file
or no if yes then you can overwrite exist value but i think your code has a problem if your file is 10MB and value is in the end file do you have any idea?
|
|
|
|
|
As known, we can use DeviceCapabilities with DC_PAPERS Retrieves a list of supported paper sizes. My question is: how do we retrieve the list of default page margins for each paper size?
This should be doable because the preview image inside the page setup dialog (eg in Notepad) displays different margins for different paper size selection.
I tried this approach but it didn't work:
(1) Use SetPrinter to change the paper size (see "Set up/change printer orientation and select paper type/size" By AlexEvans )
(2) Use GetDeviceCaps() with PHYSICALOFFSETX and PHYSICALOFFSETY to get left and top margins. But it didn't give me correct info (eg, it gives me 0 for A3 paper).
I really want to know how MFC's CPageSetupDialog is able to do that, but I haven't been able to find it out.
Thanks all for help!
|
|
|
|
|
Dear,
As i posted some days before, I want to use my program to copy files from a share folder in another computer in LAN. I tried to use the LogonUser() function but it worked only at localhost (127.0.0.1) with only current account. Please help me in this. I am using C non-MFC.
Thanks a lot.
-- modified at 5:08 Monday 21st August, 2006
Sincerely
Thangnvhl
|
|
|
|
|
See here[^] maybe it is some helpful to you
|
|
|
|
|
Hi all,
I'm wondering if turning on the /GS- switch (that's the Buffer Security Check option, it's used to prevent Buffer Overrun) make the final binary code run slower?
Environment:
1.) In pure WIN32 with C++ code. (native apps)
2.) Release build.
3.) WinXP /w SP2.
Thanks.
|
|
|
|
|
Link2006 wrote: I'm wondering if turning on the /GS- switch (that's the Buffer Security Check option, it's used to prevent Buffer Overrun) make the final binary code run slower?
Compile with and without the switch and then investigate...
too much daily WTF for someone... - Anton AfanasyevLast modified: Monday, August 21, 2006 2:50:09 PM -- Did a test program and it made no difference in speed or size.
|
|
|
|
|
PaulC1972 wrote: Compile with and without the switch and then investigate...
I can't tell the difference, maybe that's because both of my machines are rather fast, and my low-end PC is installed with Linux, so I can't test it on that machine.
I'm going to leave that switch on for now.
|
|
|
|
|
Did you notice the modification that I had to my post. I didn't find any difference between the two executables generated with and without the switch. Speed and size were the same. Running a diff between the two executables says they differ
too much daily WTF for someone... - Anton Afanasyev
|
|
|
|
|
PaulC1972 wrote: Did you notice the modification that I had to my post.
Nope, I didn't. The font is too small, I didn't notice it at first until you mentioned it.
|
|
|
|
|
I'm using VC6 SP6 and having nothing but trouble with it these days. I get random break points in my code that I cannot remove, it crashes daily, sometimes it locks during a build cycle. And now, it won't even break at a breakpoint. This is a fresh install too...
Anybody else having similar problems with VC6?
I already have VC7.1 but I'm a little worried it will corrupt my project if I port it over. How does 7 compare to 6?
|
|
|
|
|
Hmmm. When was the last time you did a full rebuild? VS has been known to get confused after a period of usage.
waldermort wrote: How does 7 compare to 6?
It depends. If you are using the stl in V6, then you may have to do some code revision changes. There are also some (minor) compatibility changes wrt message maps etc. So you may not get a smooth 1-1 conversion. However you can it on a copy of your project.
I Dream of Absolute Zero
|
|
|
|
|
6 is supposed to be rock solid compared to 7 and 8, as far as the IDE is concerned! Haven't used VC 6 for 18 months and don't know which SP it was on either.
Kevin
|
|
|
|
|
I use VC6 all day every day on multiple projects and never have any of these problems. Have you tried to a "Clean"?
|
|
|
|
|
VC6 SP6 doing fine over here. Intellisense was always a bit moody (VC++ 7.1 has occasional fits as well when using GDI+ in an MFC project) and ClassView would occasionally quit showing a class after adding a method but nothing that deleting the .ncb or .clw wouldn't fix but I believe those issues were also from before SP6.
waldermort wrote: How does 7 compare to 6?
One of the polls in the last couple of years seemed to indicate that not too many of us use 7. That probably indicates something negative but I've never used it myself to be fair.
|
|
|
|
|
The following errors are returned when I try to use (ios::good == true) as opposed to (ios::good != false)
Code:
void CSentenceAr::readFile(char strFileToRead[MAX_FILENAME_LENGTH])
{
char strLine[MAX_SENTENCE_LENGTH + 1];
fstream fileToRead(strFileToRead,ios::in);
if (ios::good == false) // OR if (ios::good == TRUE)
//which is defined as '1' in afx.h
{while (!fileToRead.eof() && Size < MAX_LINES)
// Read line of text from file and update Sentences.strSentence.
{ fileToRead.getline(strLine, MAX_SENTENCE_LENGTH);
strcpy(Sentences.strSentence[Size], strLine);
Size++;
}
}
fileToRead.close();
}
Errors:
SentenceAr.cpp(31): warning C4805: '==' : unsafe mix of type 'bool (__thiscall std::ios_base::* )(void) const' and type 'bool' in operation
SentenceAr.cpp(31): error C2446: '==' : no conversion from 'int' to 'bool (__thiscall std::ios_base::* )(void) const'
SentenceAr.cpp(31): error C2040: '==' : 'bool (__thiscall std::ios_base::* )(void) const' differs in levels of indirection from 'int'
This works though:
{
char strLine[MAX_SENTENCE_LENGTH + 1];
fstream fileToRead(strFileToRead,ios::in);
bool isItGood = ios::good;
if (ios::good != false)
{while (!fileToRead.eof() && Size < MAX_LINES)
// Read line of text from file and update Sentences.strSentence.
{ fileToRead.getline(strLine, MAX_SENTENCE_LENGTH);
strcpy(Sentences.strSentence[Size], strLine);
Size++;
}
}
fileToRead.close();
}
The IDE returns isItGood as having a 'true' value.
Jon
|
|
|
|
|
|
Actually the program hangs when I try it that way. Do I have a weird VS2003 version perhaps?
Jon
|
|
|
|
|
I am using VC++ 5.0, MFC, single document. The clipboard icon on my document lights up when there is something in the clipboard. How does it know? Can I get an event message for the clipboard change?
Thanks
|
|
|
|
|
|
|