여러가지 방법이 있겠지요..
몇가지 적어봅니다.
1. DrawText 사용
TBitmap * p = Image1->Picture->Bitmap;
p->Width = Image1->Width;
p->Height = Image1->Height;
TRect Rect;
Rect.Left = 0;
Rect.Top = 0;
Rect.Right = p->Width;
Rect.Bottom = p->Height;
DrawText(p->Canvas->Handle, L"출력할 문자열" , -1, &Rect, DT_SINGLELINE|DT_VCENTER|DT_CENTER);
2. TextRect 사용
unsigned oldalign = SetTextAlign(sgEdata->Canvas->Handle, TA_CENTER);
sgEdata->Canvas->TextRect(Rect, (Rect.Right+Rect.Left)/2, 0, "출력할 문자열");
SetTextAlign(p->Canvas->Handle, oldalign);
3. TextOut 사용
TBitmap * p = Image1->Picture->Bitmap;
p->Width = Image1->Width;
p->Height = Image1->Height;
AnsiString sStr = "출력할 문자열";
int nTextW = p->Canvas->TextWidth(sStr); // 문자열 넓이
int nTextH = p->Canvas->TextHeight(sStr); // 문자열 높이
int nStartW = (p->Width - nTextW) / 2; // 좌우 가운데 정렬하기 위한 시작점 찾기
int nStartH = (p->Height - nTextH) / 2; // 상하 가운데 정렬하기 위한 시작점 찾기
p->Canvas->TextOut(nStartW, nStartH, sStr);
김동석 님이 쓰신 글 :
: p->Canvas->TextOutA( 10, 10, 'Test' );
:
: 이런식으로 글을 써주고있는데요.
:
: 이렇게 할 경우 좌표를 정해줘야하고 중앙정렬이 되지않아
:
: TextOut을 사용하려 합니다.
:
: void __fastcall TextRect(const Types::TRect &Rect, int X, int Y, const AnsiString Text)/* overload */;
: void __fastcall TextRect(Types::TRect &Rect, AnsiString &Text, TTextFormat TextFormat = TTextFormat() )/* overload */;
:
: 위에 식으로는 똑같이 영역안에 좌표설정인거 같아 밑에 것으로 사용하려 하는데
:
: TTextFormat을 어찌 넣어줘야 할지 모르겠네요.
:
: p->Canvas->TextRect( rt, "test", tfCenter );
: E2285 Could not find a match for 'TCanvas::TextRect(TRect,const char *,TTextFormats)'
:
: p->Canvas->TextRect( rt, "test", [ tfCenter ] );
: E2188 Expression syntax
:
: