Sayfayı Yazdır | Pencereyi Kapat

butonun içinde panel kullanımı

Nereden Yazdırıldığı: Clomosy | Forum
Kategori: Genel Programlama
Forum Adı: Genel İşlemler
Forum Tanımlaması: TRObject dili ile programlama yaparken karşılaşılan genel işlemler
URL: https://forum.clomosy.com.tr/forum_posts.asp?TID=707
Tarih: 07 Ocak 2025 Saat 23:59
Program Versiyonu: Web Wiz Forums 12.07 - https://www.webwizforums.com


Konu: butonun içinde panel kullanımı
Mesajı Yazan: zeynep irem
Konu: butonun içinde panel kullanımı
Mesaj Tarihi: 22 Temmuz 2024 Saat 13:42
  var
  Form1: TclStyleForm;
  btnS: TclProButton;
  vScroll: TCLVertScrollBox;
  BtnCaptionArr, BtnNameArr, btnImgArr: array of String;
  i: Integer;
  trfPanel: TclProPanel;
  Panels: array[0..4] of TclProPanel; 

procedure ShowPanel(index: Integer);
var
  j: Integer;
begin
  // Tüm panelleri gizle
  for j := 0 to 4 do
  begin
    Panels[j].Visible := False;
  end;

  // Belirli paneli görünür yap
  Panels[index].Visible := True;
end;

procedure BtnOnClick(Sender: TObject);
var
  clickedBtn: TClProButton;
  index: Integer;
begin
  clickedBtn := TClProButton(Sender);

  
  for index := 0 to 4 do
  begin
    if clickedBtn.Name = BtnNameArr[index] then
    begin
      ShowPanel(index);
      Break;
    end;
  end;
end;

begin
  Form1 := TclStyleForm.Create(Self);
  Form1.SetFormColor('#ffffff', '', clGNone);
  Form1.clSetCaption('Menu Listesi');


  vScroll := Form1.AddNewVertScrollBox(Form1, 'ScrollBoxY');
  vScroll.Align := alMostTop;
  vScroll.Height := Form1.ClientHeight - 50; 


  BtnNameArr := ['btntkrdg', 'btnpd', 'btnkbk', 'btnhşmrm', 'btnkstnkbb'];
  BtnCaptionArr := ['Tekirdağ Köftesi', 'Tahinli Pide', 'Kabak Tatlısı', 'Höşmerim', 'Kestane Kebabı'];
  btnImgArr := [' https://www.yemektarifi.com/wp-content/uploads/2018/10/Tekirda%C4%9F-K%C3%B6ftesi-Tarifi-1.jpg" rel="nofollow - https://www.yemektarifi.com/wp-content/uploads/2018/10/Tekirda%C4%9F-K%C3%B6ftesi-Tarifi-1.jpg ',
                ' https://cdn.yemek.com/mncrop/940/625/uploads/2021/08/tahinli-pide-kucuk.jpg" rel="nofollow - https://cdn.yemek.com/mncrop/940/625/uploads/2021/08/tahinli-pide-kucuk.jpg ',
                ' https://iasbh.tmgrup.com.tr/6ebbab/650/344/0/0/752/395?u=https://isbh.tmgrup.com.tr/sbh/2020/04/24/kabak-tatli-tarifi-kabak-tatlisi-nasil-yapilir-1587752707126.jpg" rel="nofollow - https://iasbh.tmgrup.com.tr/6ebbab/650/344/0/0/752/395?u=https://isbh.tmgrup.com.tr/sbh/2020/04/24/kabak-tatli-tarifi-kabak-tatlisi-nasil-yapilir-1587752707126.jpg ',
                ' https://www.mutfagimdantarifler.com/wp-content/uploads/2017/02/hosmerim.jpg" rel="nofollow - https://www.mutfagimdantarifler.com/wp-content/uploads/2017/02/hosmerim.jpg ',
                ' https://i.pinimg.com/736x/d5/98/52/d59852ab2c5da1f001d4e17fb19f2d8e.jpg" rel="nofollow - https://i.pinimg.com/736x/d5/98/52/d59852ab2c5da1f001d4e17fb19f2d8e.jpg '];

  for i := 0 to 4 do
  begin
  
    btnS := Form1.AddNewProButton(vScroll, BtnNameArr, BtnCaptionArr);
    btnS.Align := AlTop;
    btnS.Height := 150;
    btnS.Margins.Bottom := 5;
    btnS.clProSettings.IsFill := True;
    btnS.clProSettings.FontSize := 14;
    btnS.clProSettings.FontColor := clAlphaColor.clHexToColor('#000000');
    btnS.clProSettings.TextSettings.Font.Style := [fsBold, fsItalic];
    btnS.clProSettings.BackgroundColor := clAlphaColor.clHexToColor('#f2eeed');
    btnS.clProSettings.FontVertAlign := palLeading;
    btnS.clProSettings.FontHorzAlign := palCenter;
    btnS.clProSettings.PictureSource := btnImgArr;
    btnS.clProSettings.PictureAutoFit := True;
    btnS.SetclProSettings(btnS.clProSettings);
    btnS.Name := BtnNameArr
    Form1.AddNewEvent(btnS, tbeOnClick, 'BtnOnClick');

    Panels := TclProPanel.Create(Form1);
    Panels.Parent := Form1;
    Panels.SetBounds(50, 50 + i * 310, 400, 300); // Panelin konumu ve boyutu
    Panels.BorderWidth := 2;
    Panels.BorderColor := clAlphaColor.clHexToColor('#000000');
    Panels.RoundHeight := 10;
    Panels.RoundWidth := 10;
    Panels.Visible := False; 
  end;

  ShowPanel(0);
  Form1.Run;
