Sayfayı Yazdır | Pencereyi Kapat

uses ile butona tıklama

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=959
Tarih: 04 Ocak 2025 Saat 11:49
Program Versiyonu: Web Wiz Forums 12.07 - https://www.webwizforums.com


Konu: uses ile butona tıklama
Mesajı Yazan: NadireNurSaglam
Konu: uses ile butona tıklama
Mesaj Tarihi: 12 Kasım 2024 Saat 10:23
Aşağıdaki kodum uLangTopic sayfam:

uses uComponentAdd, uChange;

var
  MyForm:TclForm;
  BodyVertScrollBox,expanderVertScrollBox: TclVertScrollBox;
  BtnSyntax : TclProButton;
  arrowLeftImg,xMarkImg ,okImage,konuImage : TCLImage;
  nameLbl,topicLbl: TClProLabel;
  myExpanderBolum1 : TclExpander;
  mainLyt,contentLyt : TClLayout;
  contentPnl,lvlPanel,clientPanel,oneaskPanel,topPnl :TCLProPanel;
  exitBtnControl,altBaslikSayisi  : Integer;
  groupNameText: String;
  addImage: TClProImage;
  langQuery,qryGroupGlobal,qryThreadGlobal:TCLJSONQuery;
  siranoLbl,altsiranoLbl: TClProLabel;
  IcerikLbl: TClProLabel;
  btnveSiraNoPnl,expanderContentPnl: TCLProPanel;
  topicIndex: Integer; // Sıra numarası için
  tiklananAnaBaslikBtn: TclProButton;
  TiklananButonDeger: String;
  tiklananButonSonDeger: String;
  tik: Boolean;
  kontrol: Integer;
procedure loadQuery;
begin
  qryGroupGlobal:=Clomosy.DBCloudQuery;
  try
  qryThreadGlobal := Clomosy.DBCloudQueryWith(ftThreadsView,'','Thread_Member_GUID ='+QuotedStr(Clomosy.AppUserGUID));
  except
    ShowMessage(clStrToLan('Check your internet connection.|İnternet bağlantınızı kontrol ediniz.'));
  end;
  
end;  

function MainTopUserFinished(topGUId:String):Boolean;
var
clQueryTop,clQuerySub:TCLJSONQuery;
begin
   Result:= False;
    try
      try
    clQueryTop:=Clomosy.ClDataSetFromJSON(qryGroupGlobal.getjsonstring);
    clQueryTop.Filtered:=false;
    clQueryTop.Filter:='OwnerGroup_GUID='+QuotedStr(topGUId);
    clQueryTop.Filtered:=true;
   if clQueryTop.Found then 
    begin
        clQueryTop.First;
        
        while not  clQueryTop.Eof  do
        begin
               
              clQuerySub:=Clomosy.ClDataSetFromJSON(qryThreadGlobal.getjsonstring);
              clQuerySub.Filtered:=false;
              clQuerySub.Filter:=' Group_GUID='+QuotedStr(clQueryTop.FieldByName('Group_GUID').AsString);
              clQuerySub.Filtered:=true;
              if clQuerySub.Found then
              begin
                if clQuerySub.FieldByName('Thread_Value_Float').AsString='1' then
                begin
                      result:=True;
                end else
                begin
                    Result:= false;
                    break;
                end;
              end else
              begin
                Result:= false;
                break;
              end;
             clQueryTop.Next;   
        end;
 
    end;
    except
    ShowMessage('Hata: uLangTopic- MainTopUserFinished');
    end;
    finally
      clQueryTop.Free;
      clQuerySub.Free;
    end
end;
  

function UserDataControl(groupGUID:string):Boolean;
  var 
    clQueryUser:TCLJSONQuery;
  begin
              try
                  try   
              result:=False;
              clQueryUser:=Clomosy.ClDataSetFromJSON(qryThreadGlobal.getjsonstring);
              clQueryUser.Filtered:=false;
              clQueryUser.Filter:=' Group_GUID='+QuotedStr(groupGUID);
              clQueryUser.Filtered:=true;

                if clQueryUser.Found then
                begin           
                      if clQueryUser.FieldByName('Thread_Value_Float').AsString='1' then 
                      begin
                         Result := True;
                         //ShowMessage('Kullanici Sinavi bitirmemistir.');
                      end else
                      begin
                         //ShowMessage('Kullanici sinava girmistir.');
                         Result := False;
                      end;
                end;
                except
                ShowMessage('Hata: uLangTopic- UserDataControl');
                end;
              finally
                       clQueryUser.Free;
              end;
  end; 

