- 1/ Dans Edit Ressources File:
- Image1 BITMAP "D:/Programme/Cpp/KDo[W32]/os1.bmp"
-
- 2/ Dans votre code:
-
- 2-1/ La bibliotheque :
- #include <windows.h>
-
- 2-2/ Déclarer vos variables:
- PAINTSTRUCT ps;
- RECT rect;
- HGLOBAL hgbl;
- HDC hdc, hdc2;
- HINSTANCE hinst;
- HBITMAP hbmp;
-
- 2-3/ Affichage de l'image:
- [...]
- LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
- {
- switch (message)
- {
- case WM_PAINT:
- hbmp=(HBITMAP)LoadImage(hinst,"Image1", IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION); // va chercher l'image
- hdc = BeginPaint( hwnd, &ps );
- GetClientRect(hwnd,&rect);
- hdc2 = CreateCompatibleDC(hdc);
- SelectObject(hdc2, hbmp);
- StretchBlt(hdc,0,0,260,270,hdc2,0,0,260,270, SRCCOPY); // incorpore l'image dans la form
- DeleteDC(hdc2);
- EndPaint( hwnd, &ps );
- break;
- [...]
- }
1/ Dans Edit Ressources File:
Image1 BITMAP "D:/Programme/Cpp/KDo[W32]/os1.bmp"
2/ Dans votre code:
2-1/ La bibliotheque :
#include <windows.h>
2-2/ Déclarer vos variables:
PAINTSTRUCT ps;
RECT rect;
HGLOBAL hgbl;
HDC hdc, hdc2;
HINSTANCE hinst;
HBITMAP hbmp;
2-3/ Affichage de l'image:
[...]
LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_PAINT:
hbmp=(HBITMAP)LoadImage(hinst,"Image1", IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION); // va chercher l'image
hdc = BeginPaint( hwnd, &ps );
GetClientRect(hwnd,&rect);
hdc2 = CreateCompatibleDC(hdc);
SelectObject(hdc2, hbmp);
StretchBlt(hdc,0,0,260,270,hdc2,0,0,260,270, SRCCOPY); // incorpore l'image dans la form
DeleteDC(hdc2);
EndPaint( hwnd, &ps );
break;
[...]
}