Bonjour

J'essaie de modifier un HBITMAP
J'ai donc un bitmap d'origine sur lequel j'applique une modification et j'affiche le nouveau bitmap

sauf que j'ai le même texte "Image n°9" sur toutes les images

Je n'arrive pas à trouver d'où vient mon erreur
J'ai l'impression qu'il manque aussi un DeleteObject pour la police

Merci

voici mon code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
 
HBITMAP Modifier_Bitmap (HWND hWndDlg, HBITMAP Mon_image_init, HFONT hFont, int index )
{
	HBITMAP Mon_image;
	HDC hDC;
	HDC hdcMem;
	char Message [20];
 
	wsprintf (Message, "Image n°%d", index);
 
	Mon_image = Mon_image_init;
 
	hDC = GetDC(hWndDlg);
	hdcMem = CreateCompatibleDC(hDC);
	SelectObject(hdcMem, Mon_image);
	SelectObject(hdcMem, hFont);
	TextOut(hdcMem, 50, 50, Message, lstrlen(Message));
	DeleteDC(hdcMem);          
	ReleaseDC(hWndDlg, hDC);
 
	return Mon_image;
}
 
 
 
...
HBITMAP Mon_image_init;
HBITMAP Mon_image;
HFONT hFont;
 
 
 
Mon_image_init = (HBITMAP)LoadImage (...);
hFont = CreateFontIndirect(...);
 
for (int i = 1; i <= 9; i++)
{
	Mon_image = Modifier_Bitmap ( hWndDlg,  Mon_image_init,  hFont,  i );
 
	hStatic = GetDlgItem(hWndDlg, (5000 + i));
	SendMessage(hStatic, STM_SETIMAGE ,IMAGE_BITMAP ,(LPARAM)Mon_image);
}