Bonjour à tous,

Pour mon application, j'ai besoin de créer des curseurs avec la flêche et le nom de l'outil en dessous. Celui-ci s'affiche correctement sur ma machine, mais différemment sur d'autres.

Voici le 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
void CEssaiCursorDlg::GetCursor (CString const & szTexte, COLORREF textColor,	bool bAlignHotSpot)	{

	CDC * pDC = GetDC () ;

	if (m_cursor) DeleteObject (m_cursor) ;

	// Récupération des informations concernant le cursor standard "flêche"
	HCURSOR hCur = LoadCursor (NULL, IDC_ARROW) ;

	ICONINFO ii = {0} ;
	ii.fIcon = FALSE ;
	GetIconInfo ((HICON) hCur, &ii) ;

	BITMAP bm ;
	GetObject (ii.hbmMask, sizeof (BITMAP), &bm) ;

	CDC memDC ;
	memDC.CreateCompatibleDC (pDC) ;

	// Calcul de la taille du texte
	CFont font, *oldfont ;

	LOGFONT lf = {0} ;
	strcpy (lf.lfFaceName, "Tahoma") ;
	lf.lfHeight	= 70 ;
	lf.lfWeight	= FW_BOLD ;
	font.CreatePointFontIndirect (&lf) ;

	oldfont = memDC.SelectObject (&font) ;
	CSize size = memDC.GetTextExtent (szTexte) ;

	// Nouvelle largeur du cursor
	if (bAlignHotSpot)	{
		size.cx += ii.xHotspot ;
	}

	int largeur = (size.cx < bm.bmWidth) ? bm.bmWidth : size.cx ;
	memDC.SelectObject (oldfont) ;

	CBitmap * oldbmp = memDC.SelectObject (CBitmap::FromHandle (ii.hbmMask)) ;

	// Récupération des deux bitmap AND et XOR
	CDC AndDC, XorDC ;
	AndDC.CreateCompatibleDC (pDC) ;
	XorDC.CreateCompatibleDC (pDC) ;

	// MASK AND
	CBitmap bmpAnd, * oldbmpAnd ;
	bmpAnd.CreateCompatibleBitmap (pDC, largeur, bm.bmHeight/2 + size.cy) ;
	oldbmpAnd = AndDC.SelectObject (&bmpAnd) ;

	CRect rc (0, 0, largeur, bm.bmHeight/2 + size.cy) ;
	AndDC.FillSolidRect (&rc, RGB (255,255,255)) ;
	AndDC.BitBlt (0, 0, bm.bmWidth, bm.bmHeight/2, &memDC, 0, 0, SRCCOPY) ;

	// Dessin du texte
	oldfont = AndDC.SelectObject (&font) ;
	rc = CRect (0, bm.bmHeight/2, largeur, bm.bmHeight/2 + size.cy) ;
	if (bAlignHotSpot)	{
		rc.left += ii.xHotspot ;
	}

	AndDC.DrawText (szTexte, rc, DT_LEFT) ;

	AndDC.SelectObject (oldfont) ;
	AndDC.SelectObject (oldbmpAnd) ;

	// MASK XOR
	CBitmap bmpXor, * oldbmpXor ;
	bmpXor.CreateCompatibleBitmap (pDC, largeur, bm.bmHeight/2 + size.cy) ;
	oldbmpXor = XorDC.SelectObject (&bmpXor) ;

	XorDC.BitBlt (0, 0, bm.bmWidth, bm.bmHeight/2, &memDC, 0, bm.bmHeight/2, SRCCOPY) ;
	
	// 
	memDC.SelectObject (oldbmp) ;
	DeleteObject (ii.hbmMask) ;

	// Dessin du texte
	oldfont = XorDC.SelectObject (&font) ;
	XorDC.SetTextColor (textColor) ;
	XorDC.SetBkMode (TRANSPARENT) ;
	XorDC.DrawText (szTexte, rc, DT_LEFT) ;

	XorDC.SelectObject (oldfont) ;
	XorDC.SelectObject (oldbmpXor) ;

	ii.hbmMask	= (HBITMAP) bmpAnd;
	ii.hbmColor	= (HBITMAP) bmpXor;
	m_cursor = CreateIconIndirect (&ii);

	bmpAnd.DeleteObject () ;
	bmpXor.DeleteObject () ;
}
Est-ce un problème de carte graphique ou autre ?
En espérant que quelqu'un aurait déjà eu ce genre de problème.

Cordialement
PP