Jump to content

PeterBelow

Members
  • Content Count

    508
  • Joined

  • Last visited

  • Days Won

    13

Everything posted by PeterBelow

  1. PeterBelow

    Codesite auto-invoke not working?

    Have you tried to check "Select shortest matching symbol"?
  2. PeterBelow

    PopUp Sub-Menu Location

    The position of the submenus is controlled by Windows (assuming we are talking about a VCL app), by default it pops up on the right side, unless there is insufficient space available on the screen on that side. I don't know of a way to control that. What you could do is to implement each submenu as a separate TPopupMenu and pop it up manually from the OnClick event of the "parent" menu item. Unfortunately it is not trivial to determine the screen position of an open menu item...
  3. PeterBelow

    Delphi 10.4 missing XML Data Binding

    With my Delphi 10.4 Version 27.0.37889.9797 (Professional) it is found under File->New->Others, Delphi projects, Web:
  4. Modelmaker CodeExplorer (MMX) offers that, and a lot of similar stuff for quickly adding methods etc. And it's free now. Could not live without it...
  5. PeterBelow

    task thread priority?

    Windows is not a real-.time OS, so you don't have any guarantee for defined thread execution times, and your program has to share the CPU resources with a few dozen OS processes. Anyway, your problem sounds like you flood your UI thread's message queue with update requests (you do Synchronize these request, I hope, and do not execute the background task's work in a syncronized method). These requests have a higher priority than the paint messages your changes to the UI cause to be added to the queue. If adding calls to a method like procedure ProcessPaintrequests; var Msg: TMsg; begin while PeekMessage(Msg, 0, WM_PAINT, WM_PAINT, PM_REMOVE) do DispatchMessage(Msg); while PeekMessage(Msg, 0, WM_NULL, WM_NULL, PM_REMOVE) do DispatchMessage(Msg); end; does not fix the problem you have to lower the priority of your worker threads to give the main thread more time to update the UI.
  6. A kind of transaction log saved to local storage (a file) may serve your purpose. You can write entries to a file using a write followed by a flush operation (or a full open - write - close cycle) . While not very fast it will ensure the entry is either written completely or not all (if the PC suffers a power failure, for example). Your operation would then follow this scheme: Write the intent to print, with the ID of the item to print, to the log print the item write the success of the operation to the log save it to the database write an end of transactio to the log or delete the log On (re)start the program can then look for a transaction log and analyse it to see how far it got on the last run.
  7. PeterBelow

    DelphiCon 2021 Code Examples

    At least one of the examples is on github: https://github.com/gustavomenabarreto/delphicon2021 Perhaps you can find more in the replays on Youtube: DelphiCon 2021 Playlist It's probably up to the speakers to make the code for their talk available somewhere...
  8. In this case it is, but one should never make assumptions about in which order the parts of a complex expressions are evaluated. It may even change depending on compiler flags, e.g. optimization on or off, stack frames on or of, range and overflow checks.
  9. PeterBelow

    Delphi profiler

    Set the Capacity property of your list objects to a suitably high value before you start adding objects, that can greatly improve performance since it cuts down cases where the list has to grow its internal array.
  10. PeterBelow

    Interface question

    @David IMO you are mixing data with UI in a way that only causes problems. You should use a list class instance (nonvisual) to hold objects that represent a student, each of which holds a list of the classes taken with the score obtained. The list class can then have a method to compose the items for a listview you pass as parameter to the method. If you need that you can store the reference to the student object in the corresponding listitem's Data property, but the lifetime management of the objects is the duty of the list class, not that of the UI listview.
  11. PeterBelow

    calculete time in delphi

    DecodeTime is the wrong method to use since it decodes a time point, not a time interval. The System.Diagnostics.TStopwatch record may be of more use for your problem. Add a private field FStopwatch: TStopwatch; to your form. In the OnCreate event you start the stopwatch with FStopwatch := TStopwatch.StartNew; When you want to know the elapsed time call FStopwatch.Stop first and then examine the Elapsed property. It returns a TTimespan record, which has properties to dissect the time interval into days, hours, minutes etc.
  12. PeterBelow

    TControlList - Jump to Selected

    Tcontrollist inherits the ParentBackground property but does not publish it, it is protected. You can try to set it to true in code, using a cracker class: type TControllistCracker = class(TControllist); ... TControllistcracker(Controllist1).Parentbackground := true; Untested!
  13. PeterBelow

    SplitString

    There is nothing wrong with the code you posted, other than the comma instead of semicolon after the "string" in the var section. Perhaps you have another SplitString function closer in scope than StrUtils.SplitString here. If you hover the mouse over SplitString, what does the code insight popup tell you where it's from?
  14. SudokuHelper is an application that acts like an electronic Sudoku grid. It supports 9x9, 12x12, and 16x16 Sudokus, both in the classic and Gosu variant, where cells can be marked to only accept even numbers. The application neither creates Sudokus itself nor provides a solver for them; it is just a more convenient way to solve a Sudoku from a magazine or other external source than doing it on paper, using pencil and eraser. The application's main features are: Invalid cell values are marked in red. Candidate values can be added and removed from a cell. Setting a cell's value will automatically remove candidates no longer possible in other cells. All actions can be undone, the undo stack is only limited by available memory. Named marks can be set for the current undo stack state and one can later restore the stack to such a named mark. The complete Sudoku can be saved to file, including the undo stack, and later loaded again from such a file. The project can be found on GitHub: https://github.com/PeterBelow/SudokuHelper The code is a good example (IMO) of how to uncouple the UI from the "buisness" code using interfaces, in a kind of MVC design. It is free (public domain) without restrictions.
  15. PeterBelow

    Paste file from clipboard to blob field (Remote Desktop)

    Google for "ole drag and drop delphi", that may turn up something useful.
  16. PeterBelow

    Trim

    Are you looking for something like this? {! <summary> Remove all characters in aSet from the passed string and return the resulting string</summary>} function RemoveCharsInSet(const S: string; const aSet: TSysCharset):string; var I: Integer; begin Result := S; for I := Length(S) downto 1 do if S[I] in aSet then Delete(Result, I, 1); end; {! <summary> Remove all characters considered whitespace from the passed string and return the resulting string</summary>} function RemoveWhitespace(const S: string):string; const Whitespace = [#0..' ']; begin Result := RemoveCharsInSet(S, Whitespace); end;
  17. PeterBelow

    Long term availability of Community Edition

    Perhaps, but keep in mind that for MS developer tools are not the major part of their business by far, so the comparison is a bit unfair.
  18. PeterBelow

    Long term availability of Community Edition

    Well, there are heaps of sites that claim to do just that, just google for "life expectancy calculator"
  19. PeterBelow

    Long term availability of Community Edition

    It's difficult to make predictions, especially if they concern the future :). What may be important to know for you is this, however: The licence for the community edition cannot be renewed; if you need to install it on a new computer you need to get a new licence key, which is no problem, however. When a new Delphi/RAD Studio version comes out there is also a new community edition, usually available after a short delay. The previous version's community edition is then no longer available and you cannot get new licence keys for it anymore, so have to move to the latest edition if your old licence expires (it is limited to 1 year if memory serves).
  20. PeterBelow

    Pos

    I think the best way is to dissect the input into "words" and then assemble the parts you want from that list. procedure TForm1.Button1Click(Sender: TObject); var LWords: TStringlist; begin LWords := TStringlist.Create(); try LWords.Delimiter := ' '; LWords.DelimitedText := edit1.Text; if LWords.Count >= 2 then edit1.Text := LWords[0] + ' ' + LWords[1]; finally LWords.Free; end; end; Note that there also is a function PosEx(const SubStr, S: string; Offset: Integer): Integer in unit System.StrUtils that allows you to start the search at a position other than 1.
  21. PeterBelow

    SAX parser

    http://saxforpascal.sourceforge.net is quit good in my experience, I used it in a few projects a couple of years ago.
  22. PeterBelow

    Changing UserDataFolder in TWebBrowser with webview

    Well, TWebbrowser (in D11) has a protected method function GetEdgeInterface: TEdgeBrowser; To get at it you can use a cracker class, e.g. declared in the implementation section of the form unit containing the TWebbrowser control. type TWebBrowserCracker = class(TWebbrowser); In your code you can then do something like var Edge: TEdgeBrowser := TWebbrowserCracker(Webbrowser1).GetEdgeInterface; if Assigned(Edge) then begin Edge.UserDataFolder := SomeDirectory; Edge.ReinitializeWebView; end; Completely untested, so use at your own risk!
  23. InternalHelperRegistry is a "global" variable declared in the implementation section of the unit and will stay around for the lifetime of the application; it is set to nil in the unit finalization. It has been some time since I last looked at the memory manager implementation, but a lock there does not protect against a race condition in the code assigning the resulting reference to a variable elsewhere.
×