[vhd] fix VHD detection on Windows 7

* Revert to using strstr
* Also fix a potential issue with GetTextExtentPoint
This commit is contained in:
Pete Batard 2014-12-03 18:44:00 +00:00
parent 8e8a2bc827
commit efd22d1fe3
4 changed files with 20 additions and 21 deletions

View file

@ -867,23 +867,19 @@ LONG GetEntryWidth(HWND hDropDown, const char *entry)
HDC hDC;
HFONT hFont, hDefFont = NULL;
SIZE size;
WCHAR* wentry = NULL;
int len;
hDC = GetDC(hDropDown);
hFont = (HFONT)SendMessage(hDropDown, WM_GETFONT, 0, 0);
if (hFont != NULL)
hDefFont = (HFONT)SelectObject(hDC, hFont);
wentry = utf8_to_wchar(entry);
len = (int)wcslen(wentry)+1;
GetTextExtentPoint32W(hDC, wentry, len, &size);
if (!GetTextExtentPointU(hDC, entry, &size))
size.cx = 0;
if (hFont != NULL)
SelectObject(hDC, hDefFont);
ReleaseDC(hDropDown, hDC);
free(wentry);
return size.cx;
}