Pour avoir une barre de defilement horizontale dans une listbox, il faut calculer la taille de la chaine de caractere la plus longue... en pixel soit-meme... (a croire que microsoft n'a pas eu le temps de finir l'api)

Je n'arrive pas a faire ce calcul en utilisant GDI, et sans utiliser MFC :
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
 
//Use GetDC to retrieve the handle to the display context for the list box 
//and store it in hDCListBox:
	HDC hDCListBox = GetDC(hwnd);
//Send the list box a WM_GETFONT message to retrieve the handle to the font
//that the list box is using, and store this handle in hFontNew:
	HFONT hFontNew = (HFONT) ::SendMessage(hwnd, WM_GETFONT, NULL, NULL);
//Use SelectObject to select the font into the display context. Retain the
//return value from the SelectObject call in hFontOld:
	HFONT hFontOld = (HFONT) SelectObject(hDCListBox, hFontNew);
//Call GetTextMetrics to get additional information about the font being used:
	TEXTMETRICS tm;
	GetTextMetrics(hDCListBox , (LPTEXTMETRIC)&tm);
//For each string, the value of the extent to be used is calculated as follows:
	DWORD dwExtent = GetTextExtent(hDCListBox, lpszText, strlen(lpszText))
					+ tm.tmAveCharWidth;
//After all the extents have been calculated, select the old font back into 
//hDCListBox and then release it:
	SelectObject(hDCListBox, hFontOld);
      ReleaseDC(hwnd, hDCListBox);												
	  return dwExtent;
J'ai trouve ce bout de code (sur MSDN) mais je n'arrive pas a appeler la fonction getDC(hwnd) de GDI, le compilateur propose uniquement la fonction getDC() de ATL, je ne vois pas ce qu'il faut rajouter pour utiliser celle de GDI, utiliser TEXTMETRICS...

Merci pour votre aide