help loading url jpg to win32 app

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;
}
 
J

Jack Klein

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;

[snip]

You need to ask in a Windows programming group like
or one of Microsoft's support
groups in the family. Your issue is with
the Windows API, not the C++ language.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top