void __fastcall TPrintList::SaveLayout1Click(TObject *Sender) { if (SaveDialog1->Execute()) { AnsiString filename=SaveDialog1->FileName; TFontStyles style; TIniFile *InitFile=new TIniFile(filename); InitFile->WriteString("Print List Options","Font Name",Memo1->Font->Name); InitFile->WriteInteger("Print List Options","Font Size",Memo1->Font->Size); InitFile->WriteInteger("Print List Options","Font Color",Memo1->Font->Color); style=Memo1->Font->Style; InitFile->WriteBool("Print List Options","Bold",style.Contains(fsBold)); InitFile->WriteBool("Print List Options","Italic",style.Contains(fsItalic)); InitFile->WriteBool("Print List Options","Underline",style.Contains(fsUnderline)); InitFile->WriteBool("Print List Options","Strike Out",style.Contains(fsStrikeOut)); int count=DBGrid1->FieldCount-1; InitFile->WriteInteger("Columns","Count",count); AnsiString head; for(int i=0;i<count;i++) { InitFile->WriteString("ColName"+IntToStr(i),"Name",DBGrid1->Columns->Items[i]->FieldName); InitFile->WriteInteger("ColName"+IntToStr(i),"Width",DBGrid1->Columns->Items[i]->Width); } delete InitFile; } }
//--------------------------------------------------------------------------- void __fastcall TPrintList::FormClose(TObject *Sender, TCloseAction &Action) { TIniFile *InitFile=new TIniFile("CMXed.ini"); AnsiString size,loc; size=IntToStr(ClientWidth)+"X"+IntToStr(ClientHeight); InitFile->WriteString("Print List Form","Window Size",size); loc=IntToStr(Left)+"X"+IntToStr(Top); InitFile->WriteString("Print List Form","Window Location",loc); TFontStyles style; InitFile->WriteString("Print List Options","Font Name",Memo1->Font->Name); InitFile->WriteInteger("Print List Options","Font Size",Memo1->Font->Size); InitFile->WriteInteger("Print List Options","Font Color",Memo1->Font->Color); style=Memo1->Font->Style; InitFile->WriteBool("Print List Options","Bold",style.Contains(fsBold)); InitFile->WriteBool("Print List Options","Italic",style.Contains(fsItalic)); InitFile->WriteBool("Print List Options","Underline",style.Contains(fsUnderline)); InitFile->WriteBool("Print List Options","Strike Out",style.Contains(fsStrikeOut)); delete InitFile; }
//--------------------------------------------------------------------------- // set the style attributes of the text // // warning: I spent days trying to isolate a problem that turned out to be // in this method. the problem was with the original signature, // SetStyle(TFontStyles Value). Sets (TFontStyles is of type Set) // do not always correctly pass unless passed by reference? // // note that this is an inconsistent problem. elsewhere in this project, // passing sets by value works just fine. it may have something to do with // the way TFont works (TFont manages the font resource in a rather odd way). // void __fastcall TTaeTextAttributes::SetStyle(TFontStyles& Value) { TCharFormat Format; InitFormat(Format); Format.dwMask = CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE | CFM_STRIKEOUT; if (Value.Contains(fsBold)) Format.dwEffects |= CFE_BOLD; if (Value.Contains(fsItalic)) Format.dwEffects |= CFE_ITALIC; if (Value.Contains(fsUnderline)) Format.dwEffects |= CFE_UNDERLINE; if (Value.Contains(fsStrikeOut)) Format.dwEffects |= CFE_STRIKEOUT; SetAttributes(Format); }
int FontStylesToInteger(TFontStyles AFontStyles) { int Result = 0; for (int AFontStyle = fsBold; AFontStyle <= fsStrikeOut; AFontStyle++) if (AFontStyles.Contains((TFontStyle)AFontStyle)) Result = Result | (1 << AFontStyle); return Result; }
//--------------------------------------------------------------------------- int __fastcall FontStylesToInt(const TFontStyles value) { int Result = 0; for (int i = fsStrikeOut; i >= fsBold; i--) { Result <<= 1; if (value.Contains((TFontStyle)i)) { Result |= 1; } } return Result; }