Harkonnen Modérateur Un modo pour les bannir tous | Oui, bien sur
Accroche toi aux branches
Code :
- #include <windows.h>
- HBITMAP g_hBitmap;
- BITMAP g_bmp;
- LRESULT CALLBACK WndProc(
- HWND hwnd,
- UINT msg,
- WPARAM wParam,
- LPARAM lParam
- )
- {
- HDC hdc, hMemDC;
- PAINTSTRUCT ps;
- switch(msg)
- {
- case WM_CREATE:
- MessageBox(
- hwnd,
- "Une image C:\test.bmp doit exister.",
- "BMP Test",
- MB_OK );
- g_hBitmap = LoadImage(
- NULL,
- "C:\\test.bmp",
- IMAGE_BITMAP,
- 0, 0,
- LR_LOADFROMFILE
- );
- GetObject(g_hBitmap, sizeof(g_bmp), &g_bmp);
- return 0;
- case WM_PAINT:
- hdc = BeginPaint(hwnd, &ps);
- if(!hdc) return -1;
- hMemDC = CreateCompatibleDC(hdc);
- SelectObject(hMemDC, g_hBitmap);
- BitBlt(
- hdc,
- 0, 0,
- g_bmp.bmWidth, g_bmp.bmHeight,
- hMemDC,
- 0, 0,
- SRCCOPY );
- EndPaint(hwnd, &ps);
- return 0;
- case WM_DESTROY:
- PostQuitMessage(0);
- return 0;
- } return DefWindowProc(hwnd, msg, wParam, lParam);
- }
- int WINAPI WinMain(
- HINSTANCE hInst,
- HINSTANCE hPrev,
- LPSTR lpszCmdLine,
- int nCmdShow
- )
- {
- static const char lpszClassName[] = "Bitmap Test";
- WNDCLASSEX wndclass;
- HWND hwnd;
- MSG msg;
- ZeroMemory(&wndclass, sizeof(wndclass));
- wndclass.cbSize = sizeof(wndclass);
- wndclass.lpfnWndProc = WndProc;
- wndclass.hInstance = hInst;
- wndclass.hIcon = (HICON)LoadIcon(NULL, IDI_APPLICATION);
- wndclass.hCursor = (HCURSOR)LoadCursor(NULL, IDC_ARROW);
- wndclass.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
- wndclass.lpszMenuName = NULL;
- wndclass.lpszClassName = lpszClassName;
- wndclass.hIconSm = (HICON)LoadIcon(NULL, IDI_APPLICATION);
- if(!RegisterClassEx(&wndclass)) return -1;
- hwnd = CreateWindow(
- lpszClassName,
- lpszClassName,
- WS_OVERLAPPEDWINDOW,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- NULL,
- NULL,
- hInst,
- NULL
- );
- if(!hwnd) return -1;
- ShowWindow(hwnd, nCmdShow);
- UpdateWindow(hwnd);
- while(GetMessage(&msg, NULL, 0, 0))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- return msg.wParam;
- }
|
Ce code ouvre une fenêtre et affiche l'image C:\Test.bmp dans cette fenêtre.
A+ [jfdsdjhfuetppo]--Message édité par Harkonnen le 16-05-2002 à 11:18:43--[/jfdsdjhfuetppo] ---------------
J'ai un string dans l'array (Paris Hilton)
|