procedure expanderContenttopicLblOnClick;
var
  getsourceList : TclStringList;
begin
             try
                try
                getsourceList := Clomosy.StringListNew;//tstringlist.Create yerine;
                getsourceList.StrictDelimiter := True;
              getsourceList.Delimiter := '|';
              getsourceList.DelimitedText := Clomosy.GlobalVariableString;
                //Clomosy.GlobalVariableInteger:=StrToInt(Clomosy.StringListItemString(getsourceList,0));
                Clomosy.GlobalVariableString:= Clomosy.StringListItemString(getsourceList,0);  
                Clomosy.GlobalVariableString:=Clomosy.GlobalVariableString+'|'+ TCLLayout(MyForm.Clsender).Hint; //Dil_ID + Alt_Baslik_ID
                Clomosy.RunUnit('TopicPage');
                MyForm.clHide;
              except
              ShowMessage('Hata: uLangtopic - expanderContenttopicLblOnClick');
              ShowMessage('expanderContenttopicLblOnClick Exception Class: '+LastExceptionClassName+' Exception Message: '+LastExceptionMessage);
              end;
            finally
                   getsourceList.Free;
            end;
end;

procedure GetSubTopics(ATopTopicGUID:string);
var
  clSubQuery:TCLJSONQuery;
  count: Integer;

begin
  try
    try
    
      count := 0;

      clSubQuery := Clomosy.ClDataSetFromJSON(qryGroupGlobal.getjsonstring);
      clSubQuery.Filtered := false;
      clSubQuery.Filter := 'OwnerGroup_GUID=' + QuotedStr(ATopTopicGUID);
      clSubQuery.Filtered := true;

      with clSubQuery do
      begin
        if Found then
        begin
          First;

          while not EOF do
          begin
            count := count + 1;
             
            expanderContentPnl := MyForm.AddNewProPanel(contentPnl, 'expanderContentPnl' + IntToStr(altBaslikSayisi));
            expanderContentPnl.Align := alMostTop;
            expanderContentPnl.Height := 40;

            topicLbl := uComponentAdd.addProLbl(MyForm,expanderContentPnl, 'btnco' + IntToStr(altBaslikSayisi),FieldByName(groupNameText).AsString,0,
            0,0,0,0,0,'#000000','','',16,0,0,0);            
            topicLbl.Align := alClient;
           
            topicLbl.clProSettings.TextSettings.Font.Style := [fsBold];
            topicLbl.clProSettings.FontHorzAlign := palLeading;
            topicLbl.clProSettings.FontVertAlign := palCenter;
            topicLbl.SetclProSettings(topicLbl.clProSettings);  
            topicLbl.Hint := FieldByName('Group_GUID').AsString;
            MyForm.AddNewEvent(topicLbl, tbeOnClick, 'expanderContenttopicLblOnClick');

            altsiranoLbl := uComponentAdd.addProLbl(MyForm,expanderContentPnl, 'altsiranoLbl' + IntToStr(altBaslikSayisi), IntToStr(topicIndex+1),
            40,40,0,0,0,25,'#ffffff','#f7b646','',14,20,20,1);            
            altsiranoLbl.Align:=alLeft;
            altsiranoLbl.clProSettings.TextSettings.Font.Style:= [fsBold];
            altsiranoLbl.clProSettings.FontVertAlign:= palcenter;
            altsiranoLbl.clProSettings.FontHorzAlign:= palcenter;
            altsiranoLbl.clProSettings.bordercolor:=clAlphaColor.clnull;
            altsiranoLbl.SetclProSettings(altsiranoLbl.clProSettings);
            
              if UserDataControl(FieldByName('Group_GUID').AsString) then
              begin
                  //clComponent.SetupComponent(addImage,'{"ImgUrl":"'+FieldByName('Group_ImageSmall').AsString+'"}');
                  altsiranoLbl.clProSettings.BackgroundColor:= clAlphaColor.clHexToColor('#27c1a0');
                  altsiranoLbl.clProSettings.FontColor:= clAlphaColor.clHexToColor('#ffffff');
                  altsiranoLbl.SetclProSettings(altsiranoLbl.clProSettings);  
              end;
                  
            Inc(topicIndex);
            Inc(altBaslikSayisi);

            Next;
          end;
         
        end;
        topicIndex:=0
      end;
      
    except
      ShowMessage('GetSubTopics Exception Class: ' + LastExceptionClassName + ' Exception Message: ' + LastExceptionMessage);
    end;
  finally
    clSubQuery.Free;
  end;
  contentPnl.Height := count*40;