end;
// kodun ' if clickedBtn.Name = BtnNameArr[index] then' kısmında sebebini çözemediğim bir hata alıyorum (kodda yapmak istediğim şey dizi şeklinde butonlarım var ve bu butonlara basıldığında bir panel açmasını istiyorum.)



Cevaplar:
Mesajı Yazan: Developer
Mesaj Tarihi: 22 Temmuz 2024 Saat 14:53
Merhaba Zeynep İrem,
Aşağıdaki kodu inceler misin?
 var
  Form1: TclStyleForm;
  btnS: TclProButton;
  vScroll: TCLVertScrollBox;
  BtnCaptionArr, BtnNameArr, btnImgArr: array of String;
  i: Integer;
  trfPanel: TclProPanel;
  Panels: array[0..4] of TclProPanel; 

procedure ShowPanel(index: Integer);
var
  j: Integer;
begin
  // Tüm panelleri gizle
  for j := 0 to 4 do
  begin
    Panels[j].Visible := False;
  end;

  // Belirli paneli görünür yap
  Panels[index].Visible := True;
end;

procedure BtnOnClick;
var
  clickedBtn: TClProButton;
  index: Integer;
begin
  clickedBtn := TClProButton(Form1.clSender);
  for index := 0 to 4 do
  begin
    if clickedBtn.caption = BtnNameArr[index] then
    begin
      ShowPanel(index);
      Break;
    end;
  end;
end;

