maniek1310 Temat założony przez niniejszego użytkownika |
[WinAPI][cURL] Wypisywanie w okienku rozmiaru pliku » 2013-09-15 09:23:33 Witam , mam problem z wyświetleniem w okienku rozmiaru pliku, podczas kompilacji wyskakuje taki błąd main.cpp||In function 'int progressbar(void*, double, double, double, double)':| main.cpp|131|error: cannot convert 'double' to 'LPCSTR {aka const char*}' for argument '2' to 'BOOL SetWindowTextA(HWND, LPCSTR)'| main.cpp||In function 'DWORD pobierz(PVOID)':| main.cpp|160|warning: no return statement in function returning non-void [-Wreturn-type]| ||=== Build finished: 1 errors, 1 warnings (0 minutes, 0 seconds) ===|
tutaj jest linijka odpowiedzialna za wyświetlenie rozmiaru na ekranie SetWindowText( hStatic4, dltotal ); a tutaj kod int progressbar( void * clientp, double dltotal, double dlnow, double ultotal, double ulnow ) { int dltotalcalk =( dlnow * 100 ) / dltotal; SetWindowText( hStatic4, dltotal ); SendMessage( hProgressBar, PBM_SETPOS,( WPARAM ) dltotalcalk, 0 ); return 0; }
void get_file( const char * url, const char * file_name, const char * mode ) { CURL * easyhandle = curl_easy_init(); curl_easy_setopt( easyhandle, CURLOPT_URL, url ); std::FILE * file = std::fopen( file_name, mode ); curl_easy_setopt( easyhandle, CURLOPT_NOPROGRESS, 0 ); curl_easy_setopt( easyhandle, CURLOPT_PROGRESSFUNCTION, progressbar ); curl_easy_setopt( easyhandle, CURLOPT_WRITEDATA, file ); curl_easy_perform( easyhandle ); curl_easy_cleanup( easyhandle ); fclose( file ); }
DWORD WINAPI pobierz( PVOID pvParam ) { switch(( int ) pvParam ) { case 1: SetWindowText( hStatic2, "Nazwa" ); get_file( "tutaj jest link do pliku", "nazwa.exe", "wb" ); break; } } |
|
MrPoxipol |
» 2013-09-15 09:31:10 Musisz zamienić liczbę na tekst.. |
|
maniek1310 Temat założony przez niniejszego użytkownika |
» 2013-09-15 09:36:47 Zrobiłem tak ale dalej nie działa. Ze stringiem też próbowałem. LPCSTR rozmiar = dltotal;
SetWindowText( hStatic4, rozmiar ); |
|
MrPoxipol |
» 2013-09-15 09:55:49 Ta, chciałbyś tak..snprintf() lub std::ostringstream ew. sprintf() |
|
maniek1310 Temat założony przez niniejszego użytkownika |
» 2013-09-15 10:07:41 Zrobiłem z użyciem std::ostringstream i dalej to samo :/ std::ostringstream rozmiar; rozmiar << dltotal;
SetWindowText( hStatic4, rozmiar.str() ); |
|
DejaVu |
» 2013-09-15 10:40:40 SetWindowText( hStatic4, rozmiar.str().c_str() );
|
|
maniek1310 Temat założony przez niniejszego użytkownika |
» 2013-09-15 11:02:51 Dzięki, działa. |
|
« 1 » |