end;


procedure SetBody(ATopicCount:integer;ATopTopicGUID,AGroupName,AGroupImage,AGroupImageSmall:string);
var
  i: integer;
  begin
    try
      
    mainLyt:=MyForm.AddNewLayout(BodyVertScrollBox,'mainLyt'+IntToStr(ATopicCount));
    mainLyt.Align:=almosttop;
    mainLyt.Height:=200;
    mainLyt.Margins.Bottom:=5;
    mainLyt.AutoResize := clVertical;
    

    lvlPanel:=uComponentAdd.addPnl(MyForm,mainLyt,'lvlPanel'+IntToStr(ATopicCount),330,60,10,10,'','','#28c1a3',3,8,8,10,0);
    lvlPanel.Align:= alTop;
    contentPnl:= uComponentAdd.addPnl(MyForm,mainLyt,'contentPnl'+IntToStr(ATopicCount),40,100,10,10,'#ffffff','','',0,5,60,17,0);
    contentPnl.Align:= alTop;
    contentPnl.Visible := False;
    contentPnl.Hint:= IntToStr(ATopicCount);
    
    BtnSyntax:= uComponentAdd.addbtn(MyForm,lvlPanel,'BtnSyntax'+IntToStr(ATopicCount),AGroupName,'',0,0,0,0,60,900,0,0,'#000000','',14,0);
    BtnSyntax.Hint := IntToStr(ATopicCount);
    BtnSyntax.Align:= alClient;
  
    BtnSyntax.clProSettings.FontHorzAlign:=palLeading;
       // BtnSyntax.clProSettings.BackgroundColor:= clAlphaColor.clgreen;
    BtnSyntax.SetclProSettings(BtnSyntax.clProSettings);
    BtnSyntax.CLTagInt := 0;


    //-------------------------başlıktaki '1top' fotoğrafı yerine 1 den başlayarak maddelendirme---------------------------//
    siranoLbl:=uComponentAdd.addProLbl(MyForm,lvlPanel,'siranoLbl'+IntToStr(ATopicCount),IntToStr(ATopicCount+1),45,45,30,8,8,8,'','',
    '#208dff',16,22,22,1);
    siranoLbl.Align:=alLeft;
    siranoLbl.clProSettings.FontVertAlign:= palcenter;
    siranoLbl.clProSettings.FontHorzAlign:= palcenter;
    siranoLbl.clProSettings.TextSettings.Font.Style:= [fsBold];
    siranoLbl.SetclProSettings(siranoLbl.clProSettings);
    
    if MainTopUserFinished(ATopTopicGUID) then
    Begin
    //--------------------------------konu tamamlanırsa renkler değişecek---------------------------//
    siranoLbl.clProSettings.BackgroundColor:= clAlphaColor.clHexToColor('#27c1a0');
    siranoLbl.clProSettings.FontColor:= clAlphaColor.clHexToColor('#ffffff');
    siranoLbl.SetclProSettings(siranoLbl.clProSettings);    
    end;
    
    okImage:= uComponentAdd.addBtnImg(MyForm,lvlPanel,'okImage'+IntToStr(ATopicCount),30,20,0,0,0,0,0,'arrow.png','','','',10,0,True);
    okImage.Align:= alRight;
    okImage.Hint := IntToStr(ATopicCount);
    okImage.CLTagInt := 0;

   
    
    GetSubTopics(ATopTopicGUID);

    except
      ShowMessage('SetBody Exception Class: '+LastExceptionClassName+' Exception Message: '+LastExceptionMessage);
    end;
  end;
  


