Bitmap Display From buffer received by tcp socket

I want to display my image on window without saving it.
When data is received window size changes but there is no display
on window.
My Code is:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
int iBufferLength;
	int iEnd;
	int iSpaceRemaining;
	
	int i;
 
	iBufferLength = iSpaceRemaining = sizeof(chIncomingDataBuffer);
	iEnd = 0;
	iSpaceRemaining -= iEnd;
 
	iBytesRead = recv(Socket, chIncomingDataBuffer+iEnd, iSpaceRemaining, 0);
	
	iEnd+=iBytesRead;
	if (iBytesRead == SOCKET_ERROR)
		MessageBox(hWnd,
						"Socket Error",
						"Connection strt",
						MB_ICONINFORMATION|MB_OK);
		chIncomingDataBuffer[iEnd] = '\0';
 
	if (lstrlen(chIncomingDataBuffer) != 0)
	{
		/*FILE* pfile;
					
					pfile = 	fopen("test.jpeg", "wb");
				fwrite(chIncomingDataBuffer,1, iBytesRead ,pfile);
				fclose(pfile);*/
 
				GetWindowRect(hWnd, &rect);
				SetWindowPos(hWnd, NULL, rect.left, rect.top, cBitmap.bmWidth, cBitmap.bmHeight, 0);
				  HDC ThisDC = GetDC(hWnd);
 
              DeleteDC(RemoteDC);
              RemoteDC = CreateCompatibleDC(ThisDC);
			  DeleteObject(hbitmap);
			  hbitmap= CreateCompatibleBitmap(ThisDC, cBitmap.bmWidth, cBitmap.bmHeight);
 
			  SelectObject(RemoteDC, hbitmap);
 
			  ReleaseDC(hWnd, ThisDC);
 

 
			  BITMAPINFO bi;
			  HBITMAP hbmap;
			  int bisize = sizeof(BITMAPINFO);
			  memcpy(&bi, chIncomingDataBuffer+iEnd, bisize );
			  SetDIBits(RemoteDC, hbitmap, 0,  cBitmap.bmHeight, chIncomingDataBuffer+iEnd+bisize,  &bi, DIB_RGB_COLORS);
 

			  InvalidateRect(hWnd, NULL, false);
 


Can you find my error,,,where I'm doing wrong?
Topic archived. No new replies allowed.