Click here to Skip to main content
15,887,683 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: capturing notify messages Pin
led mike7-May-09 7:02
led mike7-May-09 7:02 
QuestionConfusion about object code generated? Pin
lionelcyril7-May-09 5:12
lionelcyril7-May-09 5:12 
AnswerRe: Confusion about object code generated? Pin
Eytukan7-May-09 5:20
Eytukan7-May-09 5:20 
AnswerRe: Confusion about object code generated? Pin
«_Superman_»7-May-09 5:22
professional«_Superman_»7-May-09 5:22 
GeneralRe: Confusion about object code generated? Pin
Eytukan7-May-09 5:25
Eytukan7-May-09 5:25 
AnswerRe: Confusion about object code generated? Pin
CPallini7-May-09 7:00
mveCPallini7-May-09 7:00 
QuestionIWinHttpRequest get_ResponseStream and Bitmap FromStream [modified] Pin
J.B.7-May-09 4:54
J.B.7-May-09 4:54 
AnswerRe: IWinHttpRequest get_ResponseStream and Bitmap FromStream Pin
Stuart Dootson7-May-09 7:28
professionalStuart Dootson7-May-09 7:28 
I'd verify that the contents of the stream are a JPEG by loading it into memory using GetHGlobalFromStream followed by a GlobalLock on the HGLOBAL you got back from the first function. Then verify that the memory starts with the string "JFIF".

I used the WinHttp functions to download a JPG and found that the JPG started after the first six bytes of the response (I created a stream on a set of bytes) - I needed to offset the stream by six bytes to get the Bitmap to load:

Gdiplus::Bitmap* LoadBitmapFromUrl(CString const& url)
{
   HINTERNET hInternet = WinHttpOpen(L"hello", WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0);
   if (!hInternet) return 0;
   HINTERNET hConnection = WinHttpConnect(hInternet, L"www.python.org", INTERNET_DEFAULT_PORT, 0);
   if (!hConnection) return 0;
   LPCWSTR types[] = { L"image/jpeg", 0 };
   HINTERNET hRequest = WinHttpOpenRequest(hConnection, L"GET", L"/images/success/standrews.jpg", 0, WINHTTP_NO_REFERER, types, 0);
   if (!hRequest) return 0;
   if (!WinHttpSendRequest(hRequest, WINHTTP_NO_ADDITIONAL_HEADERS, 0, WINHTTP_NO_REQUEST_DATA, 0, 0, 0)) return 0;
   if (!WinHttpReceiveResponse(hRequest, 0)) return 0;
   HGLOBAL gblBuffer = GlobalAlloc(0, 1<<20);
   LPBYTE buffer = (LPBYTE)GlobalLock(gblBuffer);
   DWORD nBytesRead;
   if (!WinHttpReadData(hRequest, buffer, 1<<20, &nBytesRead)) return 0;
   IStream* pStream = 0;
   CreateStreamOnHGlobal(gblBuffer, FALSE, &pStream);
   ULARGE_INTEGER size; size.QuadPart = nBytesRead;
   pStream->SetSize(size);
   LARGE_INTEGER offset; offset.QuadPart = 6;
   pStream->Seek(offset, STREAM_SEEK_SET, 0);
   return new Gdiplus::Bitmap(pStream, FALSE);
}


(Please ignore the memory leak - I couldn't be bothered to tidy up - it's not production code Smile | :) )

Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

AnswerRe: IWinHttpRequest get_ResponseStream and Bitmap FromStream Pin
J.B.7-May-09 20:58
J.B.7-May-09 20:58 
GeneralRe: IWinHttpRequest get_ResponseStream and Bitmap FromStream Pin
Stuart Dootson7-May-09 21:47
professionalStuart Dootson7-May-09 21:47 
GeneralRe: IWinHttpRequest get_ResponseStream and Bitmap FromStream Pin
J.B.7-May-09 22:50
J.B.7-May-09 22:50 
GeneralRe: IWinHttpRequest get_ResponseStream and Bitmap FromStream Pin
Stuart Dootson7-May-09 23:04
professionalStuart Dootson7-May-09 23:04 
Questionit`s so hard, pro please help me Pin
trongduy7-May-09 4:20
trongduy7-May-09 4:20 
AnswerRe: it`s so hard, pro please help me Pin
David Crow7-May-09 4:23
David Crow7-May-09 4:23 
Questionstopping an exe Pin
jimjim7337-May-09 4:20
jimjim7337-May-09 4:20 
AnswerRe: stopping an exe Pin
David Crow7-May-09 4:24
David Crow7-May-09 4:24 
GeneralRe: stopping an exe Pin
I am BATMAN7-May-09 7:10
I am BATMAN7-May-09 7:10 
GeneralRe: stopping an exe Pin
David Crow7-May-09 7:33
David Crow7-May-09 7:33 
JokeRe: stopping an exe Pin
CPallini7-May-09 9:40
mveCPallini7-May-09 9:40 
AnswerRe: stopping an exe Pin
Stuart Dootson7-May-09 4:26
professionalStuart Dootson7-May-09 4:26 
QuestionSending data from vector into and array Pin
brucewayn7-May-09 2:59
brucewayn7-May-09 2:59 
AnswerRe: Sending data from vector into and array Pin
Rajesh R Subramanian7-May-09 3:21
professionalRajesh R Subramanian7-May-09 3:21 
AnswerRe: Sending data from vector into and array Pin
led mike7-May-09 4:17
led mike7-May-09 4:17 
AnswerRe: Sending data from vector into and array Pin
Stuart Dootson7-May-09 4:23
professionalStuart Dootson7-May-09 4:23 
QuestionUsing float to define boolean type in C Pin
kaku_lala7-May-09 1:58
kaku_lala7-May-09 1:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.