procedure topTopicClick;
begin
    
 case TclProImage(Myform.Clsender).ClTagInt of
    0:
    begin
      TclProImage(Myform.Clsender).ClTagInt := 1;
      TclProPanel(MyForm.clFindComponent('contentPnl'+TclProImage(Myform.Clsender).Hint)).Visible := True;

    end;
    1:
    begin
      TclProImage(Myform.Clsender).ClTagInt := 0;
      TclProPanel(MyForm.clFindComponent('contentPnl'+TclProImage(Myform.Clsender).Hint)).Visible := False;

    end;
  end;


end; 

procedure tiklandi;
var
clickedBtn: TclProButton;
btnHint : String;
begin
  clickedBtn:= TclProButton(Myform.Clsender);
  btnHint:= clickedBtn.Hint;
  ShowMessage('tiklandi fonk: ' + btnHint);
  uChange.degerDegistir(MyForm,('BtnSyntax'+btnHint));

end;

  procedure GetMainTopics;
  var
    clQueryMain:TCLJSONQuery;
    //qryStr:String;
    topicCount:integer;
  begin
    topicCount := 0;
    try
    clQueryMain:=Clomosy.ClDataSetFromJSON(qryGroupGlobal.getjsonstring);
    clQueryMain.Filtered:=false;
    clQueryMain.Filter:='OwnerGroup_GUID='+QuotedStr(Clomosy.GlobalVariableString);
    clQueryMain.Filtered:=true;
    
      if clQueryMain.Found then
      begin
        clQueryMain.First;
        while not clQueryMain.EOF do
        begin
          try
              SetBody(topicCount,
              clQueryMain.FieldByName('Group_GUID').AsString,
              clQueryMain.FieldByName(''+groupNameText+'').AsString,
              clQueryMain.FieldByName('Group_Image').AsString,
              clQueryMain.FieldByName('Group_ImageSmall').AsString);

              Inc(topicCount);
   
          except
             ShowMessage('GetMainTopics Exception Class: '+LastExceptionClassName+' Exception Message: '+LastExceptionMessage);
          end;
          
            MyForm.AddNewEvent(BtnSyntax,tbeOnClick,'tiklandi');
            MyForm.AddNewEvent(BtnSyntax,tbeOnMouseUp,'topTopicClick');
           
          clQueryMain.Next;
          
        end;

      end;
      finally
        clQueryMain.Free;
      end

  //ShowMessage('if dışında');
  //ShowMessage(uChange.kontrol);
  //ShowMessage(('BtnSyntax'+TclProImage(MyForm.clsender).Hint));

  //ShowMessage(('BtnSyntax'+TclProImage(MyForm.clsender).Hint));
  /*
  if uChange.kontrol =1 then
  begin
  ShowMessage('if içinde');
    ShowMessage(('BtnSyntax'+TclProButton(MyForm.clsender).Hint));

  clDoClick(TclProButton(MyForm.clFindComponent('BtnSyntax'+TclProButton(MyForm.clsender).Hint)));
  uChange.main(0);
  end;*/

  End;
   
procedure goToBack;
begin
  Clomosy.RunUnit('uLanguages');
  MyForm.clHide;
end;

procedure globalValueControl;
var
stringBackValueList : TclStringList;
begin
      try
      try
           
        stringBackValueList := Clomosy.StringListNew;//tstringlist.Create yerine;
        stringBackValueList.StrictDelimiter := True;
        stringBackValueList.Delimiter := '|';
        stringBackValueList.DelimitedText := Clomosy.GlobalVariableString;
        if  stringBackValueList.Count>1 then
        begin
        //Clomosy.GlobalVariableInteger := StrToInt(Clomosy.StringListItemString(stringBackValueList,0));
               Clomosy.GlobalVariableString:= Clomosy.StringListItemString(stringBackValueList,0); 
        end;
        except
        ShowMessage('Hata: uLangTopic- globalValueControl');
        end;
      finally
        stringBackValueList.Free;
      end;
      
  end;

 procedure geriGit;
 begin
  Clomosy.RunUnit('uLanguages');
 end;
 