begin
  Form1 := TclStyleForm.Create(Self);
  Form1.SetFormColor('#ffffff', '', clGNone);
  Form1.clSetCaption('Menu Listesi');


  vScroll := Form1.AddNewVertScrollBox(Form1, 'ScrollBoxY');
  vScroll.Align := alMostTop;
  vScroll.Height := Form1.ClHeight - 50; 


  BtnNameArr := ['btntkrdg', 'btnpd', 'btnkbk', 'btnhşmrm', 'btnkstnkbb'];
  BtnCaptionArr := ['Tekirdağ Köftesi', 'Tahinli Pide', 'Kabak Tatlısı', 'Höşmerim', 'Kestane Kebabı'];
  btnImgArr := [' https://www.yemektarifi.com/wp-content/uploads/2018/10/Tekirda%C4%9F-K%C3%B6ftesi-Tarifi-1.jpg" rel="nofollow - https://www.yemektarifi.com/wp-content/uploads/2018/10/Tekirda%C4%9F-K%C3%B6ftesi-Tarifi-1.jpg ',
                ' https://cdn.yemek.com/mncrop/940/625/uploads/2021/08/tahinli-pide-kucuk.jpg" rel="nofollow - https://cdn.yemek.com/mncrop/940/625/uploads/2021/08/tahinli-pide-kucuk.jpg ',
                ' https://iasbh.tmgrup.com.tr/6ebbab/650/344/0/0/752/395?u=https://isbh.tmgrup.com.tr/sbh/2020/04/24/kabak-tatli-tarifi-kabak-tatlisi-nasil-yapilir-1587752707126.jpg" rel="nofollow - https://iasbh.tmgrup.com.tr/6ebbab/650/344/0/0/752/395?u=https://isbh.tmgrup.com.tr/sbh/2020/04/24/kabak-tatli-tarifi-kabak-tatlisi-nasil-yapilir-1587752707126.jpg ',
                ' https://www.mutfagimdantarifler.com/wp-content/uploads/2017/02/hosmerim.jpg" rel="nofollow - https://www.mutfagimdantarifler.com/wp-content/uploads/2017/02/hosmerim.jpg ',
                ' https://i.pinimg.com/736x/d5/98/52/d59852ab2c5da1f001d4e17fb19f2d8e.jpg" rel="nofollow - https://i.pinimg.com/736x/d5/98/52/d59852ab2c5da1f001d4e17fb19f2d8e.jpg '];

  for i := 0 to 4 do
  begin
    // .GETITEM methodu TCLARRAYSTRING veya TCLARRAYINTEGER gibi clomosy array objelerinde
    // bunlar normal array
    //btnS := Form1.AddNewProButton(vScroll, ''+BtnNameArr.getItem(i)+'', ''+BtnCaptionArr.getItem(i)+'');
    btnS := Form1.AddNewProButton(vScroll, ''+BtnNameArr+'', ''+BtnCaptionArr+'');
    btnS.Align := AlTop;
    btnS.Height := 150;
    btnS.Margins.Bottom := 5;
    btnS.clProSettings.IsFill := True;
    btnS.clProSettings.FontSize := 14;
    btnS.clProSettings.FontColor := clAlphaColor.clHexToColor('#000000');
    btnS.clProSettings.TextSettings.Font.Style := [fsBold, fsItalic];
    btnS.clProSettings.BackgroundColor := clAlphaColor.clHexToColor('#f2eeed');
    btnS.clProSettings.FontVertAlign := palLeading;
    btnS.clProSettings.FontHorzAlign := palCenter;
    btnS.clProSettings.PictureSource := btnImgArr;
    btnS.clProSettings.PictureAutoFit := True;
    btnS.SetclProSettings(btnS.clProSettings);
    btnS.caption := BtnNameArr
    Form1.AddNewEvent(btnS, tbeOnClick, 'BtnOnClick');

    Panels := Form1.AddNewProPanel(Form1, 'panel'+IntToStr(i));
    Panels.clProSettings.BorderWidth := 2;
    Panels.clProSettings.BorderColor := clAlphaColor.clHexToColor('#000000');
    Panels.clProSettings.RoundHeight := 10;
    Panels.clProSettings.RoundWidth := 10;
    Panels.Visible := False; 
    Panels.SetclProSettings(Panels.clProSettings);
  end;

  ShowPanel(0);
  Form1.Run;
end;


Mesajı Yazan: zeynep irem
Mesaj Tarihi: 23 Temmuz 2024 Saat 09:06
//btnS := Form1.AddNewProButton(vScroll, ''+BtnNameArr.getItem(i)+'', ''+BtnCaptionArr.getItem(i)+''); 
bu satır yorum satırı olmasına rağmen burda hata veriyor satırı silince bile
 begin
    btnS := Form1.AddNewProButton(vScroll, ''+BtnNameArr+'', ''+BtnCaptionArr+'');
satırındaki begin kısmında hata alıyorum


Mesajı Yazan: Developer
Mesaj Tarihi: 23 Temmuz 2024 Saat 15:08
Merhaba Zeynep,
Düzeltmeleri yaptık. Kontrol eder misin?
 var
  Form1: TclStyleForm;
  btnS: TclProButton;
  vScroll: TCLVertScrollBox;
  BtnCaptionArr, BtnNameArr, btnImgArr: array of String;
  i: Integer;
  trfPanel: TclProPanel;
  Panels: array[0..4] of TclProPanel; 

procedure ShowPanel(index: Integer);
var
  j: Integer;
begin
  // Tüm panelleri gizle
  for j := 0 to 4 do
  begin
    Panels[j].Visible := False;
  end;

  // Belirli paneli görünür yap
  Panels[index].Visible := True;
end;

procedure BtnOnClick;
var
  clickedBtn: TClProButton;
  index: Integer;
begin
  clickedBtn := TClProButton(Form1.clSender);

  
  for index := 0 to 4 do
  begin
    if clickedBtn.Caption = BtnNameArr[index] then
    begin
      ShowPanel(index);
      Break;
    end;
  end;
end;

