salut tout le monde voila je pense que mon code est bon mais kan je lance le debug et que j'insere le point d'arret juste apres le LoadImage la variable HBitmap ne s'initialise pas ce qui fait que ne n'arrive pas a afficher mon image voila merci
mon code:
include <windows.h>
LRESULT CALLBACK MainProc(HWND hWnd, UINT messages, WPARAM wParam, LPARAM lParam)
{
switch (messages)
{
case WM_PAINT:
{
HDC hdc;
POINT pt;
HBITMAP hBitmap;
HDC hMemDC;
PAINTSTRUCT ps;
BITMAP bm;
hdc = BeginPaint(hWnd, &ps);
hBitmap = (HBITMAP) LoadImage( NULL, "d:\\but_valid.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
hMemDC = CreateCompatibleDC (hdc);
SelectObject (hMemDC, hBitmap);
GetObject (hBitmap, sizeof (BITMAP), &bm) ;
pt.x = bm.bmWidth;
pt.y = bm.bmHeight;
BitBlt (hdc, 0, 0, pt.x, pt.y, hMemDC, 0, 0, SRCCOPY) ;
EndPaint (hWnd, &ps);
break;
}
case WM_CLOSE:
case WM_DESTROY:
PostQuitMessage(0);
break;
}
return DefWindowProc(hWnd, messages, wParam, lParam);
}
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX main;
main.cbSize = sizeof(WNDCLASSEX);
main.style = CS_HREDRAW|CS_VREDRAW;
main.lpfnWndProc = MainProc;
main.cbClsExtra = 0;
main.cbWndExtra = 0;
main.hInstance = hInstance;
main.hIcon = LoadIcon(hInstance, "APPICON");
main.hIconSm = LoadIcon(hInstance, "WINICON");
main.hCursor = LoadCursor(NULL, IDC_ARROW);
main.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
main.lpszMenuName = NULL;
main.lpszClassName = "std";
RegisterClassEx(&main);
HWND hWnd;
hWnd = CreateWindowEx(WS_EX_CLIENTEDGE, "std", "Installation", WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT, 609, 429, NULL, NULL, hInstance, NULL);
ShowWindow(hWnd, SW_SHOW);
MSG messages;
while(GetMessage(&messages, NULL, 0, 0) == TRUE)
{
TranslateMessage(&messages);
DispatchMessage(&messages);
}
return 0;
}