void CDialog::WriteString(const std::wstring& str, Framework::CStream& stream) { for(wchar_t character : str) { stream.Write16(character); } stream.Write16(0); }
void CDialog::WriteSzOrOrd(const SZ_OR_ORD& szOrOrd, Framework::CStream& stream) { stream.Write16(szOrOrd.isString); if(szOrOrd.isString == 0xFFFF) { stream.Write16(szOrOrd.ord); } else if(szOrOrd.isString != 0) { WriteString(szOrOrd.str, stream); } }
void CDialog::WriteDialogTemplate(DIALOGTEMPLATE& dialog, Framework::CStream& stream) { stream.Write16(dialog.dlgVer); stream.Write16(dialog.signature); stream.Write32(dialog.helpID); stream.Write32(dialog.exStyle); stream.Write32(dialog.style); stream.Write16(dialog.cDlgItems); stream.Write16(dialog.x); stream.Write16(dialog.y); stream.Write16(dialog.cx); stream.Write16(dialog.cy); WriteSzOrOrd(dialog.menu, stream); WriteSzOrOrd(dialog.windowClass, stream); WriteString(dialog.title, stream); stream.Write16(dialog.pointsize); stream.Write16(dialog.weight); stream.Write8(dialog.italic); stream.Write8(dialog.charset); WriteString(dialog.typeface, stream); //Pad struct for alignment to DWORD boundary { auto currentBytePos = stream.Tell() & 0x3; if(currentBytePos != 0) { for(unsigned int i = 0; i < (4 - currentBytePos); i++) { stream.Write8(0); } } assert((stream.Tell() & 0x03) == 0); } if(!dialog.dialogItemData.empty()) { stream.Write(dialog.dialogItemData.data(), dialog.dialogItemData.size()); } }