begin
  Form1 := TclStyleForm.Create(Self);
  Form1.SetFormColor('#ffffff', '', clGNone);
  Form1.clSetCaption('Menu Listesi');


  vScroll := Form1.AddNewVertScrollBox(Form1, 'ScrollBoxY');
  vScroll.Align := alMostTop;
  vScroll.Height := Form1.ClHeight - 50; 


  BtnNameArr := ['btntkrdg', 'btnpd', 'btnkbk', 'btnhşmrm', 'btnkstnkbb'];
  BtnCaptionArr := ['Tekirdağ Köftesi', 'Tahinli Pide', 'Kabak Tatlısı', 'Höşmerim', 'Kestane Kebabı'];
  btnImgArr := [' https://www.yemektarifi.com/wp-content/uploads/2018/10/Tekirda%C4%9F-K%C3%B6ftesi-Tarifi-1.jpg" rel="nofollow - https://www.yemektarifi.com/wp-content/uploads/2018/10/Tekirda%C4%9F-K%C3%B6ftesi-Tarifi-1.jpg ',
                ' https://cdn.yemek.com/mncrop/940/625/uploads/2021/08/tahinli-pide-kucuk.jpg" rel="nofollow - https://cdn.yemek.com/mncrop/940/625/uploads/2021/08/tahinli-pide-kucuk.jpg ',
                ' https://iasbh.tmgrup.com.tr/6ebbab/650/344/0/0/752/395?u=https://isbh.tmgrup.com.tr/sbh/2020/04/24/kabak-tatli-tarifi-kabak-tatlisi-nasil-yapilir-1587752707126.jpg" rel="nofollow - https://iasbh.tmgrup.com.tr/6ebbab/650/344/0/0/752/395?u=https://isbh.tmgrup.com.tr/sbh/2020/04/24/kabak-tatli-tarifi-kabak-tatlisi-nasil-yapilir-1587752707126.jpg ',
                ' https://www.mutfagimdantarifler.com/wp-content/uploads/2017/02/hosmerim.jpg" rel="nofollow - https://www.mutfagimdantarifler.com/wp-content/uploads/2017/02/hosmerim.jpg ',
                ' https://i.pinimg.com/736x/d5/98/52/d59852ab2c5da1f001d4e17fb19f2d8e.jpg" rel="nofollow - https://i.pinimg.com/736x/d5/98/52/d59852ab2c5da1f001d4e17fb19f2d8e.jpg '];

  for i := 0 to 4 do
  begin
  
    btnS := Form1.AddNewProButton(vScroll, BtnNameArr, BtnCaptionArr);
    btnS.Align := AlTop;
    btnS.Height := 150;
    btnS.Margins.Bottom := 5;
    btnS.clProSettings.IsFill := True;
    btnS.clProSettings.FontSize := 14;
    btnS.clProSettings.FontColor := clAlphaColor.clHexToColor('#000000');
    btnS.clProSettings.TextSettings.Font.Style := [fsBold, fsItalic];
    btnS.clProSettings.BackgroundColor := clAlphaColor.clHexToColor('#f2eeed');
    btnS.clProSettings.FontVertAlign := palLeading;
    btnS.clProSettings.FontHorzAlign := palCenter;
    btnS.clProSettings.PictureSource := btnImgArr;
    btnS.clProSettings.PictureAutoFit := True;
    btnS.SetclProSettings(btnS.clProSettings);
    btnS.Caption := BtnNameArr
    Form1.AddNewEvent(btnS, tbeOnClick, 'BtnOnClick');

    Panels := Form1.AddNewProPanel(Form1, 'Panel'+IntToStr(i));
    Panels.clProSettings.BorderWidth := 2;
    Panels.clProSettings.BorderColor := clAlphaColor.clHexToColor('#000000');
    Panels.clProSettings.RoundHeight := 10;
    Panels.clProSettings.RoundWidth := 10;
    Panels.Visible := False; 
  end;

  ShowPanel(0);
  Form1.Run;
end;



Mesajı Yazan: zeynep irem
Mesaj Tarihi: 23 Temmuz 2024 Saat 16:03
// Maalesef tekrardan aynı yerde hata veriyor.
var
  Form1: TclStyleForm;
  btnS: TclProButton;
  vScroll: TCLVertScrollBox;
  BtnCaptionArr, BtnNameArr, btnImgArr: array of String;
  i: Integer;
  trfPanel: TclProPanel;
  Panels: array[0..4] of TclProPanel;

procedure ShowPanel(index: Integer);
var
  j: Integer;
begin
  // Tüm panelleri gizle
  for j := 0 to 4 do
  begin
    Panels[j].Visible := False;
  end;

  // Belirli paneli görünür yap
  Panels[index].Visible := True;
end;

procedure BtnOnClick;
var
  clickedBtn: TClProButton;
  index: Integer;
begin
  clickedBtn := TClProButton(Form1.clSender);

 
  for index := 0 to 4 do
  begin
    if clickedBtn.Caption = BtnNameArr[index] then
    begin
      ShowPanel(index);
      Break;
    end;
  end;
end;

