procedure TAngleLabel.Paint; VAR TLF : TLogFont; R : TRect; X,Y : Integer; TH, TW, {text width and height} AW, AH : Integer; {width & height of rect enclosing angled label} BEGIN R := ClientRect; GetObject(Font.Handle, SizeOf(TLF), @TLF); TLF.lfEscapement := (((Angle MOD 360) + 360) MOD 360) * 10; WITH Canvas DO BEGIN Font.Handle := CreateFontIndirect(TLF); WITH Brush DO IF NOT Transparent THEN BEGIN Style := bsSolid; Color := Self.Color; END ELSE Style := bsClear; TW := TextWidth(Caption); TH := TextHeight(Caption); Width := TW + 2; Height := TW + 2; END; AW := Round((TW * Cos(Angle*pi/180)) + (TH * Sin(Angle*pi/180))); AH := Round((TW * Cos((Angle+90)*pi/180)) + (TH * Sin((Angle+90)*pi/180))); X := (R.Right-AW) DIV 2; Y := (R.Bottom-AH) DIV 2; if not Enabled then Canvas.Font.Color := clGrayText; Canvas.TextOut(X, Y, Caption); END;
procedure TAngleLabel.CMFontChanged(var Message: TMessage); VAR TTM : TTextMetric; begin Inherited; IF csLoading IN ComponentState THEN Exit; Canvas.Font := Font; { GetTextMetrics(Canvas.Handle, TTM); IF TTM.tmPitchAndFamily AND TMPF_TRUETYPE = 0 THEN BEGIN Font.Name := \'Arial\'; MessageBeep(MB_ICONSTOP); ShowMessage(\'Only TrueType fonts permittted\'); END;} end;
procedure TAngleLabel.MouseMove(var m:twmmouse); var OldTop, OldLeft : Integer; begin inherited; if drag and not EditBoxOpen then begin { if GVars.GOn then begin m.YPos := GVars.GSize * ((m.YPos) div GVars.GSize ); m.XPos := GVars.GSize * ((m.XPos) div GVars.GSize ); end; } top:=top - oldypos+m.ypos; if top < 0 then top := 0; left := left - oldxpos+m.xpos; if left < 0 then left := 0; end; OldTop := Top; OldLeft := Left; end;
procedure TAngleLabel.MouseLdown(var m:TWMMouse); begin if EditMode then if not EditBoxOpen then begin inherited; BringToFront; drag:=true; oldxpos := m.xpos; oldypos := m.ypos; end; end;
procedure TAngleLabel.MouseLUp(var m:twmmouse); begin if not EditBoxOpen then begin inherited; drag:=false end; end;
procedure TAngleLabel.MouseLDBlClk(var m:twmmouse); var OldName, FontStyleString : String; OldSize, OldAngle, OldColor : Integer; begin inherited; //Kode ind her end;
procedure TAngleLabel.SetAngle(Value: TAngle); begin IF Value <> fAngle THEN BEGIN fAngle := Value; Invalidate; END; end;
procedure TAngleLabel.SetLabColor(Value: TLabColor); begin //Kode ind end;
constructor TAngleLabel.Create(AOwner: TComponent); begin Inherited Create(AOwner); ControlStyle := ControlStyle + [csOpaque]; AutoSize := True; Transparent := True; Font.Name := \'Arial\'; if LabText = \'\' then Caption := \'Label\' else Caption := LabText; Font.Size := 10; // Left := 20; // Top := 30; LabColor := 1; end;
procedure TAngleLabel.Paint; VAR TLF : TLogFont; R : TRect; X,Y : Integer; TH, TW, {text width and height} AW, AH : Integer; {width & height of rect enclosing angled label} BEGIN R := ClientRect; GetObject(Font.Handle, SizeOf(TLF), @TLF); TLF.lfEscapement := (((Angle MOD 360) + 360) MOD 360) * 10; WITH Canvas DO BEGIN Font.Handle := CreateFontIndirect(TLF); WITH Brush DO IF NOT Transparent THEN BEGIN Style := bsSolid; Color := Self.Color; END ELSE Style := bsClear; TW := TextWidth(Caption); TH := TextHeight(Caption); Width := TW + 2; Height := TW + 2; END; AW := Round((TW * Cos(Angle*pi/180)) + (TH * Sin(Angle*pi/180))); AH := Round((TW * Cos((Angle+90)*pi/180)) + (TH * Sin((Angle+90)*pi/180))); X := (R.Right-AW) DIV 2; Y := (R.Bottom-AH) DIV 2; if not Enabled then Canvas.Font.Color := clGrayText; Canvas.TextOut(X, Y, Caption); END;
Jeg har lige hentet komponenten TRotateLabel v.1.0
men kan du ikke fortælle mig hvordan jeg installere den ??
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.