+ INT nSel;
+ WCHAR szFontSize[100];
+
+ //
+ // FIXME: Check whether FontSize == 0
+ // (or in the case of raster font maybe, whether HIWORD(FontSize) == Height == 0) ??
+ //
+
+ /* Find and select the best font size in the list corresponding to the current size */
+ if (SizeList->UseRasterOrTTList)
+ {
+ INT idx;
+
+ /* Raster font size (in pixels) */
+ SizeList->CurrentRasterSize = FontSize;
+
+ nSel = BisectListSortedByValue(&SizeList->RasterSizeList, FontSize, NULL, FALSE);
+ idx = (INT)SendMessageW(SizeList->RasterSizeList.hWndList, LB_GETCOUNT, 0, 0);
+ if (nSel == LB_ERR)
+ {
+ /* Not found, select the first element of the list */
+ nSel = 0;
+ }
+ else if (nSel >= idx)
+ {
+ /*
+ * We got an index beyond the end of the list (as per Bisect* functionality),
+ * so instead, select the last element of the list.
+ */
+ nSel = idx-1;
+ }
+ SendMessageW(SizeList->RasterSizeList.hWndList, LB_SETCURSEL, (WPARAM)nSel, 0);
+ }
+ else
+ {
+ /* TrueType font size (in pixels or points) */
+ SizeList->CurrentTTSize = FontSize;
+
+ // _ultow(szFontSize, FontSize, 10);
+ StringCchPrintfW(szFontSize, ARRAYSIZE(szFontSize), L"%d", FontSize);
+
+ /* Find the font size in the list, or add it both in the ComboBox list, sorted by size value (string), and its edit box */
+ nSel = SendMessageW(SizeList->hWndTTSizeList, CB_FINDSTRINGEXACT, 0, (LPARAM)szFontSize);
+ if (nSel == CB_ERR)
+ {
+ nSel = (UINT)SendMessageW(SizeList->hWndTTSizeList, CB_ADDSTRING, -1, (LPARAM)szFontSize);
+ // ComboBox_SetText(...)
+ SetWindowTextW(SizeList->hWndTTSizeList, szFontSize);
+ SizeList->bIsTTSizeDirty = TRUE;
+ }
+ SendMessageW(SizeList->hWndTTSizeList, CB_SETCURSEL, (WPARAM)nSel, 0);
+ }
+}
+
+static LONG
+FontSizeList_GetSelectedFontSize(
+ IN PFONTSIZE_LIST_CTL SizeList)
+{
+ INT nSel;
+ LONG FontSize;
+ WCHAR szFontSize[100];
+
+ if (SizeList->UseRasterOrTTList)
+ {
+ /* Raster font size (in pixels) */
+
+ nSel = (INT)SendMessageW(SizeList->RasterSizeList.hWndList, LB_GETCURSEL, 0, 0);
+ if (nSel == LB_ERR) return 0;
+
+ FontSize = (LONG)SizeList->RasterSizeList.GetData(&SizeList->RasterSizeList, nSel);
+ if (FontSize == LB_ERR) return 0;
+
+ SizeList->CurrentRasterSize = FontSize;
+ }