|
문자를 입력받아서 중간중간 색상을 변형하려고하는데 잘 안되네요. 아래는 제가 사용한 코드구요.
void __fastcall TForm1::TeButton1Click(TObject *Sender)
{
static int a = 0;
a++;
if(a%3 == 0)
richMsg->SelAttributes->Color = clYellow;
else if ( a%3 ==1)
richMsg->SelAttributes->Color = clRed;
else
richMsg->SelAttributes->Color = clLime;
richMsg->Text = richMsg->Text + "Test";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btnMsgParagraphYellowClick(TObject *Sender)
{
richMsg->SelAttributes->Color = clYellow;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btnMsgParagraphGreenClick(TObject *Sender)
{
richMsg->SelAttributes->Color = clLime;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btnMsgParagraphRedClick(TObject *Sender)
{
richMsg->SelAttributes->Color = clRed;
}
//---------------------------------------------------------------------------
버튼을 누르면 번갈아가면서 붉은색, 노랑, 라임 색이 나와야하는데 무조건 노랑으로 도배되더라구요.
richMsg->SelAttributes->Color = clRed; 이 문구를 실행하고 입력하면 색상이 변하는데, 함수 안에서
if(a%3 == 0)
richMsg->SelAttributes->Color = clYellow; 이런식으로 사용했더니 무조건 노랑으로만 나오는데, 따로 뭐 설정해야하는게 있으면 좀 알려주세요.
|