http://bugs.winehq.org/show_bug.cgi?id=28610
Bug #: 28610 Summary: Drawing of Text using Message LOGFONT obtained via SystemParametersInfo can cause a crash in drawing of text (difference in behaviour) Product: Wine Version: 1.3.29 Platform: x86 OS/Version: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: gdi32 AssignedTo: wine-bugs@winehq.org ReportedBy: damian.dixon@gmail.com Classification: Unclassified
I have narrowed an issue down to a difference in behaviour between Windows and Wine.
The problem boils down to the following code:
NONCLIENTMETRICS ncm; memset(&ncm, 0, sizeof(NONCLIENTMETRICS)); ncm.cbSize = sizeof(NONCLIENTMETRICS);
VERIFY(SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0));
I used the font's returned from this call for drawing text and this caused the crash.
The problem is that I upgraded to VS2010 and changed the target to WINVER=0x600.
This means that I needed to change my code to the following.
NONCLIENTMETRICS ncm; memset(&ncm, 0, sizeof(NONCLIENTMETRICS)); ncm.cbSize = sizeof(NONCLIENTMETRICS);
#if(WINVER >= 0x0600) OSVERSIONINFO osvi; memset(&osvi,0,sizeof(osvi)); osvi.dwOSVersionInfoSize = sizeof(osvi); GetVersionEx(&osvi); if (osvi.dwMajorVersion < 6) ncm.cbSize -= sizeof(ncm.iPaddedBorderWidth); #endif VERIFY(SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0));
Note: On windows my application does not actually crash or stop working with my original code and the text is displayed at a size I would kind of expect it to be.