|
Assuming your ifile->eof() function performs a valid test for end of file, try it this way:
bool pPolyhedra::getfield(char *fieldname, CString& out)
{
BOOL bFoundField = FALSE;
while (!ifile->eof())
{
ifile->getline(linebuffer, 255, '\n');
a = linebuffer;
if (a.Find(fieldname) == -1)
{
bFoundField = TRUE;
break;
}
}
if (!bFoundField)
{
return FALSE;
}
ifile->getline(linebuffer, 255, '\n');
out = linebuffer;
out.TrimRight();
return true;
}
If it were me, I'd also use the MFC CStdioFile class for reading the file.
|
|
|
|
|
Hi,
I'm creating an NT Service class. I'm having trouble making it shutdown.
It responds to the SERVICE_CONTROL_STOP message okay but when it receives the SERVICE_CONTROL_SHUTDOWN message it doesn't terminate at all.
I'm running it on NT Server 4.0 no service packs.
Does anyone know of anything special I need to do to shutdown my service. Any help would be appreciated.
Thanks for reading.
Flit.
|
|
|
|
|
Hi there!
I have created an owner-drawn listbox which I am using to wrap text in the same string onto a new line, so that all of the lines containing the string can be selected at once.
However, I cannot seem to use tabstops!? Guessing it is to do with the fact that it is an ownerdrawn listbox...?
Anyway, I don't know where to handle this issue - the MFC code and MSDN are crap and don't mention anything about this, in the context of ownerdrawn stuff. Can anyone help please?
Yours very frustratedly!
Baz
|
|
|
|
|
Did you specified DT_EXPANDTABS flag in call to DrawText inside OnDrawItem handler?
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Cheers for that! Got it sorted now...
|
|
|
|
|
Hello, I'm trying to hide that messageboxes, using:
SetErrorMode(SEM_FAILCRITICALERRORS);
this makes some of the messageboxes to appear, I've thought to use:
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
but then I get worse results, how should I do this?
Note: after all the process the system hangs.
Notes about the process:
CreateFile(...);
CreateDirectory(...);
for (...) { CopyFile(...); }
CloseHandle(...);
As always, thank you in advance.
|
|
|
|
|
It may be not related to the msgbox problem, but why are you keeping some file open during series of CopyFile calls?
Please post code with real parameters instead of "..."; This will make diagnosing easier.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
uiErrorModeANT = SetErrorMode(SEM_FAILCRITICALERRORS);
hArxiuLog = CreateFile (filename,GENERIC_WRITE,FILE_SHARE_WRITE | FILE_SHARE_READ,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_ARCHIVE,NULL);
if (hArxiuLog != INVALID_HANDLE_VALUE)
{
dwFileSize = GetFileSize(hArxiuLog,NULL);
SetFilePointer (hArxiuLog, dwFileSize, NULL, FILE_BEGIN);
::CreateDirectory(TCCApp.GetAccesRegistre()->GetRefsPathRespatllar(),NULL);
::CreateDirectory(TCCApp.GetAccesRegistre()->GetProgramesPathRespatllar(),NULL);
iLimit = dlgPare->m_clbRestantsRespatllar.GetCount();
while ((iComptador < iLimit) && (!dlgPare->m_bCancelThread) && (!bTrobatError))
{
dlgPare->m_clbRestantsRespatllar.GetText(0,dlgPare->m_vstatRespatllantACT);
dlgPare->m_clbRestantsRespatllar.DeleteString(0);
dlgPare->UpdateData(FALSE);
dlgPare->m_clbRestantsRespatllar.RedrawWindow();
// the paths change in each loop iteration (here's not that piece of code...
iRetornOperacioCopia = CopyFile(csFullPathOrigenReferencia, csFullPathDestiReferencia, FALSE);
if (iRetornOperacioCopia == 0)
{
iErrorsTrobats++;
csAuxiliar += " : registrado error en éste proceso";
bTrobatError = true;
}
iComptador++;
}
// Posicionar el punter en l'arxiu (anar al final...)
dwFileSize = GetFileSize(hArxiuLog,NULL);
SetFilePointer (hArxiuLog, dwFileSize, NULL, FILE_BEGIN);
// csArxiuLog is a String that changes in each copy operation.
WriteFile(hArxiuLog,csArxiuLog,strlen(csArxiuLog),&dwNBWritten,NULL);
CloseHandle(hArxiuLog);
csArxiuLog.ReleaseBuffer(0);
}
// Get back to the original err mode.
SetLastError(0);
SetErrorMode(uiErrorModeANT);
|
|
|
|
|
when exactly messageboxes are displayed? During CopyFile?
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Hello, I'm trying to get some data written into the registry when the user updates a password in my app.
I'm using:
RegOpenKeyEx(HKEY_LOCAL_MACHINE,csPathSubClau,0,KEY_ALL_ACCESS,&Key);
RegSetValueEx(hKey,csValor,0,REG_SZ,(BYTE *)csNouValor.GetBuffer(iLength),iLength);
RegFlushKey(hKey);
RegCloseKey(hKey);
but the data is only flushed when I close my app, could you give me an idea?
thank you in advance.
|
|
|
|
|
I want to extract the first char from a string and test if it is equal to an int in a for loop.
char c;
for (int i=1, i
|
|
|
|
|
cast it.
Christian
I've learned that you cannot make someone love you. All you can do is stalk them and hope they panic and give in.
The early bird may get the worm, but it's the second mouse that gets the cheese.
|
|
|
|
|
how to ?
tried this
for ((int)c == i)
it still doesnt work....
|
|
|
|
|
Oh, I see. The code snippet you posted was broken, so I didn't spot exactly what you wanted to do. I just compiled this no worries:
<br />
<br />
char c = 'c';<br />
<br />
for (int i = 0; i < 255;i++)<br />
{<br />
if ( i == (int)c) break;<br />
}<br />
<br />
for (int j = 0; j < i; j++)<br />
printf("c");<br />
so I'd suggest you create a new int, and make it equal to (int) c, then make a loop of it. If ( as I assume, otherwise there would be no point ) you want to output this character, you need merely say c = z ( assuming z is the (int) of c to start with in the loop ) and it should work. You MAY need to make c a char * with two elements to ensure element 2 is a 0 though.
Christian
I've learned that you cannot make someone love you. All you can do is stalk them and hope they panic and give in.
The early bird may get the worm, but it's the second mouse that gets the cheese.
|
|
|
|
|
You don't need to do anything. The char will be implicitly converted to an int (look up "integral promotion" in your help docs) to do the comparison.
--Mike--
http://home.inreach.com/mdunn/
Tables, ladders, chairs, OH MY!
|
|
|
|
|
Someone can tell me the exact role of this ?
Thank
Yuri
|
|
|
|
|
Hi folks,
i have an environment where the server is unix and the workstations are Windows NT. Now the admin wants to send smtp-messages to the workstations. (like "i will shutdown the server in 10 seconds") i think this means i have to write small smtp-servers on all workstations which do nothing more than listen on port 25 for incoming mails, recieve them and pop them up on the screen. Anyone out there who has ever done something like this? Any help would be appriciated!
|
|
|
|
|
SMTP is not suitable for this purpose. It's for sending email, not popup notifications. Tell your administrator to find a better protocol, or define one himself.
|
|
|
|
|
Yep, it sounds like you need to use Net Send from the command prompt. but I would not know how to implement this from the UNIX side. He could just send the notification from the NT Server\Domain.
Giles
|
|
|
|
|
Dear All,
I have been stuckup by a problem i want to change the bakgroud color
of each indiviudal cell of the grid control
can any one help me on this
Sumanth Kalidindi
Hyderabd
|
|
|
|
|
Greetings,
Status: Large graphics intense project using C and Win32 with the GDI
Problem: After short periods of use the client area stops repainting correctly (partial repaint 1/3 of client area). Afterwords most of windows graphics functions are messed up and menus and stuff can't redraw
System: Windows NT 4.0 sp4, Visual C++ 6.0 sp5, 1GB RAM.
Help solving this problem would greatly be apreciated (I have it narrowed to one function) out of 120,000 lines of code
Please mail me if you have any ideas (message queue, GDI issues....)
Randy@NeuronEntertainment.com
Sincerely,
Randy Trulson
|
|
|
|
|
You have what is called a memory leak. You have run out of GDI resources, and so the whole thing is melting down. As you are using Win32, you need to be extra careful to Destroy EVERY handle that you create when you are finished with it. If it's any consolation, I changed an MFC function to straight C, and spent two nights debugging the memory leaks, because there was so much more I needed to take care of.
Christian
I've learned that you cannot make someone love you. All you can do is stalk them and hope they panic and give in.
The early bird may get the worm, but it's the second mouse that gets the cheese.
|
|
|
|
|
I'm trying to create a multithreaded server program. After I create the thread that listens for incoming connections it will go for a little while then it'll crash. I usually get some error in barcore.cpp. I have no idea what's causing this. Here is the code i use for my listen function.
UINT PASCAL CLJFileServer::ListenProc(LPVOID *pParam)
{
CLJFileServer *pThis = (CLJFileServer*)pParam;
CTimeoutSocket* pClient = NULL;
pThis->m_pListen = new CTimeoutSocket();
pThis->m_pListen->Create(pThis->m_uPort);
while(pThis->m_bStop != true)
{
if (pClient)
delete pClient;
pClient = new CTimeoutSocket;
pThis->m_pListen->SetTimeout(LJ_TIMEOUT);
int bAccepted = pThis->m_pListen->Accept(*pClient);
if (bAccepted)
{
pThis->SendAck(pClient);
if (pThis->m_uServerType == LJFS_LISTEN)
pThis->Login(pClient);
pThis->ForwardConnection(pClient);
}
}
delete pThis->m_pListen;
return 0;
}
Any ideas. I will email you my code if you need a better idea. Thanx in advance.
Stephen Caldwell
Desick Information Technologies
|
|
|
|
|
I inserted a month calendar control (CMonthCalCtrl) into my project, and handle the MCN_GETDAYSTATE notification message to set day state (e.g. to emphasize every Friday). It's pretty easy for the current month of the calendar. However, when user change the date, for example, from Jan 2000 to Dec 1999, I cannot expect which month the calendar will change to and I have no idea how to calculate which day is Friday. Is there any one can give me a hint for that? Thanks in advance.
Yijun
|
|
|
|
|
If all you have is the month/year, you can set a CTime to the 1st of that month, and use CTime::GetDayOfWeek() to get the day of the week that the 1st falls on. From there you can find the Fridays.
--Mike--
http://home.inreach.com/mdunn/
The Signature, back by popular demand: Buffy. Pajamas.
|
|
|
|