diff --git a/Source/DialogTemplate.cpp b/Source/DialogTemplate.cpp index 058e72dd..ddd883b3 100644 --- a/Source/DialogTemplate.cpp +++ b/Source/DialogTemplate.cpp @@ -127,13 +127,21 @@ CDialogTemplate::CDialogTemplate(BYTE* pbData) { // Read title variant length array ReadVarLenArr(seeker, m_szTitle); // Read font size and variant length array (only if style DS_SETFONT is used!) - if (m_dwStyle & DS_SETFONT) { + if (m_dwStyle & DS_SETFONT || m_dwStyle & DS_SHELLFONT) { m_sFontSize = *(short*)seeker; seeker += sizeof(short); + if (m_bExtended) { + m_sFontWeight = *(short*)seeker; + seeker += sizeof(short); + m_bItalic = *(BYTE*)seeker; + seeker += sizeof(BYTE); + m_bCharset = *(BYTE*)seeker; + seeker += sizeof(BYTE); + } ReadVarLenArr(seeker, m_szFont); } - // Read items + // Read items for (int i = 0; i < wItems; i++) { // DLGITEMTEMPLATE[EX]s must be aligned on DWORD boundry if (DWORD(seeker - pbData) % sizeof(DWORD)) @@ -457,15 +465,17 @@ BYTE* CDialogTemplate::Save(DWORD& dwSize) { WriteStringOrId(m_szTitle); // Write font variant length array, size, and extended info (if needed) - if (m_dwStyle & DS_SETFONT) { + if (m_dwStyle & DS_SETFONT || m_dwStyle & DS_SHELLFONT) { *(short*)seeker = m_sFontSize; seeker += sizeof(short); if (m_bExtended) { *(short*)seeker = m_sFontWeight; seeker += sizeof(short); - *(short*)seeker = m_bItalic ? TRUE : FALSE; - seeker += sizeof(short); - } + *(BYTE*)seeker = m_bItalic; + seeker += sizeof(BYTE); + *(BYTE*)seeker = m_bCharset; + seeker += sizeof(BYTE); + } WriteStringOrId(m_szFont); } @@ -538,8 +548,8 @@ DWORD CDialogTemplate::GetSize() { AddStringOrIdSize(m_szTitle); // Font - if (m_dwStyle & DS_SETFONT) { - dwSize += sizeof(WORD) + (m_bExtended ? 2*sizeof(short) : 0); + if (m_dwStyle & DS_SETFONT || m_dwStyle & DS_SHELLFONT) { + dwSize += sizeof(WORD) + (m_bExtended ? sizeof(short) + 2*sizeof(BYTE) : 0); AddStringOrIdSize(m_szFont); } diff --git a/Source/DialogTemplate.h b/Source/DialogTemplate.h index 27fc9bdb..91681cb3 100644 --- a/Source/DialogTemplate.h +++ b/Source/DialogTemplate.h @@ -58,6 +58,8 @@ struct DialogItemTemplate { WORD wCreateDataSize; }; +#pragma pack(push, 1) + typedef struct { WORD dlgVer; WORD signature; @@ -73,15 +75,17 @@ typedef struct { typedef struct { DWORD helpID; - DWORD exStyle; + DWORD exStyle; DWORD style; short x; short y; short cx; short cy; WORD id; + WORD _miscrosoft_docs_are_wrong; } DLGITEMTEMPLATEEX; +#pragma pack(pop) class CDialogTemplate { public: @@ -124,7 +128,8 @@ private: // Only if DS_FONT style is set short m_sFontSize; short m_sFontWeight; // Extended only - bool m_bItalic; // Extended only + BYTE m_bItalic; // Extended only + BYTE m_bCharset; // Extended only char* m_szFont; // Items vector diff --git a/Source/script.cpp b/Source/script.cpp index e610b27f..590461ca 100644 --- a/Source/script.cpp +++ b/Source/script.cpp @@ -1236,7 +1236,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line, FILE *fp, const char init_res_editor(); // Search for required items - #define SEARCH(x) if (!UIDlg.GetItem(x)) {ERROR_MSG("Error: Can't find %s (%u) in the custom UI!\n", #x, x);return 0;} + #define SEARCH(x) if (!UIDlg.GetItem(x)) {ERROR_MSG("Error: Can't find %s (%u) in the custom UI!\n", #x, x);return PS_ERROR;} #define SAVE(x) if (rtl) {UIDlg.ConvertToRTL(); dlg = UIDlg.Save(dwSize);} else dwSize = UIDlg.GetSize(); res_editor->UpdateResource(RT_DIALOG, x, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), dlg, dwSize); BYTE* dlg = 0;