-
Content Count
1406 -
Joined
-
Last visited
-
Days Won
22
Everything posted by programmerdelphi2k
-
here my screenshots to prove that my code works: the copies was done in the same HDD: NOW USING EMBARCADERO ISO RAD 11.2 = +6GBytes MSWindows copy-file (by Explorer), time: +/- 4/5mins My (slow) procedure using TFileStream, time: +/- 10mins or more (I forgot see the clock at begin 🙂 (let's say: 15minutes for dont be wrong at all) CPU usage: < 10% at 3.8GHertz with all MSWindows apps on memory: antivirus, chrome, RAD 11.2, etc... MEM usage: < 4GB in sometime < yet
-
TStack<T>.Peek deeper than the topmost element
programmerdelphi2k replied to dummzeuch's topic in RTL and Delphi Object Pascal
sorry, but really I dont see it... fixing now! -
TStack<T>.Peek deeper than the topmost element
programmerdelphi2k replied to dummzeuch's topic in RTL and Delphi Object Pascal
using "System.Generics.Collections" or "System.Contnrs"? uses // System.Contnrs; System.Generics.Collections; var MyStackList: TStack<TButton>; // MyStackList: TStack; procedure TForm1.Button1Click(Sender: TObject); var i: integer; begin // System.Generics.Collections.pas MyStackList := TStack<TButton>.Create; try // MyStackList.TEnumerator ... // i := MyStackList.Count - 2; // before last if (i >= 0) then MyStackList.List[ ...i...] .Caption := 'hello world'; // // MyStackList.Push( buttonX ) // MyStackList.Pop; // MyStackList.Peek; // MyStackList.Count; // *************************// // System.Contnrs.pas; // MyStackList.AtLeast( n ) // MyStackList.Push() // add // MyStackList.Pop; //remove e return // MyStackList.Peek; // next on list, no remove // MyStackList.Count // how many finally MyStackList.Free; end; end; -
@robertjohns really, I dont know what to say for you... My PC have 16GBytes RAM, CPU i7 4770K Intel, HDD 1TBytes, Antitivirus online, RAD 11.2 Embarcadero, Chrome (hungry for mem)... The unique real problem is "the time"... because the tech is not the most indicated for this task!... (just compare with MSWindows copy-file... it's very so fast than my code) Another problem is: my code it's not "multi-tasks / multi-processor" then, of course, it's so slow for 5GBytes... but it's really does not matter for me, because I really dont use it for nothing here! it was just for show you something...
-
my procedure works like expected! tested with file +5GBytes!!! RAD11.2 ISO file and tested if the same-file with profetional tool to compare it! the HASH file returns the equal values between "my copy" and ISO Embarcadero! On MSWindows 10 64bit, you need to pay attention to the buffer size, and not use too large a value. Well, a buffer larger than 16MBytes didn't show efficiency during the file copy, due to the way that MSWindows performs the cache during the data copy! Most likely, because MSWindows uses much more advanced techniques than my "simple code" presented here! After all, MSWindows is made by engineers, and I'm not one!
-
Error F2048 bad unit using wrong DCC32 in MSBUILD?
programmerdelphi2k replied to H05's topic in Delphi IDE and APIs
I remove any new try, you dont merece any oneapparently the error is not only in your IDE, but also in your way of acting. I'm pulling out before this evil spreads across my screen -
try this: function MyMinValue(const A, B: integer): integer; begin result := A; // if (A > B) then result := B; end; procedure TForm1.Button1Click(Sender: TObject); var MyFileStreamSource: TFileStream; MyFileStreamTarget: TFileStream; MyFileSourceSize : int64; MyBuffer : TBytes; // array of byte; MyBufferSize : integer; begin // See on Help about more infos: fmOpenRead, fmCreate, fmShareExclusive, etc... // DeleteFile('d:\newfile.mp4'); // MyFileStreamSource := TFileStream.Create('d:\bohemian-rhapsody-queen-how-to-play-guitar.mp4', fmOpenRead or fmShareExclusive); try MyFileSourceSize := MyFileStreamSource.Size; MyBufferSize := MyMinValue(512, MyFileSourceSize); // SetLength(MyBuffer, MyBufferSize); // MyFileStreamTarget := TFileStream.Create('d:\newfile.mp4', fmCreate or fmShareExclusive); try MyFileStreamSource.Position := 0; // while (MyFileSourceSize > 0) do begin MyFileStreamSource.Read(MyBuffer[0], MyBufferSize); // read and put on the next position... // // what to do with MyBuffer values... // MyFileStreamTarget.Write(MyBuffer[0], MyBufferSize); // write and put on the next position... // Dec(MyFileSourceSize, MyBufferSize); // MyBufferSize := MyMinValue(512, MyFileSourceSize); // NOTE: verify this value, if ok .. end; finally MyFileStreamTarget.Free; end; finally MyFileStreamSource.Free; end; // ShowMessage('end'); end;
-
ANN: Open Source Event Bus NX Horizon
programmerdelphi2k replied to Dalija Prasnikar's topic in Delphi Third-Party
@juergen as this topic is about "specific" subject from Dalija, I will send a private message with a simple project with 3 forms showing like do it: each "Observer" should subscribe itself a "Subscriber" list each "Subscriber" should have methods to "notify" who is "observing" the changes to centralizate all messages, you can use a "container" or any other way to "receive" and "send" the messages for all or some! an "Observer" can be a "Subscriber" a "Subscriber" can be a "Observer" but you need controls how all works for avoid conflicts of interest, for that, you can use the "container" like mid-term between it! for better job, you use "2 interfaces (IObservers and Observables - or any other name that desire )" for concentrate all methods necessary to dialog between class envolved! -
and if... using "FloatToStrF(...), System.SysUtils, line 19060 on RAD11.2 (using SetString internal function)
-
How to connect to wss:// server ?
programmerdelphi2k replied to wright's topic in ICS - Internet Component Suite
for your security, never publish "keys", like "APIKey" on public! -
Error F2048 bad unit using wrong DCC32 in MSBUILD?
programmerdelphi2k replied to H05's topic in Delphi IDE and APIs
more one prove that it's not recommended "Copy/Paste" from code found on interner! use a code that you dont "domains" basic concept, it's another error! if you need learn, do it with simples samples, and with time, add more functions... at end, maybe, you domains it you question, is your answer! ...have 10.4 and 11 installed... Another, the RAD always use enviroment variables "out" and "in"; out: PATH variable from O.S. anothers in "batch" files the ordem in "PATH" variable, it's determinant when not expliciting on command-line! in: $(var-name): like $(BDS) ... all this it should be considerated when, you case, trying create a "tool" (batch) to your case. a tip: try see your IDE message when compiling, and try reproduce the commands in your batch-file. when compiling any project you can see this message on "Build" and "Output" windows on bottom screen! for end, the error message is clear: Error F2048 bad unit using wrong DCC32 in MSBUILD? or 11 is using DCUs from 10.4, or else! why? because your PATH variables is appointing to wrong place! -
other way "more" simple yet: create your PopUp options in a "FRAME" - named "myPopUpUsingFrame" - OK! now, in your "form-in-usage" (for example, myFormWithEdits...), on "OnCreate" event... create your "myPopUpUsingFrame" now, in your "form-in-usage", just use "OnMouseDown" to "show your frame-popup" more simple to use, because "in fact" your new-frame will a "child" from your "form-in-usage", then, you can use shortcuts, tab to jump for it etc... procedure TfrmFormMain.FormCreate(Sender: TObject); frmFramePopupMenu := TmyPopUpUsingFrame.Create(nil); frmFramePopupMenu.Visible := false; // hide it for while... frmFramePopupMenu.Parent := self; // to show on current form ... end; procedure TfrmFormMain.FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); var MyActiveControl: TWinControl; begin MyActiveControl := self.ActiveControl; // if (Button = TMouseButton.mbRight) then begin if not(frmFramePopupMenu = nil) then begin frmFramePopupMenu.Left := X; frmFramePopupMenu.Top := Y; // frmFramePopupMenu.Show; // MyActiveControl.SetFocus; end; end;
-
IOS 15.7.1 deployed app get closed immediately once opened
programmerdelphi2k replied to param's topic in FMX
my advice: create a new app with just form and deploy it to test! if run, then, pay attention in your "real" app with all calls done on "create/run" app! note: I dont use IOS/macOS - I dont have it! -
some "enumerates" needs "spacenames" for use, or you can have a "conflict" between same "enumerate name" in many others units! then, try always use "enumarateNameSpaces.enumerateValue", like: TMyEnumX.meTwo other way to use enumerates, if no "out of range" from enumerate in usage, is: implementation /// DELPHI code {$R *.dfm} type TMyEnumX = (meOne, meTwo); // <------- procedure ShowMePlease; var MyEnumX : TMyEnumX; MyVarInt: integer; begin MyVarInt := 4; // <------- it will 5º element, if exists on enumerate type above! // MyEnumX := TMyEnumX( MyVarInt ); // <------- OUT OF RANGE here, but not error! // ShowMessage( Ord(MyEnumX).ToString ); // no errors here!! end; end.
-
I think that my "propose" and TFileStream can solve it! Each step on "stream-buffer", and replace with your "bytes". then it's not necessary "up" all data on memory!
-
here my sample in "7z " compress-files VCL_imitating_a_Popup_with_a_Form.7z each button on myFormPopUp is using an "action" from "ActionList" component! then, you use "actionXXX.Execute" event to create your logic [ not ButtonXXX.click() ] ... my ShowMessage(...) for example!
-
look, if can not buy a suite or you dont find nothing, you try this: project attached !!! VCL_imitating_a_Popup_with_a_Form.7z
-
indy Delphi and INDY: how to send a "DELETE" (the "Delete" button is in HTML page using ASP) to delete a "message" in the forum
programmerdelphi2k replied to programmerdelphi2k's topic in Network, Cloud and Web
I will wait -
My "Execute" on Thread is not called anymore... I'm staying crazy and dont see the my error
programmerdelphi2k posted a topic in Algorithms, Data Structures and Class Design
people, My "Execute" on Thread is not called anymore... I'm staying crazy and dont see the my error the thread is created and released with no-errors, etc.. I "breakpoint it" and dont see nothing to happens... I have the same constructions in anothers project and "Execute" is execute"D" and breakpoint is breakpoint"ED" >:) but new projects (units), does not works anymore I'm staying crazy and dont see my error on code.... help me! type TMyThread = class(TThread) private protected procedure Execute; override; public constructor Create; destructor Destroy; override; end; TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private public end; var Form1: TForm1; implementation {$R *.dfm} { TMyThread } constructor TMyThread.Create; begin inherited Create; // created (be suspended or not) OK! debug end; destructor TMyThread.Destroy; begin inherited; // destroyed OK! debug end; procedure TMyThread.Execute; begin // the "Execute" is not called anymore... it's jumped, same in Debug mode inherited; // or not... end; procedure TForm1.Button1Click(Sender: TObject); var x: TMyThread; begin x := TMyThread.Create; try // x.Start; // if suspended... finally x.Free; end; end; -
@David Schwartz would be some like this: of couse, you will needs create your "class" to better usage this. Look that it's not necessary hack any class. For FMX you can do it with same idea ( I think that is more easy than VCL) NOTE: all panels is aligned on "TOP" {$R *.dfm} var LFormHeight: integer = 0; function MyGetAllChildsHeight(const AControl: TWinControl): integer; begin result := 0; // for var i: integer := 0 to (AControl.ControlCount - 1) do if (AControl.Controls is TPanel) then result := result + TPanel(AControl.Controls).Height; end; procedure MyReSizeAllChilds(const AControl: TWinControl; const APerc: integer); begin for var i: integer := 0 to (AControl.ControlCount - 1) do if (AControl.Controls is TPanel) and (TPanel(AControl.Controls).ShowCaption) then begin AControl.Controls.Height := Trunc(AControl.Controls.Tag * (APerc / 100)); // <---- // for test... TPanel(AControl.Controls).Caption := AControl.Controls.Height.ToString; end; end; procedure TForm1.FormCreate(Sender: TObject); begin // I'm using "Panel2.ShowCaption" just for test [resize it or not in "MyReSizeAllChilds()"] // you'll should have a property for this usage in special!!! // LFormHeight := Self.Height; // ******************************************* preparing childs setup: // *********** panel 1 Panel1.Tag := Panel1.Height; // <--- Panel1.ShowCaption := false; // Edit1.Anchors := [akLeft, akTop, akBottom]; Edit1.Constraints.MinHeight := Edit1.Height; Edit1.Constraints.MaxHeight := Edit1.Height; // ComboBox1.Anchors := [akLeft, akTop, akBottom]; ComboBox1.Constraints.MinHeight := ComboBox1.Height; ComboBox1.Constraints.MaxHeight := ComboBox1.Height; // ListBox1.Anchors := [akLeft, akTop, akBottom]; ListBox1.Constraints.MinHeight := ListBox1.Height; ListBox1.Constraints.MaxHeight := ListBox1.Height; // Memo1.Align := alRight; // // *********** panel 2 Panel2.Tag := Panel2.Height; // <--- Panel2.ShowCaption := true; Panel2.Constraints.MinHeight := 150; // Edit2.Anchors := [akLeft, akTop, akBottom]; Edit2.Constraints.MinHeight := Edit2.Height; Edit2.Constraints.MaxHeight := Edit2.Height; // ComboBox2.Anchors := [akLeft, akTop, akBottom]; ComboBox2.Constraints.MinHeight := ComboBox2.Height; ComboBox2.Constraints.MaxHeight := ComboBox2.Height; // ListBox2.Anchors := [akLeft, akTop, akBottom]; ListBox2.Constraints.MinHeight := ListBox2.Height; // Memo2.Anchors := [akLeft, akTop, akBottom]; Memo2.Constraints.MinHeight := 160; // Self.Constraints.MinHeight := 450; // MyGetAllChildsHeight(Self); end; procedure TForm1.FormResize(Sender: TObject); var LPerc : integer; begin // ******************************************* all logic is here! no needs hack any class // Needs verify: // (n div 0 ) = exception!!! // If "LPerc value it's ok for usage on Height's" // LPerc := Trunc((LFormHeight / Self.Height) * 100); // if (LPerc > 100) then { form is shrinking in size... } LPerc := (100 - (LPerc mod 100)) else if (LPerc < 100) then { ...now it's growing } LPerc := (100 + (100 - LPerc)) else LPerc := 100; // MyReSizeAllChilds(Self, LPerc); end;
-
RAD XE have it?
-
no problem, use the same idea about! read your binary-file as "bytes"... -- see on Help: TStream subclasses, like: TMemoryStream, TStringStream, TFileStream, etc... -- if found the "correspondent values", just store in a other stream (or the same) and when end, just "save to file" --- if a[12] = 123 then a[12]=100;
-
if dont exists, you can do it that way: create a Form to acommodate your options, let's call it: "myFormPopUp" add your components necessary to create your necessity add the events necessary if necessary, use "OnClose" = Action := caFree; using "MouseDown" event in your "form (where you want the "clicks") on screen, just ask to "Show" the "MyFormPopUp" with options simulating a "popup" menu, let's call it: MyFormCustomer = mark the property "KeyPreview=true" for better usage, create the "MyFormPopUp" on create of "MyFormCustomer" or in any other place to global access! when need "hide" the "MyFormPopUp", just use: MyFormPopUp.HIDE; when need "destroy it" the "MyFormPopUp", just use: MyFormPopUp.Close; note: if the "focus" is in any other control, like "TEdit", you need use "OnKeyDown" of Edit control!!! or assing it for all controls on focus! do you understand?
-
maybe, needs test about memory usage, you can open file as "bytes" and in a looping, search your byte sequences! for example using "MemoryStream" search for "xx" bytes .... try find "Bitmap" signature on stream type TMyBuffer = array [0 .. 1] of byte; function MyFindBitmapSignature(AMemoryStream: TStringStream): int64; function MyIsTheSame(const ABuffer: TMyBuffer; const AFind: TMyBuffer): boolean; // better for many bytes comparing begin result := false; // if (Length(ABuffer) <> Length(AFind)) then exit; // for var i: integer := 0 to (Length(ABuffer)-1) do if (ABuffer[..i..] <> AFind[..i..]) then exit(false); // result := true; end; var LBuffer: TMyBuffer; LFind : TMyBuffer; begin result := -1; AMemoryStream.Position := 0; LFind[0] := 66; LFind[1] := 77; // for var i: int64 := 0 to ((AMemoryStream.Size div 2) - 1) do begin AMemoryStream.Read(LBuffer, 2); // if MyIsTheSame(LBuffer, LFind) then exit(i * 2); // (* if (LBuffer[0] = 66) and (LBuffer[1] = 77) then // 'nul, nul,... "BM" ...' begin exit(i * 2); end; *) end; end;
-
ordem to calls: Form1: Loaded, Create, AfterConstruction, FormCreate, FormShow... if there is not others on process, of course! 01 - Create event (before "Inherited") - Self = NOT nil 02 - Create event (before "Inherited") + FValue (Private field on form)= hello world 03 - Loaded (before "Inherited") 04 - Loaded (after "Inherited") 05 - Create event (after "Inherited") 06 - Create event (after "Inherited") - Self = NOT nil 07 - AfterConstruction, before "Inherited" 08 - FormCreate event (before "Inherited") 09 - FormCreate event (after "Inherited") 10 - AfterConstruction, after "inherited" 11 - FormShow event (before "Inherited") 12 - FormShow event (after "Inherited") type TForm1 = class(TForm) Button1: TButton; Memo1: TMemo; procedure FormCreate(Sender: TObject); procedure FormShow(Sender: TObject); procedure Button1Click(Sender: TObject); private FValue: string; public constructor Create(AOwner: TComponent); override; procedure Loaded; override; procedure AfterConstruction; override; end; procedure TForm1.Loaded; begin WhoIsFirst(LText, 'Loaded (before "Inherited")'); inherited; WhoIsFirst(LText, 'Loaded (after "Inherited")'); end; constructor TForm1.Create(AOwner: TComponent); begin FValue := 'hello world'; // WhoIsFirst(LText, 'Create event (before "Inherited")'); inherited; WhoIsFirst(LText, 'Create event (after "Inherited")'); end; procedure TForm1.AfterConstruction; begin WhoIsFirst(LText, 'AfterConstruction, before "Inherited"'); inherited; WhoIsFirst(LText, 'AfterConstruction, after "inherited"'); end; procedure TForm1.FormCreate(Sender: TObject); begin WhoIsFirst(LText, 'FormCreate event (before "Inherited")'); inherited; WhoIsFirst(LText, 'FormCreate event (after "Inherited")'); end; procedure TForm1.FormShow(Sender: TObject); begin WhoIsFirst(LText, 'FormShow event (before "Inherited")'); inherited; WhoIsFirst(LText, 'FormShow event (after "Inherited")'); end;