-
Content Count
115 -
Joined
-
Last visited
-
Days Won
2
Everything posted by stijnsanders
-
Looks like normal behaviour like you describe it: Windows will 'white out' applications and show them as non-responsive, when they stop reading messages from the message queue. In Delphi applications, there are two main ways to solve this: either call Application.ProcessMessages from time to time from the code that does the processing. There's some special care you'll need to take for the case when the user wants to abort the importing, or close the application. This will 'unfreeze' the application, because messages get handled, but may slow down the importing a little. The second way is to write the importing code so it uses background threads. There are libraries and solutions that can help you with this, or the hard way is inheriting from TThread yourself, but then you need to know how to synchronize between the main thread to output progress and results from the importing.
-
Project Options -> Version Info aka. dproj madness
stijnsanders replied to Attila Kovacs's topic in Delphi IDE and APIs
What I typically do to get it right, is open the dproj in a text editor, and remove all of the `<Ver`* elements that are not inside of the <PropertyGroup Condition="'$(Base)'!=''">` element, then only change the version info in the IDE with 'Target' set to 'All Configurations' -
How to execute a cmd file in delphi in invisible mode
stijnsanders replied to NBilov's topic in Windows API
If you need to capture and process the output of the cmd, I would even advise to use CreateProcess with STARTF_USESTDHANDLES. I have an example here, but it's a bit of a confusing sample because the reading of the pipes happens in the DoCommand procedure, I should take some time to write a cleaner example... -
TWSocketServer stop accepting connections
stijnsanders replied to Eric Fleming Bonilha's topic in ICS - Internet Component Suite
If you really really need to do the work on the main thread (Are you really really sure?) I would consider doing the bind and accept calls on a separate thread. It will open and accept incoming connections, so Windows gets the correct inputs and knows you still intend to work through incoming requests eventually. Do read all about thread locking and critical sections first, as you'll need it to pass requests to and from a background thread. What I would also consider, is having the work done on a main thread of a separate instance of a separate exe-file, and do CreateProcess for each incoming request. It may look like a lot of work, but will solve the 'main thread problem' and allow to handle multiple requests at once. -
RAD Studio Breakpoints not working
stijnsanders replied to Willicious's topic in Delphi IDE and APIs
I still find it a valid question. I remember this time I had something similar and fixed it by deleting the project's dcu's, to have compile/build generate all new ones. I don't remember how many Delphi versions ago it was though... -
If you are willing to consider one more alternative, I've been working on a solution to use the power and speed of the Delphi compiler for web projects, but specifically in a non-RAD way, that is without form designers: https://github.com/stijnsanders/xxm It is mostly based on my previous experience on (old!) web-projects based on PHP, (old!) ASP and Cold Fusion, so — coming from React — you may find it lacking on the side of client-side support and scripting. But it's not impossible. It should offer a great platform to develop frameworks in any which way you want (React, Vue, Wordpress, Rails etc. are also based on JavaScript, PHP, Ruby etc.) If you're willing to investigate an existing xxm-based web-project, look here: https://github.com/stijnsanders/tx#tx Since React (and others) are based on keeping a server-side copy of the view and updating the client with changes to the DOM, I was planning on trying to create a proof-of-concept to show that this is also possible with xxm, but haven't gotten around to it. I've also come to think it may have been a bad choice to build the base interface (IXxmContext) on the COM sub-system, so I might also start an 'xxm v2.0', but currently I've got more plans than I can make time to make them work... If you would take a look, please let me know what you find...
-
Just thinking out loud here: could you build SumatraPDF into a DLL you could call from Delphi code?
-
I wonder if you could get to this data using WBEM/WMI... https://stackoverflow.com/questions/2761328/how-do-i-use-wmi-with-delphi-without-drastically-increasing-the-applications-fi
-
In case you're interested, I've written my own JSON parser: https://github.com/stijnsanders/jsonDoc/blob/master/jsonDoc.pas
-
Undeclared identifier but the code compiles
stijnsanders replied to Valter's topic in Delphi IDE and APIs
What is the exact variable type of ExcelApplication and ExcelWorkbook? I would guess Variant or OleVariant, and in that case, a technique called "late binding" is used. It both explains why you don't have code-completion, and that the code compiles even without the compiler knowing about the specific available properties and methods. Behind the scenes, the operations you do (Cells, Select and Save in this case) are resolved at runtime on the 'living' objects using hidden 'IDispatch' interfaces that list the available properties and methods by name. It was invented by Microsoft to make dynamic scripting languages work (like VBScript, and actually also something called "JScript" because they weren't allowed to call it JavaScript, but that's another story). And Delphi has excellent support for this (but a downside is it works so good you don't see anything of it and can't access it, need to get the sequence of calls exactly right and need to debug on live objects.) -
How to build JSON with ISuperObject as an Array ?
stijnsanders replied to PizzaProgram's topic in ICS - Internet Component Suite
In case anyone wants to try out an alternative, with the JSON library I wrote based on variants, it would look like this: o := JSON(['base','something','identifiers',VarArrayOf([JSON(['id',z2])])]); -
So much code! Are you willing to try out a different JSON solution? When I was writing my very bare-bones connector to MongoDB, I was really into the Variant type, and really disliked long lists of overloads for all of the types. So I created my own JSON solution, that heavily uses the Variant type, and offers a really concise syntax. The above would look like this: JSON(['registration_ids',VarArrayOf(['crX...']),'notification',JSON(['title','Hi','body','Notification test'])])
-
I once did something like the reverse: I added NTLM-support to a HTTP service I created myself: https://github.com/stijnsanders/xxm/blob/master/Delphi/http/xxmHttpCtx.pas#L388 as server and client both use the same 'SChannel' API calls, if you read around in the documentation, you should find what you need to make it work: https://docs.microsoft.com/en-us/windows/win32/secauthn/acquirecredentialshandle--schannel
-
Why use Python? There are ways to 'read from' the webcam from Delphi code directly. After a quick search I found this: https://stackoverflow.com/questions/9106706/delphi-webcam-simple-program but that's from 2012? There may be others, newers, and more multi-platform options if you search around.
-
I created my own JSON unit because I really dislike long lists of overloads, and really like the Variant type: https://github.com/stijnsanders/jsonDoc It grew out of my attempt at a 'really raw' connector for MongoDB, so to/from BSON functions are here: https://github.com/stijnsanders/TMongoWire/blob/master/bsonTools.pas
-
FreeAndNil() - The Great Delphi Developer Debate
stijnsanders replied to AlexBelo's topic in Tips / Blogs / Tutorials / Videos
Actually, picking up on that. I could perfectly agree with if Delphi would make obj.Free; also set obj to nil... -
FreeAndNil() - The Great Delphi Developer Debate
stijnsanders replied to AlexBelo's topic in Tips / Blogs / Tutorials / Videos
I made an attempt to explain what I think it's really about here: http://yoy.be/FreeAndNil.html Let me know if this hits the mark or is way off... -
example of multi-part form containing headers, body (parameters) and a file to upload
stijnsanders replied to Brian Culverwell's topic in ICS - Internet Component Suite
I think I've come across the things you describe when creating xxm. There's more to the project than REST, but to have an out-of-the-box option of hosting web projects created with xxm, I created a really basic HTTP server, that also handles multipart file uploads. So, if you have a web form like this that would allow a user to post a file, the server would process the parts of the request into specific parameters like this. But I'm afraid this is quite an integrated solution and not quite a 'snippet' you can use to apply elsewhere. None-the-less I warmly invite you to take a good look at xxm and see if it could be a fit for any project you're considering that combines Delphi and the web. -
I see in System.pas that VAnsiString is of type pointer and not of type AnsiString. I'm not sure you can 'just' cast it into type AnsiString (which happens to also be a pointer internally), but assuming you can: SizeOf(VAnsiString) will probably always be 4 (on 32-bits, 8 on 64-bits), I guess you'll need Length(AnsiString(VAnsiString)) then Move(AnsiString(VAnsiString), ... will actually read the pointer value (and whatever happens to be in memory after that) not the string data itself. You have to dereference, either explicitly: Move(VAnsiString^, ... or I prefer to do this as if I'm letting Move know where the start of the string data is: Move(AnsiString(VAnsiString)[1], ... And you use SizeOf for the Inc again, change that to Length, of better still use an extra local variable so you only need 1 call to Length (and the compiler can optimize register allocation for it)
-
If you do find anything about it, I wonder how it would relate to dwScript's number of lines of code...
-
If you're willing to examine an alternative, and if you're struggling with other JSON solutions that appear to 'bind' the JSON data to some sort of schema that determine the full extent of what you'd possibly do with the date, check out this JSON unit I've created in the margin of an attempt at a no-frills MongoDB connector: https://github.com/stijnsanders/jsonDoc#jsondoc I also dislike solutions that depend long lists of overloads for all kinds of types, so it depends on Variants heavily, especially that a Variant value can hold a reference to the interface of a live instance if anything, such as another IJSONDocument object. Also arrays in JSON are converted to and from Variant arrays. So using VarType, you could detect when data is an array or not, if it's an sub-object, you'll get varUnknown, look at the function JSON declared in the unit how to get a IJSONDocument reference. Also have a look at function JSONEnum to list the "sectionX" fields the base object might have.
-
TBitmap to TBytes for ESC/POS Thermal Printer
stijnsanders replied to at3s's topic in RTL and Delphi Object Pascal
If I recall correctly, the GetPixel method is rather slow. Does FMX.Graphics' TBitmap also have a Scanline pointer property? -
Can Delphi randomize string 'Delphi'?
stijnsanders replied to Mike Torrettinni's topic in Tips / Blogs / Tutorials / Videos
Aah, that makes me think of the infinite monkeys theorem (and also) -
I would humbly like to offer another alternative. By no means I want to imply it is any better than the other options of building a website with Delphi, but if you're willing to not use the RAD-side of Delphi, and its IDE, but want to use the Delphi language and its compiler, and combine HTML and server-side logic code in the same files much like (early!) PHP or Cold Fusion, I've created this solution to do just that: https://github.com/stijnsanders/xxm#xxm What I wanted was a way to create a website by working on the code, press F5 in a browser to put it to work, but have the website itself run from a freshly compiled DLL, from a Delphi project. This same DLL would use a generic interface, so by moving it from your development machine to a online web-server, you could use the same DLL with Apache httpd, IIS, or SCGI. It may take some work to get it going and set it up, and you don't have any support of a platform, but if you know what you're doing, that can be a good thing. Most other web-platforms I've witnessed all take some freedom away by the choices that have been made in their design, and you inevitably will hit these limitations later when you're trying to do something the platform wouldn't support. If you're interested to see a fully developed web-application on xxm, have a look here: https://github.com/stijnsanders/tx#tx (I once made "get started" tutorial, but should really update it, replace xxmLocal with xxmHttp and IE with Firefox or Chrome...)
-
Delphi AES encryption/decryption
stijnsanders replied to Soji's topic in RTL and Delphi Object Pascal
If you're interested in another alternative, I've started from the root document to make a pure-Delphi version under a permissive license: https://github.com/stijnsanders/tools/blob/master/crypto/aes.pas I also did HMAC and PKDF2 here- 35 replies
-
- encryption
- decryption
-
(and 2 more)
Tagged with: