Leaderboard
Popular Content
Showing content with the highest reputation on 12/06/24 in all areas
-
You probably have noticed that when you press the middle mouse button in the Delphi IDE the editor goes into panning mode, that allows you to scroll by moving the mouse. Many of the Vcl.Controls are panning enabled including the Memos, Grids, ContolLists, TabControls, Treeviews and others. For a complete list just search for csPannable in the Delphi Vcl source code folder. They use the exact same code that the IDE uses and behave in exactly the same way. However, what you may not know (I did not), is that to enable panning you need to include in your project the Vcl.IMouse unit. Vcl also makes it easy to add panning to your custom controls. All it takes is to add the csPannable control style. So SynEdit now has the same panning support as the Delphi IDE. However, I have discovered two bugs related to Vcl panning: Memory leak when you use Vcl.IMouse - RAD Studio Service - Jira Service Management The Panning Window is not DPI scaled - RAD Studio Service - Jira Service Management Both are easy to fix, so hopefully Embarcadero will provide fixes soon enough! In the meantime, it is easy to work around the memory leak and hopefully live with the second one, which also affects the Delphi IDE.
-
@JohnLM Great. This is perfectly reasonable .. for at least two reasons. 1) The challenge is about achieving a solution - dissecting the problem in a way that makes it solvable. 2) Eg in the day 2 and 3 problems, I put the data in Excel to manipulate it around, get a perspective on the contents, and to provide results to crosscheck against while I am only part way towards constructing my approach. I have kept them in my Github repo. 3) Also, some of the challenge is just reading in the data ... which can be sometimes tedious and/or obvious. I have used Excel and Notepad++ to make the data into a Delphi unit holding the info, when moving text with code was unrewarding. PS : There's a cool video from the guy that creates and runs the challenges from very recently. People solve the problems in many different ways - and not just with code. CppNorth - Keynote: Advent of Code, Behind the Scenes - Eric Wastl
-
They say that documentation is the worst part of programming and I mostly agree with that. Nevertheless I have taken the time to add a page about the Uses Clause Manager expert to the GExperts help because that topic was completely missing. I hope I covered all the topics. There is no help button on the form yet. I’ll look into that later. There is also an updated chm file as well as a printable manual in PDF format.
-
Get Class Properties by ClassName
Remy Lebeau replied to egnew's topic in RTL and Delphi Object Pascal
Why not use the ClassType instead of the ClassName? GetProperties(v_FDConnection.Params.ClassType); GetClass() only returns classes that are registered with RegisterClass(). Not all classes are registered. GetClass() returns nil if it can't find the requested class. You are not handling that possibility. You can't pass nil to TRTTIContext.GetType(). FindClass(), on the other hand, will raise an EClassNotFound exception if the requested class is not found. -
Enum modules return ONLY the application, no other packages
Remy Lebeau replied to alogrep's topic in VCL
What makes you think EnumModules() has anything to do with that list? It enumerate the modules that your compiled EXE is using at runtime. Not the modules that are installed in the IDE at design-time. If you want the list that is installed in the IDE, then you will have to manually read that list from the IDE's configuration in the Windows Registry. If you want the list that your EXE is compiled with, then such modules only exist if you compile with Runtime Packages enabled so the packages are used as external BPLs at runtime. -
Thank you so much for providing this Update for the latest Halcon Version 24.11! In the meantime, I started writing a wrapper class that allows me to keep my old Halcon Com-Interface based code more or less as it is and internally call the C-functions. Example: procedure THalconOperators.DoOcrSingleClassMlp(CharacterRegion, CharacterImage: HObject; OCRHandle, OleNum: OleVariant; var OleClass, OleConfidence: OleVariant); var TupHandle: HTuple; TupNum: HTuple; TupClass: HTuple; TupConfidence: HTuple; begin OleVariant2HTuple(OCRHandle, @TupHandle, True); OleVariant2HTuple(OleNum, @TupNum); T_do_ocr_single_class_mlp(CharacterRegion, CharacterImage, TupHandle, TupNum, @TupClass, @TupConfidence); OleClass := HTuple2OleVariant(TupClass); OleConfidence := HTuple2OleVariant(TupConfidence); F_destroy_tuple(@TupHandle); F_destroy_tuple(@TupNum); F_destroy_tuple(@TupClass); F_destroy_tuple(@TupConfidence); end; So the idea is: convert all "OleVariant" varibales into "HTuple" (with my self-written procedure "OleVariant2HTuple") , call the C-function and convert the returned tuples into "OleVariant" variables again (with my function "HTuple2OleVariant"). With this it was relatively simple to convert an entire project from using the COM interface to using the C-library. Now I tried to compile my project with the latest "Halcon2411.pas" that you provided and I runt into a problem: the structure of the record "HTuple" (aka "HCTuple") has changed and is now: Hctuple = record val: Hcpar; num: INT4_8; capacity: INT4_8; flags: Integer; elem: Hcelem; end; before it was HTUPLE = record val: Hpar; &type: HINT; pad: array [0..3] of UTF8Char; num: INT4_8; capacity: INT4_8; free: HINT; elem: Hcelem; end; so we don't have the field "&type" any more? Why is that? I find it so confusing that all of a sudden one of the most important structures of this library (the TUPLE) is changed. Another issue that I have is that I didn't manage to use the "CHET" programme for creating the *.PAS File out of the halcon *.h files like you did it. It would be really helpful if you could provide me with more detailed info on what *.h files you copied into one directory and what changes you needed to do to them to successfully create a *.pas file out of this. In any case I am really greatful for the fantastic job that you did, showing that it is possible to use even the latest HALCON versions with Delphi.
-
Thanks everyone! I applied Dave's solution. Thread closed.
-
I do not normally do these types of challenges because I am no professional. But, I did an Excel version of Day-1's puzzle fairly quickly. It took a few minutes without any programming involved, so I guess it does not count. But I did an XE7 (windows) version, today, though it took me many hours to complete. I don't have those Services listed on the website, so there is nothing to see from me, source code wise, over there. And, I am proud to say that, "I did it!" for Day-1's puzzle.
-
Type mismatch for field 'SumVal', expecting: FMTBcd actual: Float'.
Dmitry Arefiev replied to emileverh's topic in Databases
Yes, it is. Did you read about "...::type" syntax ? -
uses iOSapi.Helpers; function GetBrightness: Single; begin Result := TiOSHelper.MainScreen.brightness; end; procedure SetBrightness(const AValue: Single); begin if (AValue >= 0) and (AValue <= 1) then TiOSHelper.MainScreen.setBrightness(AValue); end;
-
This was written by Copilot. I can not test the code as I do not have the iOS units installed on my system. To change the screen brightness on iOS using Delphi, you can use the UIScreen class from the iOS API. Here's a basic example of how you can achieve this: 1. Import the necessary iOS units: uses iOSapi.UIKit, iOSapi.Foundation; 1. Set the screen brightness: procedure SetScreenBrightness(Brightness: CGFloat); begin UIScreen.mainScreen.setBrightness(Brightness); end; 1. Call the procedure with the desired brightness level: begin SetScreenBrightness(0.5); // Set brightness to 50% end; In this example, UIScreen.mainScreen.setBrightness is used to set the brightness level. The brightness value should be between 0.0 (minimum brightness) and 1.0 (maximum brightness)https://www.reddit.com/r/iOSProgramming/comments/whtu5q/is_there_a_way_to_control_screen_brightness/https://forums.developer.apple.com/forums/thread/717234. Would you like more details on integrating this into a full application?
-
To increase the chances for a positive response, I would recommend to first check if its possible at all with XCode and Objective-C. If it's possible there then its usually also possible in Delphi, and then you can begin figuring out how its done and eventually ask about it here.
-
Type inference in assignment but not comparison??
David Heffernan replied to PiedSoftware's topic in RTL and Delphi Object Pascal
Not sure who Dave is.... Delphi doesn't know that the type of the thing to the right of the equality operator is an array, it thinks it is a set. That's why you get the error. You might not like this, but this is just how it is right now. From the language perspective, there is clearly some magic disambiguation applied in the case of the assignment operator that isn't applied elsewhere. As Remy says, all you can do is to open a ticket. Shooting the messenger isn't going to get you anywhere. But even if the code did compile, what would you want it to do? For dynamic arrays, like other reference types, the equality operator = means reference equality. But I suspect that you would want value equality. So even if this code ever compiled, I don't think it would do what you want to do. In which case you will need to implement a method or function to perform value equality testing, and so the topic becomes somewhat moot. -
Open-source Delphi interpreters?
Bob Devine replied to David Schwartz's topic in Network, Cloud and Web
You should try FPC for Linux servers. The absence of Linux in Delphi Pro or Community is one of the reasons I let my Delphi subscription recently lapse. It's not even so much the cost, but the lack of an open community means I've no idea how stable Delphi Linux is, so it's not worth the risk. FPC/Linux has been rock solid for the two years I've been using it (with mORMot). -
Yes
-
I update this topic 'cause new versions are released of Halcon (and quote Matthias that were interested about that). I post a Delphi wrapper around this, not a really Delphi wrapper, only a porting from C headers that I have done with CHET. Take care that some adjustments should be done from your previous sources because in Halcon are changed some records (Tuples), and for other reasons too. Read carefully the "Release Notes for HALCON 24.11.1.0 Progress-Steady" (https://www.mvtec.com/products/halcon/work-with-halcon/documentation/release-notes-2411-1) for full details. I tried the new wrapper only partially. Bye HalconC_2411.pas
-
Meta-Delphi question about web hosting..
Die Holländer replied to jglosz's topic in Network, Cloud and Web
or https://thinfinity-vui-v3-docs.cybelesoft.com/ It seems it delivers the whole environment needed.. Delphi Demo -
function: how to return nil
Roger Cigol replied to jesu's topic in Algorithms, Data Structures and Class Design
Very good suggestion by @dummzeuch Very few people give enough thought to naming of functions and variables. Developing a consistent approach can significantly help with long term program readability / long term support for large projects. Anything that hints at doing that gets my full support ! https://cigolblog.wordpress.com/2023/01/ https://cigolblog.wordpress.com/2019/10/ https://cigolblog.wordpress.com/2017/06/ -
function: how to return nil
dummzeuch replied to jesu's topic in Algorithms, Data Structures and Class Design
I usually prefix functions like this with "Try", so instead of function GetTheValue(parameters ...): SomeType; it's function TryGetTheValue(parameters ...; out Value: SomeType): Boolean; -
function: how to return nil
Brandon Staggs replied to jesu's topic in Algorithms, Data Structures and Class Design
You're better off doing something like function myfunc(const InVal: String; out OutVal: Double): Boolean; Return True if the value was set and false if not. There are other ways to handle this but the worst way is a magic value in Double. There's no reason to do that when it is so easy to indicate explicitly whether or not the value is valid. -
Delphi 12.0 Athens is not correctly installing the Android SDK
Dave Nottage replied to scamp's topic in Cross-platform
It's likely because you have an incompatible JDK present on the machine. This is a potential fix: 1. Make sure JAVA_HOME environment variable is set to the Adoptium JDK: JAVA_HOME=C:\Program Files\Eclipse Adoptium\jdk-11.0.15.10-hotspot 2. Add missing build-tools by going to: C:\Users\Public\Documents\Embarcadero\Studio\23.0\CatalogRepository\AndroidSDK-2525-23.0.50491.5718\cmdline-tools\latest\bin In a command prompt and issue these commands: sdkmanager “build-tools;33.0.2” sdkmanager “platforms;android-33” -
It's a bit complex to explain, however I try. First, to use CHET you have to put all the includes you need into one directory, and then you have to change the definition in the individual file references, which originally point to subdirectories. Second, unlike C, where you can declare variables or definitions anywhere and even out of order, in the wrapper, declarations must be "ordered" (ie first you declare something, then you use it). So you have to take the generated .pas and move several declaration blocks at the head of the wrapper (or between various other declarations). It's not very complex, it just takes a little patience and taking into account that I do it every three years or so, everything is manageable. Another good thing is that once you've done it, you can use tools like Beyond Compare to help you: between the various versions of Halcon there are no abysmal differences, so much so that normally you just need to recompile the projects (or at least change some variables) to port to the new version. In updates between versions (for example between 20.11.01 and 20.11.03) there are no changes in the includes (unless it is explicitly highlighted in the notes) and therefore there is no need to change the wrapper. I normally use the Draw_Rectangle and similar functions without problems. If you want advice, when you can use the functions without the T_ as they use normal variables and not tuples. var ro1, co1, ro2, co2: double; //SomeWhere should be decalre "fWindowHandle: HLong;" and should be assigned of course Draw_Rectangle1(fWindowHandle, @ro1, @co1, @ro2, @co2); //and you can use of course also the _mod function ..... Bye P.S.: Beware of one "thing": when a function returns multiple elements (for example a list of points), it MUST be used in the form "T_" i.e. with tuples, unless it is certain that only one value is returned, such as example when preceded by the SelectObj function.
-
This is not an interface with .net assembly. It's a wrapper around C library. This will use the HalconC.dll. Nothing to do with .Net. And Yes i created lot of projects, may be not very big but most of them use 20 and more thread like that in the examples (of course with more and more functions inside) with Halcon. I don't have memory leak, but you must care to "clear" every single hobject that you use, before use it (not need if you are sure that is nil). If you reuse an object without clear it and it's already in use you will "lost" the memory (means LEAKS). Also, the wrapper don't has any know about macro, so you cannot use Halcon macro in Delphi. But this was never a problem for me. Bye