AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren

Horizontales anklickbares Menü bauen

Ein Thema von v2afrank · begonnen am 28. Aug 2012 · letzter Beitrag vom 28. Aug 2012
 
Benutzerbild von Bummi
Bummi

Registriert seit: 15. Jun 2010
Ort: Augsburg Bayern Süddeutschland
3.470 Beiträge
 
Delphi XE3 Enterprise
 
#4

AW: Horizontales anklickbares Menü bauen

  Alt 28. Aug 2012, 12:57
Noch nicht in eine Komponente gegossen, aber vielleicht willst Du das ja tun ...
Delphi-Quellcode:
unit Test;
///20120828 by Thomas Wassermann
interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls;

type

  TReginfo=Record
      Caption:String;
      Color:TColor;
      SelColor:TColor;
      RGN:HRGN;
      Rec:TRect;
      Selected:Boolean;
  End;
  TReginfoArray=Array of TReginfo;

  TForm5 = class(TForm)
    PaintBox1: TPaintBox;
    procedure PaintBox1Paint(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure PaintBox1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  private
    { Private-Deklarationen }
    FReginfoArray:TReginfoArray;
    procedure Clicked(index: Integer);
  public
    { Public-Deklarationen }
  end;

var
  Form5: TForm5;

implementation

{$R *.dfm}
Const
 C_SW=200;

procedure TForm5.FormCreate(Sender: TObject);

var
 c:TCanvas;
 i:Integer;
begin
   SetLength(FReginfoArray,3);
   FReginfoArray[0].Color := clGreen;
   FReginfoArray[0].SelColor := clLime;
   FReginfoArray[0].Caption := 'Lasche1';
   FReginfoArray[1].Color := clNavy;
   FReginfoArray[1].SelColor := clBlue;
   FReginfoArray[1].Caption := 'Lasche2';
   FReginfoArray[2].Color := clRed;
   FReginfoArray[2].SelColor := clYellow;
   FReginfoArray[2].Caption := 'Lasche3';
   c := paintbox1.Canvas;
   for I := Low(FReginfoArray) to High(FReginfoArray) do
      begin
         BeginPath(c.Handle);
         MoveToEx(c.Handle, i*C_SW, 0, nil);
         AngleArc(c.Handle,(i+1)*C_SW, Paintbox1.Height div 2, Paintbox1.Height div 2, 90 ,-180);
         AngleArc(c.Handle,(i )*C_SW , Paintbox1.Height div 2, Paintbox1.Height div 2, -90 ,180);
         EndPath(c.Handle);
         FReginfoArray[i].RGN := PathToRegion(c.Handle);
         FReginfoArray[i].Rec := Rect(i*C_SW,0,(i+1)*C_SW,Paintbox1.Height);
      end;

end;

procedure TForm5.FormDestroy(Sender: TObject);
var
 i:Integer;
begin
  for I := Low(FReginfoArray) to High(FReginfoArray) do
    begin
         DeleteObject(FReginfoArray[i].RGN);
    end;
end;

procedure TForm5.Clicked(index:Integer);
begin
    Showmessage(FReginfoArray[index].Caption);
end;

procedure TForm5.PaintBox1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
 i:Integer;
begin
    for I := Low(FReginfoArray) to High(FReginfoArray) do
      begin
        FReginfoArray[i].Selected := PtInRegion(FReginfoArray[i].RGN,x,y);
        PaintBox1.Invalidate;
        if PtInRegion(FReginfoArray[i].RGN,x,y) then Clicked(i);

      end;
end;

procedure TForm5.PaintBox1Paint(Sender: TObject);
var
  c:TCanvas;
  I:Integer;
begin
   c := TpaintBox(Sender).Canvas;
   c.Font.Size := 14;
   for I := Low(FReginfoArray) to High(FReginfoArray) do
      begin
         C.Brush.Style := bsSolid;
         if FReginfoArray[i].Selected then c.Brush.Color := FReginfoArray[i].SelColor else c.Brush.Color := FReginfoArray[i].Color;
         PaintRgn(c.Handle,FReginfoArray[i].RGN);
         AngleArc(c.Handle,(i+1)*C_SW, Paintbox1.Height div 2, Paintbox1.Height div 2, 90 ,-180);
         AngleArc(c.Handle,(i )*C_SW , Paintbox1.Height div 2, Paintbox1.Height div 2, -90 ,180);
         C.Brush.Style := bsClear;
         c.TextRect(FReginfoArray[i].Rec,FReginfoArray[i].Caption,[tfCenter,tfVerticalCenter,tfSingleLine]);
      end;
end;

end.
Angehängte Grafiken
Dateityp: png Bild 1.png (33,7 KB, 51x aufgerufen)
Dateityp: png Bild 2.png (32,7 KB, 42x aufgerufen)
Angehängte Dateien
Dateityp: zip Lasche.zip (1,7 KB, 11x aufgerufen)
Thomas Wassermann H₂♂
Das Problem steckt meistens zwischen den Ohren
DRY DRY KISS
H₂ (wenn bei meinen Snipplets nichts anderes angegeben ist Lizenz: WTFPL)
  Mit Zitat antworten Zitat
 

Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 06:32 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz