Commit f1ef14e0 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

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: 's avatarHuw Davies <huw@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 9bce3e61
...@@ -747,6 +747,7 @@ static void test_EM_SETCHARFORMAT(void) ...@@ -747,6 +747,7 @@ static void test_EM_SETCHARFORMAT(void)
{ {
HWND hwndRichEdit = new_richedit(NULL); HWND hwndRichEdit = new_richedit(NULL);
CHARFORMAT2A cf2; CHARFORMAT2A cf2;
CHARFORMAT2W cfW;
int rc = 0; int rc = 0;
int tested_effects[] = { int tested_effects[] = {
CFE_BOLD, CFE_BOLD,
...@@ -1196,6 +1197,48 @@ static void test_EM_SETCHARFORMAT(void) ...@@ -1196,6 +1197,48 @@ static void test_EM_SETCHARFORMAT(void)
ok((cf2.dwEffects & CFE_BOLD) == CFE_BOLD, ok((cf2.dwEffects & CFE_BOLD) == CFE_BOLD,
"%d, cf2.dwEffects == 0x%08x expected effect 0x%08x\n", i, cf2.dwEffects, 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); DestroyWindow(hwndRichEdit);
} }
......
...@@ -287,6 +287,7 @@ typedef struct _charformat2a { ...@@ -287,6 +287,7 @@ typedef struct _charformat2a {
BYTE bCharSet; BYTE bCharSet;
BYTE bPitchAndFamily; BYTE bPitchAndFamily;
char szFaceName[LF_FACESIZE]; 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; WORD wWeight;
SHORT sSpacing; SHORT sSpacing;
COLORREF crBackColor; COLORREF crBackColor;
...@@ -309,6 +310,7 @@ typedef struct _charformat2w { ...@@ -309,6 +310,7 @@ typedef struct _charformat2w {
BYTE bCharSet; BYTE bCharSet;
BYTE bPitchAndFamily; BYTE bPitchAndFamily;
WCHAR szFaceName[LF_FACESIZE]; 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; WORD wWeight;
SHORT sSpacing; SHORT sSpacing;
COLORREF crBackColor; COLORREF crBackColor;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment