Jump to content

programmerdelphi2k

Members
  • Content Count

    1406
  • Joined

  • Last visited

  • Days Won

    22

Everything posted by programmerdelphi2k

  1. programmerdelphi2k

    for i := X to Y inclusive... how?

    @Willicious using your analogy of one set within another, and not the whole set, seems to me similar to what Delphi uses when adding or removing "an item" in an options property, i.e.: AOption := AOption + [ItemX] or AOption := AOption - [ItemX] (or using multiplication, etc...) However, a "Set" is restricted to 256 elements, and, to circumvent this limit, you would have to use a List or Array to store the values, and later compare whether or not they are contained in the container! other hazards could occur in an unattended task... implementation {$R *.dfm} type TMyEnums = (xx1, xx2, xx3, xx4, xx5, xx6, xx7, xx8, xx9, xx10); TMyEnumsSet = set of TMyEnums; procedure TForm1.Button1Click(Sender: TObject); var a: TMyEnumsSet; b: TMyEnumsSet; c: TMyEnumsSet; d: TMyEnums; e: TMyEnums; begin {$R-} // Intersection of Sets d := TMyEnums(11); // out of range, then... {$R-}...{$R+} e := TMyEnums(0); // a := [xx1, xx2, xx3, xx4, xx5, xx6, xx7, xx8, xx9, xx10]; b := [xx2, xx3, d, xx1, xx8, xx2, e]; c := a * b; // = xx1, xx2, xx3, xx8 {$R+} end; end. maybe this post can help to add /remove new elements in Set https://stackoverflow.com/questions/33173534/how-do-i-check-or-change-which-set-elements-are-present-using-rtti
  2. programmerdelphi2k

    for i := X to Y inclusive... how?

    maybe when you run your code in "quantICUM" cpu you can have it! 8 states in 1... for now, just 2 in 1
  3. programmerdelphi2k

    Scanning for files while they are created or deleted

    I think that is better this way: if necessary use "WinApi.Window.XXXXXX" to avoid conflict with others units with function-names, like "FINDClose" in "System.SysUtils and Winapi.Window" function MyFindDeletedFilesOnList(AList: TArray<string>; AValue: string): boolean; begin result := false; // if (length(AList) = 0) or (AValue.IsEmpty) then exit; // for var N in AList do if (N = AValue.Trim) then exit(true); end; procedure TForm1.Button2Click(Sender: TObject); var LWFDw : _WIN32_FIND_DATAW; LHandle : THandle; LPathFolder : PWideChar; LTrue : boolean; LFilename : string; i : integer; LDeletedFiles: TArray<string>; begin Memo1.Text := ''; i := 0; LPathFolder := 'd:\MyFolder'; LHandle := FindFirstFile(PWideChar(LPathFolder + '\*.*'), LWFDw); LTrue := (LHandle <> INVALID_HANDLE_VALUE); // // Nothing is guaranteed here, as another process (internal or external) can delete the file at any time! try while LTrue do begin LFilename := string(LWFDw.cFileName); // if (LFilename.Trim > '..') and MyFindDeletedFilesOnList(LDeletedFiles, LFilename) then begin LTrue := FindNextFile(LHandle, LWFDw); Memo1.Lines.Add('.... continue your search! the file ' + LFilename + ' was deleted'); // continue; // next round... end; // else, you can create your list of all files not deleted too! // i := i + 1; // if (LFilename.Trim <= '..') then LFilename := '...... dir root and ancestral dir ......'; // Memo1.Lines.Add(i.ToString + ', ' + LFilename); // // (i=2) it will avoid verify all time "if exists or not"! if (i = 2) and FileExists(LPathFolder + '\a.jpg') then // delete after: "." and ".." ... next round will be "a.jpg" begin DeleteFile(LPathFolder + '\a.jpg'); LDeletedFiles := LDeletedFiles + ['a.jpg']; end; // LTrue := FindNextFile(LHandle, LWFDw); end; finally if (LHandle <> INVALID_HANDLE_VALUE) then Winapi.Windows.FindClose(LHandle); end; end; initialization ReportMemoryLeaksOnShutdown := true; end.
  4. programmerdelphi2k

    Scanning for files while they are created or deleted

    maybe because after you trigger the procedure that verifies the files, it already has the names of the files that existed before your other procedure (or line) that triggers the "DeleteFile" command or similar... so, the list "contains the values old" before his "new" command! Perhaps it would be better for you, right after sending the "delete" command, to cancel the old task and launch a new task to verify the new situation. Or who knows, find an API function that does this "in real time", but I think you may have the previous result or even a "false positive". So maybe you have to have a "delay" between the two tasks....
  5. @Robert Gilland when you register a new class, you needs UNregister it when it's not more needs it. to knows all types registered on system (your app), you can use RTTI query. see this sample https://docwiki.embarcadero.com/CodeExamples/Sydney/en/Getting_RTTI_for_Rooted_Types_(Delphi) the register is done in "INITIALIZATION" section, and unregister is done in "FINALIZATION" section from unit where this class is defined, normally.
  6. programmerdelphi2k

    Rendering form content

  7. programmerdelphi2k

    Rendering form content

    well, then the problem really is with you no? here is < 1.5s -> TO SHOW 1000 object, of course!
  8. programmerdelphi2k

    Assign KeyDown function to btnClick

  9. programmerdelphi2k

    Rendering form content

    I did, the time is minimum! the time is above I did, but your Form dont do nothing... just have some panels and nothing of code... "MatchesByRound" is not called ??? picture deleted (not really necessary so)
  10. programmerdelphi2k

    Rendering form content

    many USES was commented,, now I need know " OddCorr = CPnlHeight - Trunc(CPnlSpaceVer / Idx2); ---> IDx2 and IDx6 what value use?
  11. programmerdelphi2k

    Rendering form content

    new time to create 1000 object into Panel1: Creating object: Lines: 1001, Time: 00:00:00.0439193 ------------- Changing Controls of Panel1 to Show, Time: 00:00:01.4996190, New Parent: Form1 ------------- Hiding controls, Time: 00:00:00.5445169, New Parent: Form1 ------------- Changing Parent of Panel1, Time: 00:00:00.0936809, New Parent: ScrollBox1 ------------- Showing controls, Time: 00:00:01.4349263, New Parent: ScrollBox1 ------------- Hiding controls, Time: 00:00:00.5135471, New Parent: ScrollBox1 ------------- Changing Parent of Panel1, Time: 00:00:00.0948245, New Parent: Form1 ------------- Showing controls, Time: 00:00:01.4588028, New Parent: Form1
  12. programmerdelphi2k

    Rendering form content

    so much actions, I pass it! you dont need buy nothing, just review your code: exists many similar objs, maybe needs a "Design Pattern" here not? changes: Panel now is the "Parent" of my 1000 objects, and the Panel will be accomodate in ScrollBox1 ... Lines: 1001, Time: 00:00:01.3179827 // of course, needs remove lines not necessary like "LText... re-position of object, etc..." Changing Parent of Panel1, Time: 00:00:01.6891914, New Parent: ScrollBox1 ->> as said, ScrollBox needs more actions than Panel! Changing Parent of Panel1, Time: 00:00:01.4804362, New Parent: Form1 Changing Parent of Panel1, Time: 00:00:01.7900458, New Parent: ScrollBox1 -------------
  13. programmerdelphi2k

    Rendering form content

    impossible for me: I dont use JST or ADV suites! sorry!
  14. programmerdelphi2k

    Rendering form content

    well, if the ScrollBox render the Panel, then, it dont need render the objects in Panel. all job is done by Panel.... and the panel dont needs create "scrollbars" for example, resize, etc...
  15. programmerdelphi2k

    Rendering form content

    @Stano let's remember that "default Delphi components it's not necessary the better code than other libs on market", for sure, TAdvSmoothPanel have a code more performatic (for that it exists not?) look this: Lines: 1001 (1000 controls created on-the-fly), Time: 00:00:01.6594270 ... later, 3 click on change parent! ------------- Changing Parent of ScrollBox1, Time: 00:00:02.2364219, New Parent: Panel1 ------------- Changing Parent of ScrollBox1, Time: 00:00:02.2367827, New Parent: Form1 ------------- Changing Parent of ScrollBox1, Time: 00:00:02.2283093, New Parent: Panel1 ------------- implementation {$R *.dfm} uses System.Diagnostics; var SW : TStopWatch; LWidth : integer = 50; LHeight: integer = 50; LLeft : integer = 0; LTop : integer = 0; procedure NewPositionAndSize; begin LWidth := random(50 + random(200)); LHeight := random(50 + random(50)); LLeft := random(Form1.ScrollBox1.Width - LWidth); LTop := random(Form1.ScrollBox1.Height - LHeight); end; procedure TForm1.BtnCreate_Many_WinControlsClick(Sender: TObject); var LClass : TArray<TClass>; LWinControl: TWinControl; LText : string; LIndex : integer; begin Memo1.Text := ''; LClass := [TButton, TComboBox, TListBox, TPanel, TEdit, TMemo]; // NewPositionAndSize; // SW.Reset; SW.Start; // for var i: integer := 1 to 1000 do begin LIndex := random(length(LClass)); LWinControl := TWinControlClass(LClass[LIndex]).Create(Form1); LText := LText + slinebreak + LWinControl.ClassName; // NewPositionAndSize; LWinControl.Width := LWidth; LWinControl.Height := LHeight; LWinControl.Left := LLeft; LWinControl.Top := LTop; LWinControl.Brush.Color := random($FFFF); // LWinControl.Parent := ScrollBox1; end; // SW.Stop; // Memo1.Lines.Add(LText); Memo1.Lines.Add('Lines: ' + Memo1.Lines.Count.ToString + ', Time: ' + SW.Elapsed.Duration.ToString); end; procedure TForm1.Btn_Put_ScrollBox_into_PanelClick(Sender: TObject); begin SW.Reset; SW.Start; // if ScrollBox1.Parent = Panel1 then begin ScrollBox1.Parent := Form1; Label2.Caption := 'ScrollBox1 Parent = ' + ScrollBox1.Parent.Name; ScrollBox1.Top := 72; ScrollBox1.Left := 32; end else begin ScrollBox1.Parent := Panel1; Label2.Caption := 'ScrollBox1 Parent = ' + ScrollBox1.Parent.Name; ScrollBox1.Top := 22; ScrollBox1.Left := 12; end; // SW.Stop; // Memo1.Lines.Add('-------------'); Memo1.Lines.Add('Changing Parent of ScrollBox1, Time: ' + SW.Elapsed.Duration.ToString + ', New Parent: ' + ScrollBox1.Parent.Name); Memo1.Lines.Add('-------------'); end; procedure TForm1.FormCreate(Sender: TObject); begin Label2.Caption := 'ScrollBox1 Parent = ' + ScrollBox1.Parent.Name; end; initialization ReportMemoryLeaksOnShutdown := true; randomize; // SW := TStopWatch.Create; end.
  16. programmerdelphi2k

    WMI (winspool) and critical section

    @alogrep see that https://social.msdn.microsoft.com/Forums/vstudio/en-US/18866f7c-a896-4465-9208-c920cf1f1158/is-wmi-api-threadsafe-?forum=netfxbcl#:~:text=Your application will be thread,accessing them in different threads. https://microsoft.public.win32.programmer.wmi.narkive.com/vLmbKJcS/wmi-and-multi-threading
  17. // fixed... type TADyn = array of integer; TAClose = array [0 .. 1] of integer; procedure TForm1.Button1Click(Sender: TObject); var ADyn : TADyn; AClose: TAClose; AOpen : array of integer; // ------------------- procedure ShowMeArrayOpen(Arr: array of integer); begin Arr[0] := 123456; ShowMessage(AOpen[0].ToString); end; procedure ShowMeArrayDyn(Arr: TADyn); begin Arr[0] := 123456; ShowMessage(ADyn[0].ToString); end; procedure ShowMeArrayClose(Arr: TAClose); begin Arr[0] := 123456; ShowMessage(AClose[0].ToString); end; begin AOpen := AOpen + [111]; ShowMeArrayOpen(AOpen); ShowMessage(AOpen[0].ToString); // ADyn := ADyn + [333]; ShowMeArrayDyn(ADyn); ShowMessage(ADyn[0].ToString); // AClose[0] := 444; ShowMeArrayClose(AClose); ShowMessage(AClose[0].ToString); end; source: old Rudy article: http://rvelthuis.de/articles/articles-openarr.html as he said: it's confused but...
  18. @o815 im not specialist in bitwise usage, but if a "set of bytes" is a real -UInt64, then, you can catch all "bytes" that represent your real-UInt64 and convert to UInt64, do the calculating, and re-convert to bytes again.. can you get it? another, if you need "arrays of bytes", then you can have "array of UInt64" not? xx :TArray<UInt64>; another another: dinamic Array is "var" param no? then, maybe you dont need "result := ....XXX modified" -> Delphi dynamic arrays are always reference-types.
  19. programmerdelphi2k

    CE registering problem

    the new ISO 11.3 with Community Edition would not be: ..../11.0/RADStudio_11_3_28_13236a.iso (if you can download the ISO, of course) Other: needs remove old RAD 11.xxx before, and if necessary delete old licenses (for him) files in C:\ProgramData\{....} guid name
  20. programmerdelphi2k

    RAD Studio Breakpoints not working

    other: if the "breakpoint" is in line "NOT" used in any place, then is ignored!
  21. programmerdelphi2k

    Display a TBitmap in original resolution

    if dont, sorry! look my post... calculate font scale
  22. programmerdelphi2k

    Change "FadeOut" code to "FadeIn" code

    @Willicious maybe "TColor32( Round(....) );
  23. programmerdelphi2k

    write text on image with specific position fmx

    @xorpas maybe some like this... Invalidate informs the form that its entire surface needs to be repainted. Calling Invalidate can prevent flicker caused by a series of partial repaints. There is no performance penalty for calling Invalidate multiple times before the form is actually repainted. implementation {$R *.fmx} var LImageWidthOriginal, LImageHeightOriginal: single; LFontSizeScale : single = 1; // init value procedure TForm1.Button1Click(Sender: TObject); begin Image1.Align := TAlignLayout.None; // Image1.Size.Width := 200; Image1.Size.Height := 200; LFontSizeScale := (Image1.Width * Image1.Height) / (LImageWidthOriginal * LImageHeightOriginal); // Invalidate; // re-do form canvas end; procedure TForm1.Button2Click(Sender: TObject); begin Image1.Align := TAlignLayout.None; // Image1.Size.Width := 500; Image1.Size.Height := 600; LFontSizeScale := (Image1.Width * Image1.Height) / (LImageWidthOriginal * LImageHeightOriginal); // Invalidate; // re-do form canvas end; procedure TForm1.Button3Click(Sender: TObject); begin Image1.Align := TAlignLayout.Client; // LFontSizeScale := (Image1.Width * Image1.Height) / (LImageWidthOriginal * LImageHeightOriginal); end; procedure TForm1.FormCreate(Sender: TObject); begin // 3º - first run Image1.WrapMode := TImageWrapMode.Stretch; LImageWidthOriginal := Image1.Size.Width; LImageHeightOriginal := Image1.Size.Height; end; procedure TForm1.Image1Paint(Sender: TObject; Canvas: TCanvas; const ARect: TRectF); var LRectText : TRectF; LImagePoint: TPointF; begin // 4º - first run LImagePoint := Image1.AbsoluteToLocal(PointF(Image1.Position.x + 10, Image1.Position.Y + 10)); LRectText := TRectF.Create(LImagePoint.x, LImagePoint.Y, Image1.Width, Image1.Height); // Canvas.Fill.Color := TAlphaColorRec.Yellow; Canvas.Font.Size := LFontSizeScale * 20; Canvas.FillText(LRectText, 'Hello World', false, 1, [], TTextAlign.Leading, TTextAlign.Leading); end; procedure TForm1.Image1Resize(Sender: TObject); begin // 1 º - first run end; procedure TForm1.Image1Resized(Sender: TObject); begin // 2 º - first run end; end.
  24. programmerdelphi2k

    Display a TBitmap in original resolution

    question: and if you place a TImage in a form (or another container), define this container to occupy the entire screen (or the desired size), and, in the TImage, activate the option to use the entire client area of this container. So the TImage properties (like WrapMode) can be set to fill this entire area, dont? there is TImageViewer too...
  25. programmerdelphi2k

    Change "FadeOut" code to "FadeIn" code

    I dont know this procedure, but I think that "P" can be the "point"... Inc(P) is growing.... then if P := PixelPtr( x, y) = max values then dec(P) can "go back" the positions on TColor32Entry(P^) ... I dont know, if just a thinking... would be X = Width and Y=Height of your Bitmap? here a Github with so much code including Fade In/Out effect in "forms"!!! https://github.com/tothpaul/Delphi/tree/master/FadingEffect
×