begin
  Form1 := TclStyleForm.Create(Self);
  Form1.SetFormColor('#ffffff', '', clGNone);
  Form1.clSetCaption('Menu Listesi');


  vScroll := Form1.AddNewVertScrollBox(Form1, 'ScrollBoxY');
  vScroll.Align := alMostTop;
  vScroll.Height := Form1.ClHeight - 50;


  BtnNameArr := ['btntkrdg', 'btnpd', 'btnkbk', 'btnhşmrm', 'btnkstnkbb'];
  BtnCaptionArr := ['Tekirdağ Köftesi', 'Tahinli Pide', 'Kabak Tatlısı', 'Höşmerim', 'Kestane Kebabı'];
  btnImgArr := [' https://www.yemektarifi.com/wp-content/uploads/2018/10/Tekirda%C4%9F-K%C3%B6ftesi-Tarifi-1.jpg" rel="nofollow - https://www.yemektarifi.com/wp-content/uploads/2018/10/Tekirda%C4%9F-K%C3%B6ftesi-Tarifi-1.jpg ',
                ' https://cdn.yemek.com/mncrop/940/625/uploads/2021/08/tahinli-pide-kucuk.jpg" rel="nofollow - https://cdn.yemek.com/mncrop/940/625/uploads/2021/08/tahinli-pide-kucuk.jpg ',
                ' https://iasbh.tmgrup.com.tr/6ebbab/650/344/0/0/752/395?u=https://isbh.tmgrup.com.tr/sbh/2020/04/24/kabak-tatli-tarifi-kabak-tatlisi-nasil-yapilir-1587752707126.jpg" rel="nofollow - https://iasbh.tmgrup.com.tr/6ebbab/650/344/0/0/752/395?u=https://isbh.tmgrup.com.tr/sbh/2020/04/24/kabak-tatli-tarifi-kabak-tatlisi-nasil-yapilir-1587752707126.jpg ',
                ' https://www.mutfagimdantarifler.com/wp-content/uploads/2017/02/hosmerim.jpg" rel="nofollow - https://www.mutfagimdantarifler.com/wp-content/uploads/2017/02/hosmerim.jpg ',
                ' https://i.pinimg.com/736x/d5/98/52/d59852ab2c5da1f001d4e17fb19f2d8e.jpg" rel="nofollow - https://i.pinimg.com/736x/d5/98/52/d59852ab2c5da1f001d4e17fb19f2d8e.jpg '];

  for i := 0 to 4 do
  begin
 
    btnS := Form1.AddNewProButton(vScroll, BtnNameArr, BtnCaptionArr);
    btnS.Align := AlTop;
    btnS.Height := 150;
    btnS.Margins.Bottom := 5;
    btnS.clProSettings.IsFill := True;
    btnS.clProSettings.FontSize := 14;
    btnS.clProSettings.FontColor := clAlphaColor.clHexToColor('#000000');
    btnS.clProSettings.TextSettings.Font.Style := [fsBold, fsItalic];
    btnS.clProSettings.BackgroundColor := clAlphaColor.clHexToColor('#f2eeed');
    btnS.clProSettings.FontVertAlign := palLeading;
    btnS.clProSettings.FontHorzAlign := palCenter;
    btnS.clProSettings.PictureSource := btnImgArr;
    btnS.clProSettings.PictureAutoFit := True;
    btnS.SetclProSettings(btnS.clProSettings);
    btnS.Caption := BtnNameArr;
    Form1.AddNewEvent(btnS, tbeOnClick, 'BtnOnClick');

    Panels := Form1.AddNewProPanel(Form1, 'Panel'+IntToStr(i));
    Panels.clProSettings.BorderWidth := 2;
    Panels.clProSettings.BorderColor := clAlphaColor.clHexToColor('#000000');
    Panels.clProSettings.RoundHeight := 10;
    Panels.clProSettings.RoundWidth := 10;
    Panels.Visible := False;
  end;

  ShowPanel(0);
  Form1.Run;
end;
--------------------------------------------------------------------
TclStyleForm
RUNTIME ERROR
Invalid variant type conversion when evaluating instruction CallProc ($FFFFFFFF,$3,$1BC0EA8,$BD0EFE0,'AddNewProButton').
Stack content is: [(unknown),Null,0,Null...].
Source position: 64,70
Position: 64, 70
Clomosy Build : 20240709.111531



Mesajı Yazan: Developer
Mesaj Tarihi: 01 Ağustos 2024 Saat 11:07
Merhaba Zeynep,
Hatan hala devam ediyor mu?



Sayfayı Yazdır | Pencereyi Kapat

Forum Software by Web Wiz Forums® version 12.07 - https://www.webwizforums.com
Copyright ©2001-2024 Web Wiz Ltd. - https://www.webwiz.net