Jump to content

skyzoframe[hun]

Members
  • Content Count

    20
  • Joined

  • Last visited

Community Reputation

1 Neutral

About skyzoframe[hun]

  • Birthday 11/07/1984

Technical Information

  • Delphi-Version
    Delphi 10.4 Sydney

Recent Profile Visitors

358 profile views
  1. skyzoframe[hun]

    Create a bitmap of selected control?

    Hi, I have almost the same question. How to get ListView item width and height in runtime? Create bitmap on fly.: check WorkStation00.rar
  2. skyzoframe[hun]

    TListView OnItemClick problems

    I think everything goes wrong, when you want to use "ListView1.SearchVisible :=True" properities. ListView indexes are then unusable. If the ListView Index must be the same as the database index, then I use the tag properties. item := ListView1.Items.Add; item.Index := YourDatabaseIndex; // (After the search, it will be changed!) item.Tag := YourDatabaseIndex; //integer // or item.Objects.FindObjectT<TListItemText>('INDEX').Text := YourDatabaseIndex.ToString; //and if you search, and wanted the selected item database indexes procedure TForm2.ListView1ItemClickEx(const Sender: TObject; ItemIndex: Integer; const LocalClickPos: TPointF; const ItemObject: TListItemDrawable); begin Label1.text := Itemindex.ToString; (After the search, it will be changed!) Label2.Text := Listview1.Selected.Tag.ToString; end;
  3. skyzoframe[hun]

    Interbase Trigger

    Change after insert to before insert. https://docwiki.embarcadero.com/InterBase/2020/en/The_Trigger_Body
  4. skyzoframe[hun]

    TListView OnItemClick problems

    Here what I use.: by the way.. I don't know, if it works on iOS. Android was fine for me. unit ListViewTap; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Controls.Presentation, FMX.StdCtrls, FMX.ListView.Types, FMX.ListView.Appearances, FMX.ListView.Adapters.Base, FMX.ListView, FMX.Objects, FMX.TabControl, FireDAC.Stan.Intf, FireDAC.Stan.Option, FireDAC.Stan.Error, FireDAC.UI.Intf, FireDAC.Phys.Intf, FireDAC.Stan.Def, FireDAC.Stan.Pool, FireDAC.Stan.Async, FireDAC.Phys, FireDAC.Phys.IB, FireDAC.Phys.IBDef, FireDAC.FMXUI.Wait, Data.DB, FireDAC.Comp.Client; type TForm1 = class(TForm) ListView01: TListView; lbError: TLabel; sbtExit01 : TSpeedButton; sbtShowAll: TSpeedButton; procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); private { Private declarations } public procedure MainSetup; {$IFDEF ANDROID} procedure SetupGestures_ListView01; procedure Gestures_ListView01(Sender: TObject; const EventInfo: TGestureEventInfo; var Handled: Boolean); {$ELSE} {$IFDEF MSWINDOWS} procedure ListView01Click(Sender: TObject); {$ENDIF} {$ENDIF} end; var Form1: TForm1; implementation {$R *.fmx} {$R *.LgXhdpiPh.fmx ANDROID} {$R *.Surface.fmx MSWINDOWS} //uses SharedGlobals, CRUDL_Work20; {$region 'FormCreate & FormDestroy'} procedure TForm1.FormCreate(Sender: TObject); begin MainSetup; {$IFDEF ANDROID} lbError.Text := 'Android'; ListView01.OnGesture := Self.Gestures_ListView01; {$ELSE} {$IFDEF MSWINDOWS} lbError.Text := 'MSWindows'; ListView01.OnClick := Self.ListView01Click; {$ENDIF} {$ENDIF} end; procedure TForm1.FormDestroy(Sender: TObject); begin // do something end; procedure TForm1.sbtExit01Click(Sender: TObject); begin {$IFDEF ANDROID} Application.Terminate; {$ENDIF} {$IFDEF MSWINDOWS} // mtWarning -> Warns the user about a potential issue. // mtError -> Informs the user of an error that occurred. // mtInformation -> Provides information to the user. // mtConfirmation -> Ask the user for confirmation. // mtCustom -> None of the above. if MessageDlg('Realy exit?', TMsgDlgType.mtConfirmation, [TMsgDlgBtn.mbYes,TMsgDlgBtn.mbNo], 0) = mrYes then begin Application.Terminate; end; {$ENDIF} end; procedure TForm1.MainSetup; begin {$IFDEF ANDROID} sbtShowAll.TintColor := TAlphaColors.Aqua; {$ENDIF} {$IFDEF MSWINDOWS} sbtShowAll.IsPressed := Boolean(1); {$ENDIF} end; {$region 'Android_Setup'} {$IFDEF ANDROID} procedure TForm1.SetupGestures_ListView01; begin ListView01.Touch.InteractiveGestures := [TInteractiveGesture.DoubleTap, //Similar to a double-click. One of the basic survival rules in ZombieLand. //TInteractiveGesture.TwoFingerTap, // The "Two Finger Tap" gesture; requires two fingers. //TInteractiveGesture.PressAndTap, // The "Press And Tap" gesture; requires two fingers, one to hold pressed and one to tap. TInteractiveGesture.LongTap]; // The "Long Tap" gesture (also known as "Tap and hold", "Long Press" or "Press"); requires just one finger. Elicits a command such as Copy (for a picture), text editing commands or the TMagnifierGlass (for TMemo). end; procedure TForm1.Gesture_ListView01(Sender: TObject; const EventInfo: TGestureEventInfo; var Handled: Boolean); begin if ListView01.Selected <> nil then begin case EventInfo.GestureID of igiLongTap : begin lbError.Text := ('Long Tap: ' + ListView01.Selected.Index.ToString); //do something end; igiDoubleTap: begin lbError.Text := ('Double Tap: ' + ListView01.Selected.Index.ToString); //do something end; end; end; end; {$ENDIF} {$endregion} {$region 'MSWindows_setup'} {$IFDEF MSWINDOWS} procedure TForm1.ListView01Click(Sender: TObject); begin lbError.Text := 'Click'; end; {$ENDIF} {$endregion} end.
  5. if you have problems with "Thousand Separators", remove it from the string! if (ContainsText(sString, ',')) and (ContainsText(sString, '.')) then begin if (fs.ThousandSeparator=',') then sString := StringReplace(sString,',','',[rfReplaceAll, rfIgnoreCase]) else if (fs.ThousandSeparator='.') then sString := StringReplace(sString,'.','',[rfReplaceAll, rfIgnoreCase]); end; hm.. it is stupid... if string="1,1546.98" and ThousandSeparator=',' then result="1,154698"
  6. function StrToInt00(sString:String; out f : Float32):Boolean; var fs:TFormatSettings; begin try try GetLocaleFormatSettings(LOCALE_SYSTEM_DEFAULT, fs); // remove space if ContainsText(sString, ' ') then sString := StringReplace(sString,' ','',[rfReplaceAll, rfIgnoreCase]); if ContainsText(sString, ',') then begin if fs.DecimalSeparator='.' then sString := StringReplace(sString,',','.',[rfReplaceAll, rfIgnoreCase]); end else if ContainsText(sString, '.') then begin if fs.DecimalSeparator=',' then sString := StringReplace(sString,'.',',',[rfReplaceAll, rfIgnoreCase]); end; finally f := StrToFloat(sString); Result := True; end; except Result := False; end; end;
  7. nope... i mean change!! ctrl+c - ctrl+v copy code sample, then change it... ^^
  8. procedure TForm2.Button2Click(Sender: TObject); var Bool : Boolean; Bool01 : Boolean; begin Bool := false; Bool01 := Boolean(0); Button2.Text:=Bool.ToString+' - '+Bool01.ToString; end; // Boolean(0) equivalent False; // Boolean(1) equivalent True; // the reason is simple.. I am too lazy to change true-to false , write 1-to 0 is much faster. //
  9. hi, one solution from the infinity. // on login form. procedure TFormLogin.Log(uiMessage: String); var TimeStamp : TDateTime; begin TimeStamp := Now; TMemo_Log.lines.add('--'+DateTimeToStr(TimeStamp)+sLineBreak +uiMessage); end; // write to file.. procedure TFormLogin.FormDestroy(Sender: TObject); var BOM: WideChar; FS: TFileStream; WS: WideString; I: Integer; begin log(']---[Program Close]---['+sLineBreak +'-----------------------------'+sLineBreak +'Server='+f_ip+sLineBreak +'Port='+f_port+sLineBreak +'RoleName='+rolename+sLineBreak +'SharedGlobals.DataBase='+SharedGlobals.DataBase+sLineBreak +'Protocol='+Protocol+sLineBreak +'CharacterSet='+CharacterSet+sLineBreak +'ExtendedMetadata='+ExtendedMetadata+sLineBreak +'-----------------------------'+sLineBreak +'DB name='+LOGONNAME+sLineBreak +'DB password='+LOGONPASSWORD+sLineBreak +'ui name='+LOGINNAME+sLineBreak +'ui password='+LOGINPASSWORD+sLineBreak +'-----------------------------'); // write out to file! FS := TFileStream.Create('.\ini\Log.txt', fmCreate); try BOM := WideChar($FEFF); FS.WriteBuffer(BOM, SizeOf(BOM)); For I := 0 to mLog.Lines.Count-1 do begin WS := WideString( mLog.Lines[I] + sLineBreak); FS.WriteBuffer(PWideChar(WS)^, Length(WS) * SizeOf(WideChar)); end; finally FS.DisposeOf; end; end; /// then every time you use Showmessage('fcuk.. it is wrong..'); /// cal FormLogin.Log('nope.. error here.. or something'); {$region 'Business Logic'} // check every success and failed database talc.. like.: function TdmWork19.GetMGR_WP(aList: dmTombMGR_WP; out Error: String): Boolean; var fSor : dmSorMGR_WP; Qcon : TFDConnection; Q : TFDQuery; calc : Float32; n:integer; begin Error := ''; Qcon := TFDConnection.Create(Self); try FormLogin.DBCon(QCon); Q := TFDQuery.Create(Self); try Q.Connection := Qcon; try if aList<>nil then begin Q.SQL.Text := ('select '+sLineBreak +' extract(year from ITEM_DONE) as ForYear, '+sLineBreak +' extract(month from ITEM_DONE) as ForMonth, '+sLineBreak +' extract(day from ITEM_DONE) as ForDay, '+sLineBreak +' Count(ITEM_Z) as db, '+sLineBreak +' sum(ITEM_Z) as fm '+sLineBreak +'from MGR_WP '+sLineBreak +'group by ForDay'+sLineBreak +'order by ForYear desc, ForMonth desc, ForDay desc'); Q.Open; try if Q.IsEmpty then begin Error := Error+'Database empty'; FormLogin.Log(Error); //here save out Result := Boolean(0); end else begin aList.Clear; n:=0; while not Q.Eof do begin fSor.FORYEAR := Q.FieldByName('FORYEAR').AsInteger; fSor.FORMONTH := Q.FieldByName('FORMONTH').AsInteger; fSor.FORDAY := Q.FieldByName('FORDAY').AsInteger; fSor.DB := Q.FieldByName('DB').AsInteger; calc:= Q.FieldByName('FM').AsInteger; fSor.FM := trunc(calc/10); aList.Add(fSor); Q.Next; inc(n,1); end; Error:=Error+sLineBreak+'records number.: '+n.Tostring; FormLogin.Log(Error); Result := Boolean(1); end; finally Q.Close; end; end; except on E : Exception do begin Error := Error+sLineBreak+'n='+n.Tostring+sLineBreak+('GetMGR_WP'+sLineBreak+'Exception class name = '+E.ClassName+SLineBreak+'Exception message = '+E.Message); FormLogin.Log(Error); Result := Boolean(0); end; end; finally Q.DisposeOf; end; finally Qcon.DisposeOf; end; end; {$endregion} {$region 'user interface'} //here check if your user build-up interface object is good or wrong. procedure TMunkaAllomas_19.GetListView1; var uiError : String; item : TListViewItem; fSor : dmSorMGR_WP; f : Float32; dt : TDateTime; DayName : String; ev,honap,nap : word; begin if GetData.GetMGR_WP(FdmTombMGR_WP,uiError)=Boolean(1) then begin ListView1.ApplyStyleLookup; ListView1.Items.Clear; ListView1.BeginUpdate; try try for fSor in FdmTombMGR_WP do begin item := ListView1.Items.Add; try ev := Word(fSor.FORYEAR); honap := Word(FSor.ForMonth); nap := Word(FSor.ForDay); finally dt := EncodeDate(ev, honap,nap); end; if SharedGlobals.WeekEndCheck(dt,DayName)=Boolean(1) then begin item.Objects.FindObjectT<TListItemText>('DATUM').Text := DateTimeToStr(DT); item.Objects.FindObjectT<TListItemText>('NAP').Text := DayName end else begin item.Objects.FindObjectT<TListItemText>('DATUM').Text := DateTimeToStr(DT); item.Objects.FindObjectT<TListItemText>('NAP').Text := DayName end; item.Objects.FindObjectT<TListItemText>('DB').Text := fSor.DB.ToString+' [db] alkatrész.'; f:= FSor.FM; item.Objects.FindObjectT<TListItemText>('FM').Text := Format('%.3f', [(f/1000)])+' [fm] anyag.'; end; finally ListView1.EndUpdate; end; except on E : Exception do begin uiError:=uiError+sLineBreak+('ListView1'+sLineBreak+'Exception class name = '+E.ClassName+SLineBreak+'Exception message = '+E.Message); FormLogin.Log(uiError); end; end; end else ShowMessage(uiError); end; {$endregion}
  10. skyzoframe[hun]

    Binary data in String?

    Extended version.: https://en.wikipedia.org/wiki/ISO/IEC_8859-2 Here "ő" and "ű" aren't missing.
  11. skyzoframe[hun]

    FMX TListView with dynamicappearance. Create progress bar as bitmap.

    Mistake here.: procedure TForm2.FormDestroy(Sender: TObject); Var rec : dmRecord; begin try for rec in FArray do begin if rec.mStr_Flag=Boolean(1) then rec.mStr.DisposeOf; end; finally //FArray.Clear; FArray.DisposeOf; // missing line end; end; OR procedure TForm2.FormDestroy(Sender: TObject); begin try GetData.dmArray_CLEAR(FArray); finally FArray.DisposeOf; end; end;
  12. Maybe create a TMemo and save here every log information. And before the program closed, save it out to file. {$IFDEF MSWINDOWS} procedure Form1.Log(uiMessage: String); var TimeStamp : TDateTime; begin TimeStamp := Now; Memo1.lines.add('--'+DateTimeToStr(TimeStamp)+sLineBreak +uiMessage); end; procedure Form1.FormDestroy(Sender: TObject); var BOM: WideChar; FS: TFileStream; WS: WideString; I: Integer; begin FS := TFileStream.Create('.\ini\Log.txt', fmCreate); try BOM := WideChar($FEFF); FS.WriteBuffer(BOM, SizeOf(BOM)); For I := 0 to Memo1.Lines.Count-1 do begin WS := WideString( Memo1.Lines[I] + sLineBreak); FS.WriteBuffer(PWideChar(WS)^, Length(WS) * SizeOf(WideChar)); end; finally FS.DisposeOf; end; end; {$ENDIF} How to do it on Android?
  13. Hi, I need examples for error handling strategies. Does anyone have any advice? (Log every success and failed procedure or function.)
  14. skyzoframe[hun]

    FMX TListView with dynamicappearance. Create progress bar as bitmap.

    Check here the rar file. In data module you can see, how to build up in runtime the query for data source usage. Here usually I use synchronized threads. In user interface I handle every data sources in dynamic arrays. You all right, I don't use livebindings and live database connections. Live bindings for me is like "tying hands".
  15. skyzoframe[hun]

    FMX TListView with dynamicappearance. Create progress bar as bitmap.

    Or, y := 5; //x := 200; x := trunc(Listview1.Width-50); and it will be responsive for window resize.: Problem step.: 5.- By the way. Is there another method to get object width, in runtime? "TAppearanceListViewItem(ListView1.Items.Add).Objects.FindObjectT<TListItemImage>('IMAGE').Width"
×