Datei aus Internet runterladen
-
Hallo Zusammen
Ich hab mich im MFC-FAQ umgesehen und etwas interessantes gefunden. Und zwar geht es um das Thema "Internet - Datei aus dem Internet runterladen (mit Statusanzeige)". Gemäss dieser Funktion hab ich einen Button erstellt IDC_DOWNLOAD, eine Progressbar m_Progress, ein Static-Feld m_Static.
Nur was ist m_percent?? und wenn ich das nutzen will bekomme ich etliche Fehlermeldungen!
ts\visual studio 2010\projects\scvsct\scvsct\scvsctdlg.cpp(237): error C2065: 'CInternetSession' : undeclared identifier 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\scvsctdlg.cpp(237): error C2146: syntax error : missing ';' before identifier 'session' 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\scvsctdlg.cpp(237): error C2065: 'INTERNET_OPEN_TYPE_PRECONFIG' : undeclared identifier 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\scvsctdlg.cpp(237): error C3861: 'session': identifier not found 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\scvsctdlg.cpp(244): error C2065: 'session' : undeclared identifier 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\scvsctdlg.cpp(244): error C2228: left of '.OpenURL' must have class/struct/union 1> type is ''unknown-type'' 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\scvsctdlg.cpp(244): error C2065: 'INTERNET_FLAG_TRANSFER_BINARY' : undeclared identifier 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\scvsctdlg.cpp(255): error C2061: syntax error : identifier 'CInternetException' 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\scvsctdlg.cpp(255): error C2310: catch handlers must specify one type 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\scvsctdlg.cpp(257): error C2065: 'e' : undeclared identifier 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\scvsctdlg.cpp(257): error C2227: left of '->Delete' must point to class/struct/union/generic type 1> type is ''unknown-type'' 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\scvsctdlg.cpp(258): error C2065: 'session' : undeclared identifier 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\scvsctdlg.cpp(258): error C2228: left of '.Close' must have class/struct/union 1> type is ''unknown-type'' 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\scvsctdlg.cpp(259): error C2065: 'session' : undeclared identifier 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\scvsctdlg.cpp(262): error C2317: 'try' block starting on line '243' has no catch handlers 1> DownloadDlg.cpp 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\downloaddlg.cpp(28): error C2065: 'IDC_DOWNLOAD_STATUS' : undeclared identifier 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\downloaddlg.cpp(35): error C2065: 'IDC_BUTTON1' : undeclared identifier 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\downloaddlg.cpp(35): error C2065: 'IDC_BUTTON1' : undeclared identifier 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\downloaddlg.cpp(51): error C2065: 'CInternetSession' : undeclared identifier 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\downloaddlg.cpp(51): error C2146: syntax error : missing ';' before identifier 'pInetSession' 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\downloaddlg.cpp(51): error C2065: 'pInetSession' : undeclared identifier 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\downloaddlg.cpp(64): error C2679: binary '=' : no operator found which takes a right-hand operand of type 'const char [48]' (or there is no acceptable conversion) 1> e:\microsoft visual studio 10.0\vc\atlmfc\include\afxwin.h(3543): could be 'CStatic &CStatic::operator =(const CStatic &)' 1> while trying to match the argument list '(CStatic, const char [48])' 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\downloaddlg.cpp(65): error C2664: 'CWnd::SetDlgItemTextA' : cannot convert parameter 2 from 'CStatic' to 'LPCTSTR' 1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\downloaddlg.cpp(68): error C2065: 'pInetSession' : undeclared identifier 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\downloaddlg.cpp(68): error C2228: left of '.OpenURL' must have class/struct/union 1> type is ''unknown-type'' 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\downloaddlg.cpp(72): error C2679: binary '=' : no operator found which takes a right-hand operand of type 'const char [40]' (or there is no acceptable conversion) 1> e:\microsoft visual studio 10.0\vc\atlmfc\include\afxwin.h(3543): could be 'CStatic &CStatic::operator =(const CStatic &)' 1> while trying to match the argument list '(CStatic, const char [40])' 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\downloaddlg.cpp(73): error C2664: 'CWnd::SetDlgItemTextA' : cannot convert parameter 2 from 'CStatic' to 'LPCTSTR' 1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\downloaddlg.cpp(78): warning C4244: '=' : conversion from 'ULONGLONG' to 'int', possible loss of data 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\downloaddlg.cpp(91): error C2679: binary '=' : no operator found which takes a right-hand operand of type 'const char [37]' (or there is no acceptable conversion) 1> e:\microsoft visual studio 10.0\vc\atlmfc\include\afxwin.h(3543): could be 'CStatic &CStatic::operator =(const CStatic &)' 1> while trying to match the argument list '(CStatic, const char [37])' 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\downloaddlg.cpp(92): error C2664: 'CWnd::SetDlgItemTextA' : cannot convert parameter 2 from 'CStatic' to 'LPCTSTR' 1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\downloaddlg.cpp(101): error C2679: binary '=' : no operator found which takes a right-hand operand of type 'const char [35]' (or there is no acceptable conversion) 1> e:\microsoft visual studio 10.0\vc\atlmfc\include\afxwin.h(3543): could be 'CStatic &CStatic::operator =(const CStatic &)' 1> while trying to match the argument list '(CStatic, const char [35])' 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\downloaddlg.cpp(102): error C2664: 'CWnd::SetDlgItemTextA' : cannot convert parameter 2 from 'CStatic' to 'LPCTSTR' 1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\downloaddlg.cpp(111): error C2679: binary '=' : no operator found which takes a right-hand operand of type 'const char [21]' (or there is no acceptable conversion) 1> e:\microsoft visual studio 10.0\vc\atlmfc\include\afxwin.h(3543): could be 'CStatic &CStatic::operator =(const CStatic &)' 1> while trying to match the argument list '(CStatic, const char [21])' 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\downloaddlg.cpp(112): error C2664: 'CWnd::SetDlgItemTextA' : cannot convert parameter 2 from 'CStatic' to 'LPCTSTR' 1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\downloaddlg.cpp(132): error C2679: binary '=' : no operator found which takes a right-hand operand of type 'CString' (or there is no acceptable conversion) 1> e:\microsoft visual studio 10.0\vc\atlmfc\include\afxwin.h(3543): could be 'CStatic &CStatic::operator =(const CStatic &)' 1> while trying to match the argument list '(CStatic, CString)' 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\downloaddlg.cpp(133): error C2664: 'CWnd::SetDlgItemTextA' : cannot convert parameter 2 from 'CStatic' to 'LPCTSTR' 1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\downloaddlg.cpp(139): error C2061: syntax error : identifier 'CInternetException' 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\downloaddlg.cpp(139): error C2310: catch handlers must specify one type 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\downloaddlg.cpp(144): error C2065: 'IE' : undeclared identifier 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\downloaddlg.cpp(144): error C2227: left of '->GetErrorMessage' must point to class/struct/union/generic type 1> type is ''unknown-type'' 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\downloaddlg.cpp(148): error C2679: binary '=' : no operator found which takes a right-hand operand of type 'CString' (or there is no acceptable conversion) 1> e:\microsoft visual studio 10.0\vc\atlmfc\include\afxwin.h(3543): could be 'CStatic &CStatic::operator =(const CStatic &)' 1> while trying to match the argument list '(CStatic, CString)' 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\downloaddlg.cpp(149): error C2664: 'CWnd::SetDlgItemTextA' : cannot convert parameter 2 from 'CStatic' to 'LPCTSTR' 1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\downloaddlg.cpp(154): error C2317: 'try' block starting on line '62' has no catch handlers 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\downloaddlg.cpp(154): error C2679: binary '=' : no operator found which takes a right-hand operand of type 'const char [18]' (or there is no acceptable conversion) 1> e:\microsoft visual studio 10.0\vc\atlmfc\include\afxwin.h(3543): could be 'CStatic &CStatic::operator =(const CStatic &)' 1> while trying to match the argument list '(CStatic, const char [18])' 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\downloaddlg.cpp(156): error C2664: 'CWnd::SetDlgItemTextA' : cannot convert parameter 2 from 'CStatic' to 'LPCTSTR' 1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\downloaddlg.cpp(160): error C2679: binary '=' : no operator found which takes a right-hand operand of type 'const char [24]' (or there is no acceptable conversion) 1> e:\microsoft visual studio 10.0\vc\atlmfc\include\afxwin.h(3543): could be 'CStatic &CStatic::operator =(const CStatic &)' 1> while trying to match the argument list '(CStatic, const char [24])' 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\downloaddlg.cpp(161): error C2679: binary '=' : no operator found which takes a right-hand operand of type 'CString' (or there is no acceptable conversion) 1> e:\microsoft visual studio 10.0\vc\atlmfc\include\afxwin.h(3543): could be 'CStatic &CStatic::operator =(const CStatic &)' 1> while trying to match the argument list '(CStatic, CString)' 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\downloaddlg.cpp(163): error C2664: 'CWnd::SetDlgItemTextA' : cannot convert parameter 2 from 'CStatic' to 'LPCTSTR' 1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called 1>c:\users\wolf\documents\visual studio 2010\projects\scvsct\scvsct\downloaddlg.cpp(164): error C2664: 'CWnd::SetDlgItemTextA' : cannot convert parameter 2 from 'CStatic' to 'LPCTSTR' 1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called 1> Generating Code...
Was mach ich falsch??
Gruss
WolfCH
-
Ach ja, bevor ich es vergesse: Ich nutze MS Visual C++ 2010.
-
Hast Du denn überhaupt ein MFC Projekt?
Hast Du gemäß Doku afxinet.h included?
-
Hi Martin
Ja, habe ein MFC Projekt und auch die afxinet.h included. Ebenso die winapi.h, stdafx.h.
Es kommen jedoch immernoch dieselben Fehler. YourDlg heisst bei mir DownloadDlg. Wenn ich manuell pDownloadDlg->SetDlgItemTextA("....") hinschreibe zeigt mir der das auch an dass es möglich ist.
Trotzdem erhalte ich überall dieselben Fehlermeldungen.
Er kennt "try" nicht. session ist ungültig, etc.
Operator = ist nicht erlaubt etc.Ist in VC2010 die Vorgehensweise wohl komplett anders als in VC2008?? Mir ist schon aufgefallen dass bei VC2008 SetWindowText war und in VC2010 ist es nun SetWindowTextW.
Gruss
Wolf
-
So. Also ich hab es mal weiter gebracht.
Jetzt erhalte ich nur noch folgende Fehlermeldungen:error C2679: binary '=' : no operator found which takes a right-hand operand of type 'const char [48]' (or there is no acceptable conversion)
1> e:\microsoft visual studio 10.0\vc\atlmfc\include\afxwin.h(3543): could be 'CStatic &CStatic::operator =(const CStatic &)'Der Code dazu:
pDownloadDlg->m_Status = "Vorgang initialisiert. Suche wird gestartet ...";
und
error C2664: 'CWnd::SetDlgItemTextA' : cannot convert parameter 2 from 'CStatic' to 'LPCTSTR'
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be calledbetrifft:
pDownloadDlg->SetDlgItemTextA(IDC_STATIC_STATUS,pDownloadDlg->m_Status);
Und diese Fehlermeldung gilt für jede SetDlgItemText sowie jede ->m_Status= ...
Noch eine Frage: Was ist m_Percent?? Habe da mal ein Static-Percent angelegt mit der m_Percent variable und irgendwo im DLG platziert.. oder ist das was anderes?
Gruss
Wolf
-
Ok. Hat sich soweit erledigt.
Die Variablen m_Status und m_Percent waren Static statt CString.Hab das geändert nun gehts.
ALlerdings wenn ich die Datei runterladen will, bekomm ich folgende Fehlermeldung:
Siehe Screen: http://img403.imageshack.us/img403/6009/vc2010error.png
Gruss
-
Der CallStack gibt mir folgendes an:
Die DLGDATA.CPP:
if (pSite == NULL) { TRACE(traceAppMsg, 0, "Error: no data exchange control with ID 0x%04X.\n", nIDC); ASSERT(FALSE); AfxThrowNotSupportedException(); }
Und Line 40 ist das ASSERT(FALES);.
-
Schau in die Debug Ausgabe.
Es wird ein COntrol mit einer ID gesucht, die nicht in Deinem Diaog Template vorhanden ist.
-
Genau das wars! Danke für den Tipp.
Und wieder hab ich etwas dazugerlernt.
Die Progressbar war im Source als IDC_PROGRESS drin.Im Dialog aber als IDC_PROGRESS2. Das war es also.
Vielen Dank
und PS: Ich glaub ich registrier mich hier mal.. sonst muss ich ja immer bei einer Änderung gleich ein neuer Beitrag verfassen...das ist mühsam.