Run a search as this gets asked quite a lot.
In your code
Code:
HDC hdc, hdcMem ; //no init here for hdc
HINSTANCE hInstance ;
PAINTSTRUCT ps;
BITMAP1=LoadBitmap(hInstance, MAKEINTRESOURCE(102));
GetObject(BITMAP1, sizeof(BITMAP1), &bitmap);
cxSource=bitmap.bmWidth; //why do this if you are not going to use them?
cySource=bitmap.bmHeight;
hdcMem=CreateCompatibleDC(hdc); //What is hdc?
SelectObject(hdcMem, BITMAP1);
BitBlt(hdc, 1, 1, 50, 50, hdcMem, 0, 0, SRCCOPY);
What value does hdc have that you are creating a HDC compatible with it?
Try
Code:
HWND hWnd_Object_To_Paint;//get this HWND with GetDlgItem() ect
hdc=GetDC(hWnd_Object_To_Paint);
//your stuff
ReleaseDC(hdc);
Of course this will only draw it once. When the window needs to be repainted and a WM_PAINT msg is sent you will need to redraw it.
For this I would recomend a framebufferDC and screenDC system.
That is all drawing is done to one HDC, the framebuffer. AFTER all the drawing is done the FrameBufferDC is 'copied' [BltBit()] to the screenDC and a paint msg called for with UpdateWindow() or InvalidateRect().
All painting is done with the screenDC. In the paint function the minimum of work is done to ensure it is fast.
Also you must ensure like any memory you create that you free it before using the same handle again or exiting the app.
As I said run a search for more code on this.