Leaderboard
Popular Content
Showing content with the highest reputation on 05/28/23 in Posts
-
The sample only works on Delphi 10.3 and above.
-
Hi Did you upgraded the Android manifest template file to the need one for 11.3 ? Did you updates the JAR libraries needed for the project in the project manager Android platform you compile ? (probably yes if it compiles, but check in case not) If you transfer the APK manually to an other device, does it starts or not ? Does the program starts when you compile it in DEBUG mode and start it with (or without) the debugger from the IDE ?
-
Problems with Delphi class structure / visibility
Lachlan Gemmell replied to Willicious's topic in Delphi IDE and APIs
So you'll need to find an instance of the TRenderer to access it's internal theme instance (hopefully via a public Theme property on the renderer). Use the same technique. Do a find in files for TRenderer.Create and find where the renderer is created. You may find it's contained by another class, in which case you repeat the same process for that class to find it's instance(s). To get access to the theme LemNames you may end up doing something like SomeGlobalInstanceOfSomeClass.SomePropertyForTheRendererInstance.Theme.LemNames := 'Cats'; Note that none of the parts of that made up line are unit names or class names. They're all instances, a global instance in the case of the first part, then properties within a class representing an instance, and finally the LemNames string property of the TNeoTheme class. To get this fictional line of code to compile I need to add to my uses clause whichever unit contains the declaration for the first instance, in this case the SomeGlobalInstanceOfSomeClass global variable. -
Problems with Delphi class structure / visibility
Stano replied to Willicious's topic in Delphi IDE and APIs
I recommend that you visualise the whole situation. That is the most important thing to do. This will help you to understand the problem. Since you can't do it in your head, and neither can I, you have to sketch it out. Paper is inappropriate for this task. The best I know is the DIA program. It's not finished and it's already dead. It does its job more than well. I'm confident that you will move forward with this technique. I personally use it to visualize problems: DIA: DB bindings, Classes: dependencies (links), their structure - as needed Word, text editor Excel FreeMind -
Problems with Delphi class structure / visibility
Lachlan Gemmell replied to Willicious's topic in Delphi IDE and APIs
I watched the rest of the video. A few comments. Firstly if you find yourself typing unit names (e.g. LemNeoTheme) outside of a uses clause, 9 times out of 10 you're doing it wrong. Secondly if you find yourself accessing a property through a class name (e.g. TNeoTheme), 8 times out of 10 you're doing it wrong. Think of a unit and the classes inside it as the paper instructions on how to build a table (a real physical table you sit at). The class procedures and functions are the steps you will need to follow to build that table and the data variables inside that class are just a list of the tools you'll need. Lets call this class TFantasticWoodenTableBuilder and it has public property HammerColour (which is a string). Don't think of that TFantasticWoodenTableBuilder class (or the unit that contains it) as being "alive" in any sense. It is as inanimate as an actual set of paper table building instructions. It can't actually physically do or verbally tell you anything. Next a real person Frank comes along and reads those instructions. Frank commits them to memory, goes away and starts building a table. Frank is now an instance of TFantasticWoodenTableBuilder and his HammerColour happens to be red. John reads the instructions and decides to build a wooden table with them. His hammer is blue. We now have two instances of TFantasticWoodenTableBuilder, Frank and John each with their own separate properties (though both called HammerColour) that stores their own respective hammer colours. If you want to know the colour of somebody's hammer you have to ask them (via an instance variable). There's no point asking the class (TFantasticWoodenTableBuilder), it's just a piece of paper, it's not going to talk back to you. The Frank and John instance variables are declared like this var Frank : TFantasticWoodenTableBuilder; John : TFantaticWoodenTableBuilder; This is how they are created (as in memory allocated to them) John := TFantasticWoodenTableBuilder.Create; Frank := TFantasticWoodenTableBuilder.Create; This is how you get or set their hammer colours if John.HammerColour <> 'blue' then ShowMessage('John has pinched somebody elses hammer'); Frank.HammerColour := 'green'; When you're done with them you free these instances so they release their memory Frank.Free; Frank := nil; { to everyone else, lets not make this line a thing please :-) } John.Free; John := nil; So the above code declared two instances John and Frank, created those instances, interrogated their respective hammer colours, and lastly freed the memory associated with those instance variables. Very important, if you're in another unit and you want to know what Frank's hammer colour is, you need to be able to reference the Frank instance through the Frank variable. Now that Frank variable is probably not declared in the same unit as the TFantasticWoodenTableClass. It's probably declared in some other unit. You have to add that other unit to your uses clause, not the unit that has the TFantasticWoodenTableClass in it. How do you know which other unit? Well you have to go searching for it just like you did at 7:04 in your video. How do you know what to search for? Detective work. Welcome to programming. At the 7:30 mark of the video you're getting close to understanding the problem but the actual solution is going to evade you until you learn more about object oriented programming. I haven't watched it but this video might be a good start. -
Problems with Delphi class structure / visibility
Lachlan Gemmell replied to Willicious's topic in Delphi IDE and APIs
I watched the first third of your video. You don't have an instance of your class TNeoTheme to actually retrieve the property from. A theme sounds like something you only need a single instance of in your whole application (I could be wrong on that, but for now let's say I'm right). Since there's only going to be one of them a global TNeoTheme instance variable will be acceptable for now. Let's declare it in the LemNeoTheme.pas unit unit LemNeoTheme; interface type TNeoTheme = class private FLemNames : string; public property LemNames : string read FLemNames write FLemNames; end; var MyTheme : TNeoTheme; { this variable MyTheme will represent the single instance of the class TLemNeoTheme } { it does not however create that instance here, just declares the variable } implementation { code, code, code, more code } { now at the very bottom of the unit, just before the final end. statement } initialization MyTheme := TNeoTheme.Create; { this is where the memory for the instance of TLemNeoTheme is allocated } { and assigned to the MyTheme variable. It will occur when the program starts } finalization MyTheme.Free; { this is where the memory for the instance is released. It will occur when the program shuts down } MyTheme := nil; end. Now over in TGamePreviewScreen.GetTextLineInfoArray you access the LemNames property via the MyTheme instance variable Result[2].Line := Result[2].Line + IntToStr(zombies + lemmings) + MyTheme.LemNames; Please be aware that we're only scratching the surface with the code above. It's probably appropriate for your TNeoTheme class but most other class instances will not be global variables like this and will require other techniques. Actually surely there is already a TNeoTheme instance somewhere in this code already. Do a Find in Files search for "TNeoTheme.Create". Ignore the actual constructor implementation but you'll likely find something like: AnotherThemeInstanceVariable := TNeoTheme.Create; That variable AnotherThemeInstanceVariable is probably the one you should be using rather than the MyTheme variable I declared and created above. I hope you'll take this in the spirit that it's intended in but a quick look at the project on that video makes me think you've picked a pretty big mountain to climb for your first outing. Maybe go find a few gentle hills to train on first before attempting something as large and complex in scale as game development. -
Is there MQTT connection feature in RAD Studio v10.4?
esegece replied to TimCruise's topic in Delphi IDE and APIs
Hi, I am Sergio the developer of sgcWebsockets library (esegece.com). The MQTT protocol is supported (3.1.1 and 5.0) on plain TCP and WebSocket connections (secure connections are supported too) and can be compiled on all Delphi personalities (windows, mobile, linux...). You can check the following link, which contains more info about the MQTT client component: https://www.esegece.com/websockets/protocols/mqtt The documentation can be accessed from here: https://www.esegece.com/help/sgcWebSockets/#t=Components%2FProtocols%2FSubprotocols%2FMQTT%2FProtocol_MQTT.htm Kind Regards, Sergio -
Automate Restorable Operations with Custom Managed Records
Erik@Grijjy posted a topic in Tips / Blogs / Tutorials / Videos
Check out how you can use Custom Managed Records to reduce the number of try..finally blocks you write. https://blog.grijjy.com/2020/08/03/automate-restorable-operations-with-custom-managed-records/ -
Bitmaps2Video for Windows Media Foundation
programmerdelphi2k replied to Renate Schaaf's topic in I made this
said so much, and nothing!