당연히 델파이에서 잘 됩니다.
지금 올릴 컴포넌트 소스는 저희회사 업무상 개발을 한것이죠.
단, 핵심부분만 올려드리겠습니다.
저작권이 저희 회사에 있으므로 이것을 사용하시려면 허가를 받아주시기 바랍니다.
단지 기술의 공유를 위해 이곳에 올립니다.
procedure TScrollLabel.MouseMove(Shift: TShiftState; X, Y: Integer);
// 스크롤 시킨다.
// 텍스트의 맨끝과 맨처음인지를 검사해서 표시할 수 있게..
//---------------------------------------------------------------------------
begin
inherited;
if (ssLeft in Shift) or (ssRight in Shift) then
begin
Cursor := crHandGrib;
Windows.SetCursor( Screen.Cursors[Cursor] );
ScrollY := ScrollY + ( (y - ScrollY) - OldPos.y );
if ( fScrollHeight + ScrollY - (Height - 10) ) < 0 then
begin
EndOfText := true;
ScrollY := -( fScrollHeight - (Height - 10) );
end else EndOfText := false;
if ScrollY >= 0 then
begin
StartOfText := true;
ScrollY := 0
end else StartOfText := false;
ScrollX := ScrollX + ( (X - ScrollX) - OldPos.X);
if ( fScrollWidth + ScrollX - (Width - 10) ) < 0 then
begin
EndOfTextR := true;
ScrollX := -( fScrollWidth - (Width - 10) );
end else EndOfTextR := false;
if ScrollX >= 0 then
begin
StartOfTextR := true;
ScrollX := 0
end else StartOfTextR := false;
Paint;
end else
begin
Cursor := crHandFlat;
Windows.SetCursor( Screen.Cursors[Cursor] );
end;
end;
procedure TScrollLabel.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
// 현재위치를 저장하고 커서를 바꾼다.
//---------------------------------------------------------------------------
begin
inherited ;
OldPos.y := y - ScrollY;
OldPos.X := X - ScrollX; // 철현이가 오른쪽, 왼쪽으로도 스크롤이 가능하게 고친부분
Cursor := crHandGrib;
Windows.SetCursor( Screen.Cursors[Cursor] );
end;
//---------------------------------------------------------------------------
procedure TScrollLabel.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
// 커서를 되돌린다.
//---------------------------------------------------------------------------
begin
inherited;
Cursor := crHandFlat;
Windows.SetCursor( Screen.Cursors[Cursor] );
end;
procedure TScrollLabel.Paint;
// 출력하는 부분.. : 배경이미지와 글자를 합성해서 출력.
// tempBitmap에 우선 배경이미지를 그림.
// 배경이 그려진 tempBitmap위에 글자를 출력.
// 합성된 tempBitmap를 출력.
//---------------------------------------------------------------------------
const
Alignments: array[TAlignment] of Word = (DT_LEFT, DT_RIGHT, DT_CENTER);
WordWraps: array[Boolean] of Word = (0, DT_WORDBREAK);
var Rect : TRect;
tempBitmap : TBitmap;
Lucifer : TTextMetric;
begin
inherited;
AdjustBounds;
// 합성하기위한 중간 비트맵의 생성.
// 글자가 캔바스에 꽉차는 것을 막기위해서
// 20만큼씩 작게.
tempBitmap := TBitmap.Create;
tempBitmap.width := Width + 10; {---------}
tempBitmap.Height := Height + 10; {---------}
// 배경이미지를 tempBitmap에 그린다.
if fBackImage <> nil then
tempBitmap.Canvas.Draw(
-( Left + 10 - fBackImage.Left ),
-( Top + 10 - fBackImage.Top ),
fBackImage.Picture.Bitmap
)
else
begin
tempBitmap.Canvas.Brush.Color := TForm(Owner).Color;
tempBitmap.Canvas.FillRect(ClientRect);
end;
with tempBitmap.Canvas do
begin
// 글자가 투명하게 보이도록.
Brush.Style := bsClear;
// 글자가 뿌려질 영역을 지정.
Rect := ClientRect;
Rect.Right := Rect.Right - 10;
// 스크롤을 위해서 Top을 조정.
if fScrollHeight < tempBitmap.Height then
begin
If (ScrollY <> 0) or (Height > fBitmap.Height) then
ScrollY := ( ( Height - 10 ) div 2) - ( fScrollHeight div 2 ) - (Font.Height div 2);
end;
Rect.Top := ScrollY;
{******************************************************************************}
gettextmetrics(Canvas.Handle, Lucifer);
if fScrollWidth < TempBitmap.Width then
begin
If (ScrollX <> 0) or (Width > fBitmap.Width) then
ScrollX := ( width div 2) - ( fScrollWidth div 2 ) - (Lucifer.tmAvecharWidth div 2);
end;
Rect.Left := ScrollX;
{******************************************************************************}
if not fBitmap.Empty then
begin
TempBitmap.Canvas.CopyMode := cmSrcAnd;
TempBitmap.Canvas.Draw(ScrollX, ScrollY, fBitmap);
end else
begin
// 글자그리기.
DoDrawText(
tempBitmap.Canvas,
Rect,
DT_EXPANDTABS or WordWraps[FWordWrap] or DT_NOPREFIX or Alignments[FAlignment]
);
end;
end;
// 합성된 이미지를 출력.
Canvas.Draw(10, 10, tempBitmap);
// 비트맵 해제.
tempBitmap.Free;
// 테두리 꾸미기.
DrawBound(Canvas, ClientRect);
// 영역 재조정.
AdjustBounds;
end;
도움이 되시려나 모르겠네요...
완저히 동작이 되는 컴포넌트는 저희회사로 연락을 주시면 안내해 드리겠습니다.
ㄴ
521-7900 입니다.. 전 이정욱 이구요... ^^;
|