begin
   globalValueControl;  
   loadQuery;

  MyForm := TclForm.Create(Self);
  TclProButton(MyForm.clFindComponent('BtnGoBack')).Visible :=False;
  TclProButton(MyForm.clFindComponent('BtnFormMenu')).Visible :=False;
  MyForm.SetFormBGImage('bg4.png');
  
  //exitBtnControl := 0;
  //MyForm.AddNewEvent(MyForm,tbeOnFormCloseQuery,'closeQuery');
  
  MyForm.AddNewEvent(MyForm,tbeOnFormClose,'geriGit');
  //getQuery; //product bilgileri
  
  clientPanel:=MyForm.AddNewProPanel(MyForm,'testPanelRow');
  clientPanel.Align:= alContents;
  clientPanel.clProSettings.BackgroundColor:= clAlphaColor.clnull;
  clientPanel.SetclProSettings(clientPanel.clProSettings);
  
  groupNameText := clStrToLan('Group_Name|Group_NameEx');

   
  //          TOP
  
  
  topPnl := uComponentAdd.addPnl(MyForm,clientPanel,'topPnl',0,40,1,1,'','','',0,15,0,0,0);
  topPnl.Align:= almosttop;

  
  //geri butonu
  arrowLeftImg := uComponentAdd.addBtnImg(MyForm, topPnl, 'arrowLeftImg',40,30,2,2,2,10,10,'backBtn.png','','','',0,0,True);
  arrowLeftImg.Align:= alLeft;
  MyForm.AddNewEvent(arrowLeftImg,tbeOnClick,'goToBack');

   // langQuery:=Clomosy.DBCloudQueryWith(ftGroups,'','Group_ID='+IntToStr(Clomosy.GlobalVariableInteger));
    try
    try
      langQuery:=Clomosy.ClDataSetFromJSON(qryGroupGlobal.getjsonstring);
      langQuery.Filtered:=false;
      langQuery.Filter:='Group_GUID='+QuotedStr(Clomosy.GlobalVariableString);
      langQuery.Filtered:=true;
  //   ShowMessage(langQuery.GetJsonString);

      except
      ShowMessage('Hata: uLangTopic- Ana Kod Bloğu');
      end;
    finally
      langQuery.Free;
    end;
  
  //çıkış butonu
  
  xMarkImg:=uComponentAdd.addBtnImg(MyForm,topPnl,'xMarkImg',40,30,2,2,2,10,0,'exitBtn.png','','','',10,0,True);  
  xMarkImg.Align:= alRight;
  
  MyForm.AddNewEvent(xMarkImg,tbeOnClick,'goToBack');
  
  BodyVertScrollBox := MyForm.AddNewVertScrollBox(clientPanel,'Test');
  BodyVertScrollBox.Align := alClient;
  BodyVertScrollBox.Margins.Top := 20;
  topicIndex := 0;
  altBaslikSayisi:=0;
  
  GetMainTopics;

  MyForm.Run;

end;

Yukarıdaki sayfada ana başlıklara tıklayınca alt başlıklar açılıyor. Açılan bu alt başlıklardan herhangi birine tıklandığında yeni bir sayfa olan TopicPage'e geçiyor. Bu sayfadan geri dönüldüğünde tıklanmış olan ana başlığın alt başlıkları açık gelmesi lazım ama tüm alt başlıklar kapalı geliyor. Bunu sağlamak için 'tiklandi' fonksiyonunu yazdım ve başka bir sayfa olan uChange'e tıklanan butonun adını gönderdim. Ama uChange sayfasında butona tıklama işlemini yapabilmem için sanırım birkaç kontrol yapmam lazım ama yapamadım. Şu haliyle tüm alt başlıklar hala kapalı geliyor. Aşağıda uChange sayfasını paylaşıyorum:


 procedure degerDegistir(gelenForm,btnDeger: String);
begin
ShowMessage('degerDegistir de');
ShowMessage(btnDeger);
  //clDoClick(TclProButton(gelenForm.clFindComponent(btnDeger)));

end;




Cevaplar:
Mesajı Yazan: Developer
Mesaj Tarihi: 12 Kasım 2024 Saat 16:27
Merhaba Nadire,
Senin gönderdiğin kodun :
    try
    try
      langQuery:=Clomosy.ClDataSetFromJSON(qryGroupGlobal.getjsonstring);
      langQuery.Filtered:=false;
      langQuery.Filter:='Group_GUID='+QuotedStr(Clomosy.GlobalVariableString);
      langQuery.Filtered:=true;
  //   ShowMessage(langQuery.GetJsonString);

      except
      ShowMessage('Hata: uLangTopic- Ana Kod Bloğu');
      end;
    finally
      langQuery.Free;
    end;
bu kısmında hataya düşüyor.




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