Jump to content

PeterBelow

Members
  • Content Count

    465
  • Joined

  • Last visited

  • Days Won

    13

Everything posted by PeterBelow

  1. 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.
  2. 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"
  3. 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).
  4. 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.
  5. 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.
  6. 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!
  7. 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.
  8. Well, interface references are pointers, so the problem is just how to make sure the reference count stays correct, which the code does. The singleton template the code was created from is quite old, however, predating the appearance of TMonitor by several years. There may be a cleaner way to implement this these days, but I don't like to change working code if there's no pressing reason to do so.
  9. That code comes from the forin template that comes with newer versions of Delphi. Sorry for the inconvenience, but since I program mostly for my own use i'm not much concerned with compatibilty with older Delphi versions and simply did not notice this as a potential problem.
  10. http://rvelthuis.de/articles/articles-pointers.html
  11. PeterBelow

    SetFocus issue

    That sounds as if the form is no longer the foreground window after the ActiveX control hasloaded the file. Try to add a BringToFront; after the LoadFile line.
  12. PeterBelow

    Form no longer repaints after WM_SETREDRAW

    Just a guess: check the value of self.handle in both methods to verify they are the same. VCL forms are prone to recreate their window handle at the drop of a hat...
  13. PeterBelow

    PopMenu two levels down..

    Did you remember to set the PopupMode property of your modal forms to pmAuto? What you describe sounds like a Z-order problem. But I see from the newer messages that the problem spontaneously resolved itself. It always makes me nervous when that happens in my projects...
  14. PeterBelow

    Quick debug variables?

    Look at the Format function, it can be used to compose a string from values/variables using a template string with placeholders, taking the values to insert via an open array parameter. That covers all standard simple datatypes, but complex types like objects, arrays, dictionaries usually have no default method to convert their content to a string (although some have a ToString method, natively or through class or record helpers). For your own classes you can override the ToString method inherited from TObject, for instance.
  15. PeterBelow

    Left Click Does not Focus Control

    Maake sure you set the form borderstyle to bsNone, so it has no caption bar. Windows does not like controls with the WS_Caption window style (and that is what the form becomes when you embed it), they have focus issues likr the one you observed.
  16. Timer messages have low priority. If your DoProcessMessages call takes longer than the message interval then a timer tick will not add a new wm_timer message to the queue but increment an internal count for the message already in the queue. Use a waitable timer and one of the MsgWait API functions instead of SetTimer,
  17. PeterBelow

    Resolve a uses clause unit path?

    Well, there is a FileSearch function in Sysutils that will search for a file in semicolon-separated list of directory names, but of course you still have to extract the library path from the IDE settings (= registry key, specific for an IDE version), the search path from the current project, if relevant, replace any macros ($(name)) in the pathes etc. to get the list of folders. I'm not aware of a ready-made function for this exposed in the RTL or Open Tools API.
  18. PeterBelow

    The Embarcadero GetIt server could not be reached...

    https://community.idera.com/developer-tools/b/blog/posts/temporary-10-3-2-getit-server-for-installing-10-3-2-add-on-packages?fbclid=IwAR1bV79CCoutmAyH6slVbima_F9QMX29QX1nnwuCl5COCdmXU86BJJNhN9Y
  19. Yes, it is far from easy to switch processing to a specific secondary thread. Basically it is only possible savely if that thread has been written for this. So i can only concur with your previous reply: the responsibility of handling the synchronizing should fall to the code providing the callback.
  20. PeterBelow

    handling predicate conditions

    Yes, but the error you get then will not immediately indicate what the problem is. The way I do it its clear that the problem is a contract violation, and one can write unit tests that check whether the method correctly detects a contract violation.
  21. PeterBelow

    handling predicate conditions

    I usually test for pre and postconditions like this: procedure TBlobDB.CreateNewDatabase(aDBStream, aIndexStream: TStream; aTakeStreamOwnership: boolean); const Procname = 'TBlobDB.CreateNewDatabase'; begin if not Assigned(aDBStream) then raise EParameterCannotBeNil.Create(Procname,'aDBStream'); if not Assigned(aIndexStream) then raise EParameterCannotBeNil.Create(Procname,'aIndexStream'); This is for errors that are supposed to be found and fixed during the testing phase or (for library code) in unit tests. For user input the input is validated before it is used by the program, if this is at all feasable. The end user should never see an exception coming from parameter validation at a lower level, in my opinion, since the UI context may not be evident at that point and it may be unclear to the user what he did wrong.
  22. PeterBelow

    Debugging Inline Variables in 10.3.2

    Well, the cure is simple: do not use inline variables 😉. They are alien to the language anyway and serve no real purpose IMNSHO...
  23. Did you just open the old D7 project in Rio to start the migration? That is not a good idea for such a massive version jump. After you have extracted the complete old project from version control, close all files and the RIO IDE and go to the project folder on disk and move all files not having one of the following extensions to a zip folder: dpr, pas, res, rc, ico If the project contains other resources you may keep them as well. The important part is to delete the old project file (do not remember what extension it used in D7, perhaps bdsproj, and the old cfg file as well. Then open the IDE and open the project's dpr file. This will create a new project file. The project will show up in the project manager view and should have the Win32 target assigned automatically. It will also have a default build configuration assigned, but the settings used for that will not all be suitable for your project. So the next step is to open the project options dialog (from the Project menu or the project manager view's context menu) and adjust the settings, especially the search and output pathes. Beware! The settings dialog is completely different from the one you may know from D7! Since you can have multiple build configurations for multiple target platforms the settings are organized as a kind of hierarchy, and you have to first select the correct hierarchy level for the settings you want to modify. You do this using the combo box at the top of the right-side pane, pick "32 bit windows platform" under "all configurations". In the left-hand treeview you should have the top node (Delphi compiler) selected, that shows the page with the project-specific path settings on the right. The most important things here to get your project to compile are the unit scope names and the search path. Delphi uses namespace-like scope names on the run-time and framework units and has done so since many versions. But D7 did not use unit scope names. To make migration easier the IDE and the compiler will automatically search for units named in Uses clauses within the scopes listed in the unit scope names field if the unit is not found by the given name (the System scope is always searched, though). The default list contains the most frequently used scopes, but you have to make sure that VCL and VCL.Win are in the list as well. The search path becomes important if your project uses custom units not located in the project folder (where the dpr file and the generated dproj file reside). You have to add all pathes for units there that are not found on the IDE library path (as dcu or pas). I don't know how you organize your project files on disk. I usually use something like projectname (dpr, dproj, cfg) source (pas, inc) bin (dcus) exe (exe) doc (documentation) resources (rc and res files, files embedded in them) test (unit tests and other test programs) So the output folder path set in the dialog would be (without the quotes, of course) ".\exe". The unit output path would be ".\bin\$(platform)\$(config)" The search path would be ".\bin\$(platform)\$(config);.\source;$(common);$(include)" "common" and "include" are environment variables defined in the IDE Options dialog that contain the pathes to my code library (not project specific units). The resource compiler node on the left also has a search path setting, these are for rc and res files, but in my experience this has been a bit unreliable in recent versions; i often have to add rc files explicitely to a project to get them compiled and linked in.
  24. PeterBelow

    Playing multiple wave files simultaneously

    As far as I remember from older discussions you have to merge (mix) the sound files into one before you can play it. Windows has an API for that, see Audio mixers If you google for mixer audio sound delphi you may find something useful.
×