J
Joseph
I am trying to load a jpg from a website into the main windows, i am
trying to modify a few examples that i found in the web but i havent
been able to do so. so far i think i got the jpg on a buffer but i
dont know what to do use this instead of a hbitmap. here is my code so
far.
LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam,
LPARAM lParam) {
HBITMAP hBitmap;
HWND hBmpStat;
HINTERNET hInet;
HINTERNET hURL;
DWORD filesize, bytesread;
DWORD lenbufsiz = 2000;
TCHAR filedata[2000];
BOOL nRc;
LPVOID filebuff = 0;
filesize = 0;
switch(Message) {
case WM_CREATE:
if(!(hInet=InternetOpen(AGENT_NAME,
INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,0)))
{
InternetCloseHandle(hInet);
}
if(!(hURL=InternetOpenUrl(hInet,"http://66.92.73.95/prop_pics/webcam.jpg",NULL,0
,0 ,0)))
{
InternetCloseHandle(hInet);
}
if(hURL) {
filesize = HttpQueryInfo(hURL,
HTTP_QUERY_CONTENT_LENGTH, (LPVOID)filedata, &lenbufsiz, (LPDWORD)0);
}
if(filesize != 0) {
filebuff = (LPVOID)calloc(filesize, sizeof(BYTE));
hBitmap = LoadBitmap(ghInstance, TEXT (itoa (i,
filebuff,10) )
}else {
hBitmap = LoadBitmap(ghInstance,
MAKEINTRESOURCE(IDB_BITMAP1));
}
// MAKEINTRESOURCE(IDB_BITMAP1));
hBmpStat = CreateWindowEx(
NULL,
"Static",
"",
WS_VISIBLE | WS_CHILD | SS_BITMAP,
0, 0,
0, 0,
hwnd, NULL,
ghInstance,
NULL);
SendMessage(hBmpStat, STM_SETIMAGE,
IMAGE_BITMAP, (LPARAM) hBitmap);
break;
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, Message, wParam,
lParam);
}
return 0;
}
trying to modify a few examples that i found in the web but i havent
been able to do so. so far i think i got the jpg on a buffer but i
dont know what to do use this instead of a hbitmap. here is my code so
far.
LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam,
LPARAM lParam) {
HBITMAP hBitmap;
HWND hBmpStat;
HINTERNET hInet;
HINTERNET hURL;
DWORD filesize, bytesread;
DWORD lenbufsiz = 2000;
TCHAR filedata[2000];
BOOL nRc;
LPVOID filebuff = 0;
filesize = 0;
switch(Message) {
case WM_CREATE:
if(!(hInet=InternetOpen(AGENT_NAME,
INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,0)))
{
InternetCloseHandle(hInet);
}
if(!(hURL=InternetOpenUrl(hInet,"http://66.92.73.95/prop_pics/webcam.jpg",NULL,0
,0 ,0)))
{
InternetCloseHandle(hInet);
}
if(hURL) {
filesize = HttpQueryInfo(hURL,
HTTP_QUERY_CONTENT_LENGTH, (LPVOID)filedata, &lenbufsiz, (LPDWORD)0);
}
if(filesize != 0) {
filebuff = (LPVOID)calloc(filesize, sizeof(BYTE));
hBitmap = LoadBitmap(ghInstance, TEXT (itoa (i,
filebuff,10) )
}else {
hBitmap = LoadBitmap(ghInstance,
MAKEINTRESOURCE(IDB_BITMAP1));
}
// MAKEINTRESOURCE(IDB_BITMAP1));
hBmpStat = CreateWindowEx(
NULL,
"Static",
"",
WS_VISIBLE | WS_CHILD | SS_BITMAP,
0, 0,
0, 0,
hwnd, NULL,
ghInstance,
NULL);
SendMessage(hBmpStat, STM_SETIMAGE,
IMAGE_BITMAP, (LPARAM) hBitmap);
break;
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, Message, wParam,
lParam);
}
return 0;
}