Please look at the following source code. I have a bimap in my resource file and I want to first load that bitmap into the memory DC and then I want to copy it on to the screen
But the following code just shows me an error message:
The message is my own. I call it whenver i cannot load the image from the resource file:
Code:
#include <windows.h>
#include "resource.h"
#define TheClass "myclass"

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
	switch(msg)
	{
	case WM_CREATE:
	HBITMAP hbball;
	hbball = LoadBitmap(NULL,  "BALLBMP");
	if(!hbball)
	{
     MessageBox(hwnd, "Load of resource BALLBMP failed.", "Error",
         MB_OK | MB_ICONEXCLAMATION);
	}
	 return 0;
	case WM_PAINT:
	if(hbball)
		{
		HDC winhdc, memhdc;
		PAINTSTRUCT ps;
		BITMAP bm;
		winhdc =  BeginPaint(hwnd, &ps);
		memhdc = CreateCompatibleDC(winhdc);
		SelectObject(memhdc, hbball);
		GetObject(hbball, sizeof(bm), &bm);
		BitBlt(winhdc,0,0,bm.bmWidth, bm.bmHeight, memhdc, 0,0,SRCCOPY);
		DeleteDC(memhdc);
		EndPaint(hwnd, &ps);
		}
		return 0;
	case WM_CLOSE:
		DestroyWindow(hwnd);
		return 0;
	case WM_DESTROY:
		DeleteObject(hbball);
		PostQuitMessage(0);
		return 0;
	}

	return DefWindowProc(hwnd, msg, wparam, lparam);
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE HPrevInstance, LPSTR lpCmdLine, int ShowCmd)
{
	WNDCLASSEX wc;
	HWND hwnd;
	MSG msg;

	//Creates the window class

	wc.cbClsExtra = 0;
	wc.cbSize = sizeof(wc);
	wc.cbWndExtra = 0;
	wc.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
	wc.hCursor = LoadCursor(NULL, IDC_ARROW);
	wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
	wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
	wc.hInstance = hInstance;
	wc.lpfnWndProc = WndProc;
	wc.lpszClassName = TheClass;
	wc.lpszMenuName = MAKEINTRESOURCE(MYMENU);
	wc.style = CS_VREDRAW | CS_HREDRAW;

	//Registers the Window Class -- if it does not succeed then it
	//shows an error message.

	if(!RegisterClassEx(&wc))
	{
		MessageBox(NULL, "Error occurred while \
		Registering the Main Class", "Error!", MB_OK);
		return 0;
	}

	//Creates the main window hwnd

	hwnd = CreateWindow(TheClass,
					"The Ball Example",
					WS_OVERLAPPEDWINDOW,
					0,
					0,
					500,
					500,
					NULL,
					NULL,
					hInstance,
					NULL);

	//Check if there is any error when we make our windows' Hwnd

	if(hwnd == NULL)
	{
		MessageBox(NULL, "Error making the Hwnd for our window","Error",MB_OK);
	return 0;
	}

	ShowWindow(hwnd, SW_SHOW);
	UpdateWindow(hwnd);

	while(GetMessage(&msg, NULL, 0,0))
	{
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}

	return msg.wParam;
}


Do you know what is rong with that?