windows编程 在一个窗口上加载一个位图图片

希望前辈们能给个demo程序。或者最基本的窗口上加载一个位图图片就好,加载位图时用的LoadImage
初学windows编程,不太懂上下文设备,希望大神能给个例程,让我学习。

#include
#include "resource.h"

LRESULT CALLBACK WndProc1(HWND hwnd,UINT message,WPARAM wParam,LPARAM IParam)
{
HDC hdc;
PAINTSTRUCT ps;
RECT rect;

switch(message)
{
case WM_PAINT:
    hdc=BeginPaint(hwnd,&ps);
    GetClientRect(hwnd,&rect);
    DrawText (hdc, TEXT ("Hello, Windows 98!"), -1, &rect,DT_SINGLELINE | DT_CENTER | DT_VCENTER) ;
    EndPaint (hwnd, &ps) ;
    return 0 ;
case WM_DESTROY:
    PostQuitMessage(0);
    return 0;
}
return DefWindowProc(hwnd,message,wParam,IParam);

}

LRESULT CALLBACK WndProc2(HWND hwnd,UINT message,WPARAM wParam,LPARAM IParam)
{
RECT rcDialog;
HBITMAP LoadBmp;
static BITMAP s_bm;
static HDC s_hdcMem;
////================================================================================
switch(message)
{
case WM_PAINT:
LoadBmp = (HBITMAP)LoadImageA(NULL, "005.bmp",IMAGE_BITMAP,80,29,LR_DEFAULTCOLOR);

        // 将背影图片放入HDC - s_hdcMem
        HDC        hdc;
        hdc = GetDC(hwnd);
        s_hdcMem = CreateCompatibleDC(hdc);
        SelectObject(s_hdcMem, LoadBmp);
        StretchBlt(hdc, 0, 0, 80, 29, hdc, 0, 0, 80, 29, SRCCOPY);
        ReleaseDC(hwnd, hdc);
        // 得到位图信息
        GetObject(LoadBmp, sizeof(s_bm), &s_bm);                
        return 0 ;

    case WM_CTLCOLORDLG:
    GetClientRect(hwnd, &rcDialog);
    //通过SetStretchBltMode的设置能使StretchBlt在缩放图像更加清晰
    SetStretchBltMode((HDC)wParam, COLORONCOLOR);
    StretchBlt((HDC)wParam, 0, 0, rcDialog.right, rcDialog.bottom, s_hdcMem, 0, 0, s_bm.bmWidth, s_bm.bmHeight, SRCCOPY);   
    return (BOOL)((HBRUSH)GetStockObject(NULL_BRUSH));


    case WM_DESTROY:
    PostQuitMessage(0);
    return 0 ;

////========================================================================

}return DefWindowProc(hwnd,message,wParam,IParam);

}

int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,PSTR szCmdLine,int iCmdShow)
{
static TCHAR szAppName1[]=TEXT("HelloWin");
static TCHAR szAppName2[]=TEXT("hello");
HWND hwnd1;
HWND hwnd2;
MSG msg;

WNDCLASS wndclass1;
wndclass1.style        = CS_HREDRAW | CS_VREDRAW ;
wndclass1.lpfnWndProc  = WndProc1 ;
wndclass1.cbClsExtra   = 0 ;
wndclass1.cbWndExtra   = 0 ;
wndclass1.hInstance    = hInstance ;
wndclass1.hIcon        = LoadIcon (NULL, IDI_APPLICATION) ;
wndclass1.hCursor      = LoadCursor (NULL, IDC_ARROW) ;
wndclass1.hbrBackground= (HBRUSH) GetStockObject (WHITE_BRUSH) ;
wndclass1.lpszMenuName  = NULL ;
wndclass1.lpszClassName= szAppName1 ;

WNDCLASSEX wndclass2;
wndclass2.cbSize       = sizeof(WNDCLASSEX);
wndclass2.style        = CS_HREDRAW | CS_VREDRAW | CS_OWNDC ;
wndclass2.lpfnWndProc  = WndProc2 ;
wndclass2.cbClsExtra   = 0 ;
wndclass2.cbWndExtra   = 0 ;
wndclass2.hInstance    = hInstance ;
wndclass2.hIcon        = LoadIcon (NULL, IDI_APPLICATION) ;
wndclass2.hCursor      = LoadCursor (NULL, IDC_ARROW) ;
wndclass2.hbrBackground= NULL;
wndclass2.lpszMenuName  = NULL ;
wndclass2.lpszClassName= szAppName2 ;
wndclass2.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);

if (!RegisterClass(&wndclass1))
{
    MessageBox(NULL,TEXT("OH MY GOD1"),szAppName1,MB_ICONERROR);
    return 0;
}
if (!RegisterClassEx(&wndclass2))
{
    MessageBox(NULL,TEXT("OH MY GOD2"),szAppName2,MB_ICONERROR);
    return 0;
}   

hwnd1 = CreateWindow( szAppName1,      // window class name
    TEXT ("hello window1..."),   // window caption
    WS_POPUP,  // window style
    0,// initial x position
    0,// initial y position
    800,// initial x size
    600,// initial y size
    NULL,                 // parent window handle
    NULL,            // window menu handle
    hInstance,   // program instance handle
    NULL) ;      // creation parameters
ShowWindow(hwnd1,iCmdShow);
UpdateWindow(hwnd1);

hwnd2 = CreateWindowEx( WS_EX_TOPMOST,
    szAppName2,      // window class name
    TEXT ("hello window2..."),   // window caption
    WS_CHILD,  // window style
    80,// initial x position
    50,// initial y position
    200,// initial x size
    50,// initial y size
    hwnd1,                 // parent window handle
    NULL,            // window menu handle
    hInstance,   // program instance handle
    NULL) ;      // creation parameters
ShowWindow(hwnd2,iCmdShow);
UpdateWindow(hwnd2);

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

}

WndProc2的位图加载有问题 我尝试打断点也进不去 求赐教

看这个就好 http://blog.csdn.net/zuishikonghuan/article/details/46620965
这个是图标的,位图就换汤不换药