From f1ef14e02375d29a53e5796acc40d0c47dc11dec Mon Sep 17 00:00:00 2001 From: Huw Davies Date: Thu, 13 Oct 2016 16:52:49 +0100 Subject: [PATCH] include: Add a padding WORD to ensure that wWeight is at the correct offset. This is a bug in MS's C version of these structures. Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard --- dlls/riched20/tests/editor.c | 43 ++++++++++++++++++++++++++++++++++++ include/richedit.h | 2 ++ 2 files changed, 45 insertions(+) diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c index 88270aa4d53..36e082e4ebc 100644 --- a/dlls/riched20/tests/editor.c +++ b/dlls/riched20/tests/editor.c @@ -747,6 +747,7 @@ static void test_EM_SETCHARFORMAT(void) { HWND hwndRichEdit = new_richedit(NULL); CHARFORMAT2A cf2; + CHARFORMAT2W cfW; int rc = 0; int tested_effects[] = { CFE_BOLD, @@ -1196,6 +1197,48 @@ static void test_EM_SETCHARFORMAT(void) ok((cf2.dwEffects & CFE_BOLD) == CFE_BOLD, "%d, cf2.dwEffects == 0x%08x expected effect 0x%08x\n", i, cf2.dwEffects, CFE_BOLD); + /* show that wWeight is at the correct offset in CHARFORMAT2A */ + memset(&cf2, 0, sizeof(cf2)); + cf2.cbSize = sizeof(cf2); + cf2.dwMask = CFM_WEIGHT; + cf2.wWeight = 100; + SendMessageA(hwndRichEdit, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2); + memset(&cf2, 0, sizeof(cf2)); + cf2.cbSize = sizeof(cf2); + SendMessageA(hwndRichEdit, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2); + ok(cf2.wWeight == 100, "got %d\n", cf2.wWeight); + + memset(&cf2, 0, sizeof(cf2)); + cf2.cbSize = sizeof(cf2); + cf2.dwMask = CFM_SPACING; + cf2.sSpacing = 10; + SendMessageA(hwndRichEdit, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2); + memset(&cf2, 0, sizeof(cf2)); + cf2.cbSize = sizeof(cf2); + SendMessageA(hwndRichEdit, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2); + ok(cf2.sSpacing == 10, "got %d\n", cf2.sSpacing); + + /* show that wWeight is at the correct offset in CHARFORMAT2W */ + memset(&cfW, 0, sizeof(cfW)); + cfW.cbSize = sizeof(cfW); + cfW.dwMask = CFM_WEIGHT; + cfW.wWeight = 100; + SendMessageA(hwndRichEdit, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cfW); + memset(&cfW, 0, sizeof(cfW)); + cfW.cbSize = sizeof(cfW); + SendMessageA(hwndRichEdit, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cfW); + ok(cfW.wWeight == 100, "got %d\n", cfW.wWeight); + + memset(&cfW, 0, sizeof(cfW)); + cfW.cbSize = sizeof(cfW); + cfW.dwMask = CFM_SPACING; + cfW.sSpacing = 10; + SendMessageA(hwndRichEdit, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cfW); + memset(&cfW, 0, sizeof(cfW)); + cfW.cbSize = sizeof(cfW); + SendMessageA(hwndRichEdit, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cfW); + ok(cfW.sSpacing == 10, "got %d\n", cfW.sSpacing); + DestroyWindow(hwndRichEdit); } diff --git a/include/richedit.h b/include/richedit.h index f0ae57e47b6..63221e2d9e8 100644 --- a/include/richedit.h +++ b/include/richedit.h @@ -287,6 +287,7 @@ typedef struct _charformat2a { BYTE bCharSet; BYTE bPitchAndFamily; char szFaceName[LF_FACESIZE]; + WORD pad; /* Not in MS's C version, but needed to ensure that wWeight is at the correct offset to match the C++ version */ WORD wWeight; SHORT sSpacing; COLORREF crBackColor; @@ -309,6 +310,7 @@ typedef struct _charformat2w { BYTE bCharSet; BYTE bPitchAndFamily; WCHAR szFaceName[LF_FACESIZE]; + WORD pad; /* Not in MS's C version, but needed to ensure that wWeight is at the correct offset to match the C++ version */ WORD wWeight; SHORT sSpacing; COLORREF crBackColor;