|
|
Hi,
I am having trouble removing an object from a std::list.
I have got a Line object and a list structure in the form
std::list<line> lines;
and am trying to remove a particular Line object from the list by
Line * selectedLine;
// code to determine what line is selected
lines.remove(*selectedLine);
I get the error
c:\program files\microsoft visual studio 8\vc\include\list(908) : error C2678: binary '==' : no operator found which takes a left-hand operand of type 'Line' (or there is no acceptable conversion)
c:\program files\microsoft platform sdk for windows server 2003 r2\include\guiddef.h(192): could be 'int operator ==(const GUID &,const GUID &)' [found using argument-dependent lookup]
while trying to match the argument list '(Line, const Line)'
c:\program files\microsoft visual studio 8\vc\include\list(898) : while compiling class template member function 'void std::list<_Ty>::remove(const _Ty &)'
with
[
_Ty=Line
]
c:\documents and settings\kevin\my documents\visual studio 2005\projects\sdl_001\sdl_001\main.h(391) : see reference to class template instantiation 'std::list<_Ty>' being compiled
with
[
_Ty=Line
]
I have tried searching google but all I can find is examples of how to remove integers and strings from lists
Any help would be appreciated
Kevin
|
|
|
|
|
I never used remove before but I suppose that you need to supply an ==operator for your Line class. Otherwise, the compiler cannot know if two Line objects are the same.
|
|
|
|
|
ah thats solved my problem. i thought the == operator was implicitly defined to check if two objects were equal
thanks
kevin
|
|
|
|
|
hi!i am trying to implement a code in c for cyclic reduction method.any one can help me (with an algorithm or the code itself)
|
|
|
|
|
hi!i am trying to implement a code in c for cyclic reduction (tridiagonal matrix).any one can help me (with an algorithm or the code itself)
|
|
|
|
|
where are you stuck ?
have you started anything, or are you just expecting us to pound out a working code ?
|
|
|
|
|
Hi All,
Pls let me know if there is any solution for this problem.
Im starting FTP uploading and at the same time HTTP downloading too for the same server which supports both ftp and http.
File is partially downloading at the receiver.Downloaded file size is less than the actual uploaded file.
Here problem is internetreadfile() is failing to read, once it does not receive data while file is uploading.
m_hHttpFile = HttpOpenRequest(m_hHttpConnection, "GET", FileToDownload, NULL, NULL, ppszAcceptTypes, INTERNET_FLAG_RELOAD |
INTERNET_FLAG_KEEP_CONNECTION, NULL);
if (m_hHttpFile == NULL)
{
return 0;
}
BOOL bSend = ::HttpSendRequest(m_hHttpFile, NULL, 0, NULL, 0);
if (!bSend)
{
AfxMessageBox(" Http download HttpSendRequest failed");
return 0;
}
TCHAR szStatusCode[32];
if (!HttpQueryInfo(m_hHttpFile, HTTP_QUERY_STATUS_CODE, szStatusCode, &dwInfoSize, NULL))
{
AfxMessageBox(" Http download HttpQueryInfo failed");
CString strMsg;
strMsg.Format("Error:%d", GetLastError());
//AfxMessageBox(strMsg);
return 0;
}
long nStatusCode = _ttol(szStatusCode);
if (nStatusCode != HTTP_STATUS_OK)
{
AfxMessageBox(" Http download server file not available ");
return 0;
}
DWORD dwBytesRead = 0;
char szReadBuf[TRANSFER_SIZE+1];
CFileException e;
m_FileToWrite.Open(LocalFile, CFile::modeCreate | CFile::modeWrite /*| CFile::shareDenyWrite*/);
double sum = 0;
do
{
if (!::InternetReadFile(m_hHttpFile, szReadBuf, TRANSFER_SIZE, &dwBytesRead))
{
AfxMessageBox("Http download InternetReadFile Failed");
return 0;
}
if(dwBytesRead>0)
{
TRY
{
m_FileToWrite.Write(szReadBuf, dwBytesRead);
}
CATCH(CFileException, e);
{
e->Delete();
return 0;
}
END_CATCH
}
sum += dwBytesRead;
}
while(sum!=filelength);
|
|
|
|
|
I'm not quite sure what the problem is...
"When I haven't finished uploading a file, downloading it fails part of the way through"
This sounds pretty straightforward to me! A little patience before downloading will probably cure your isssue.
Iain.
|
|
|
|
|
Hi
Thanks for ur response
Im able to start downloading the file using HTTP while the same file is being uploaded using FTP.
When ftp server permits to access that file while it is uploading, y cant we
download that file.
Actually we are able to download the file upto some extent. After that internetreadfile() is returning 0 bytes. After that its not reading the reamining data. internetreadfile()should wait for the requested amount of data. But its not doing so.
Its a bit urgent task for me. Awaiting for ur reply
|
|
|
|
|
Jyo2007 wrote: When ftp server permits to access that file while it is uploading, y cant we
download that file.
Why would you want to download a file that has not been fully uploaded yet?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Inorder to synchronize file upload and download it is quite obvious that u want to download the file which isnt uploaded completely.
When internet read file returns 0, close the handle to internet file, recall httpopenrequest() and httpsendfile()and then continue reading file from the location where previously the downloading has stopped(using internetsetfilepointer method).
|
|
|
|
|
programmer81 wrote: ...it is quite obvious that u...
No, not me.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Why you dont use of URLDownloadToFile Function.
|
|
|
|
|
Hi
I have to retrieve the registery value through RegQueryValueEx().Before
doing this I am using RegOpenKeyEx() to open the registery.But the return value of RegOpenKeyEx() I am getting is 998 i.e the function is not able to successfully open the windows registery.Although,I have tried to map the error code of getlasterror() with the help of FormatMessage(),the return value of
getlasterror() is 0 i.e. "operation completed successfully".
Here is the code:
PHKEY m_htKey;
const char* lpSubKey = "SOFTWARE\\MyProduct\\N K software\\1.5";
long* lpcbValue = NULL;
DWORD valueType = 0;
DWORD dwBufLen = 0;
const char* valueName = "NKSDir";
long res = RegOpenKeyEx(HKEY_CURRENT_USER ,lpSubKey,0,KEY_ALL_ACCESS,m_htKey);
DWORD dw = GetLastError();
LPVOID lpMsgBuf;
FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |FORMAT_MESSAGE_IGNORE_INSERTS, NULL,GetLastError(),MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,0,NULL);
//Display the string.
MessageBox( NULL, (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION );
// Free the buffer.
LocalFree( lpMsgBuf );
if (res != ERROR_SUCCESS)
return TRUE;
else
{
printf("hi");
res = RegQueryValueEx((HKEY)m_htKey,valueName,NULL,&valueType,NULL,&dwBufLen);
}
Now in the above code, the if condition is getting true and it's returning true.The control is not going into the else condition.
Can you please suggest me what could be the reason behind it that RegOpenKeyEx() is returning non zero value?
With Regards
Neeraj Sinha
|
|
|
|
|
I don't know the solution to your problem (I never worked with the registry) but shouldn't you pass the return value of RegOpenKeyEx to your FormatMessage function instead of GetLastError ? Even if you get an error in RegOpenKeyEx, GetLastError will still return 0.
|
|
|
|
|
Yes I agree.Thanks for your help to remove my confusion.Now I am
getting the correct message of error code 998 through FormatMessage, i.e."Invalid access to memory location".
Can anybody please solve this problem?What could be the possible
reason behind this message?
With Regards
Neeraj Sinha
|
|
|
|
|
Hi,
Cedric's comment is correct, you need to pass the value returned from RegQueryValueEx() to FormatMessage() and then tell us the error you are getting before we can help.
|
|
|
|
|
LONG regResult = ERROR_SUCCESS;
HKEY hKey;
regResult=RegOpenKeyEx(HKEY_LOCAL_MACHINE,
"Software\\MyProduct\\N K software\\1.5"
,0,KEY_ALL_ACCESS,&hKey);
if(regResult == ERROR_SUCCESS)
{
unsigned long type=REG_SZ, size=1024;
char res[1024]="";
char res2[1024]="";
long err=RegQueryValueEx(hKey,"Reference",NULL,&type,(LPBYTE)&res[0],&size);
RegCloseKey(hKey);
if(err==ERROR_SUCCESS)
{
//....do necessary code here }
else
//...do code here
}
Hope this will help you!!!!!!!!!!1
|
|
|
|
|
Hi Cedric,Jonathan and D.Mani
Thanks a lot for your quick replies.
I got my problem completely solved now.
With Regards
Neeraj Sinha
|
|
|
|
|
|
My project has a dialog, in this dialog, have two control: A and B
when this dialog print, A covered B, but when B has some change(change color, for example), and then B covered A.
How to lead A covered B again? Thanks!
|
|
|
|
|
Look up SetWindowPos(),you should be able to use this to change your controls Z-order.
|
|
|
|
|
if that's normal for your design that they overlap, then you should hide the control overlapped by calling ShowWindow(FALSE) on it.
otherwise, you have a design issue in your dialog :p
|
|
|
|
|
I set a Dialog's "Vertical scroll" property true.Now I want to calculate its scroll bar's width. how to do it ?
Thanks in advance.
|
|
|
|