在【神化世界】的开发过程中用到了对于指定控件字体的设置取消,和自己想象的面向对象操作方式不太一致,特别记录下来。
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
int nn=0;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
//set font style to define
nn=1-nn;
if(nn==1)
Label1->Font->Style = TFontStyles()<< fsBold << fsUnderline;
else
Label1->Font->Style = TFontStyles();
}
//---------------------------------------------------------------------------
在《神化世界》的开发中,作者遇到了控件字体设置的问题,具体涉及字体风格的切换,通过TFontStyles类实现标签Label1的粗体和下划线样式动态改变。代码示例展示了非传统面向对象操作的方式。
777

被折叠的 条评论
为什么被折叠?



