

PeterBelow
-
Content Count
566 -
Joined
-
Last visited
-
Days Won
13
Posts posted by PeterBelow
-
-
9 hours ago, Mr. E said:Greetings,
How long does it take to update Delphi 11?
The resource and performance monitor do not show any activity (hdd, network).
It is a Windows 11 Pro VM on Proxmox, with adequate resources; I disabled the Firewall and it has no antivirus.I have almost an hour and I don't see any progress in the update/installation (web install).
I'm going to wait another hour; but, I am tempted to stop the VM, restore it (I did a previous backup) and retry.
The update has problems with uninstalling some GetIt packages, e. g. Parnassus Bookmarks and Navigator. It is recommended to manually uninstall these first before you run the update. I dimly remember a blog post about this issue but cannot find it at the moment.
Anyway: the GetIt uninstall opens a command window that then fails to close. Just close it yourself, you may actually be able to type "exit" at its prompt for that, otherwise shoot it down via task manager. The process will then continue normally.
-
2
-
-
5 hours ago, limelect said:After so many years of successful Delphi, I almost give up
on my free program.
After out of memory I made a new test program and this is what I came up with
1. NO PROBLEM with SQL.
Have you tried to build the program as a 64 bit executable? You also need the 64 bit version of MySQL of course.
-
51 minutes ago, brk303 said:I have a design time package which has a form linked to a datamodule.
The same code is used for a standalone app, in which everything works fine, but in design time package the links between forms/datamodules are not restored.
I have used RegisterFindGlobalComponentProc to hook in my function that does this:
if AnsiSameText(Name, 'dmxxx) then
Result := dmxxxThis fixes the links from form to dmxxx, but I then found the dmxxx has name = '' and ComponentCount = 0, there should be 3 components on datamodule.
All of this runs fine in standalone app outside IDE.
Does anyone know what is different with component name/linking/restoring in IDE compared to standalone ?
As far as I know forms (all TCustomForm descendants in fact, including TDatamodule) are not meant to be added to design-time packages. If you want to make them reusable from other projects add them to the object repository instead, this way they are accessible from the File -> New -> Others dialog.
-
8 hours ago, SteveHatcher said:I am trying to understand some relatively simple Delphi code for a GUI and am wondering if there is any tool which can tell me what which classes call what, and when etc. (Delphi 10.4 Community Edition.)
I have looked at class explorer and Model View, but they both show just the classes (and hierarchies) which are used, not necessarily when one calls another.
What I am after is something generated that would look as follows (just making this up):
ObjectA
ObjectA.Prop1
ObjectA.Prop1.doesSomething
ObjectA.ButtonClick
tmpObjectCreate
tmpObjectCreate.Prop1.doesSomethingElse
ObjectA.CallSomeMethod
Sort of what you might get from adding a breakpoint and steeping through line by line, but wondering if there is any way to generate this automatically?
This might not exist but would love some input.
ThanksPascal Analyzer may be helpful in this context. It is not free but if I remember correctly you can evaluate it for a period until paying for it. Have not used it myself, though.
-
21 minutes ago, programmerdelphi2k said:no, no, no!
I can do any number of searches, no matter what size pattern is used!
If there are 1000 occurrences within the file, I can find them all and replace them!
It doesn't matter the size of the "pattern" I'm looking for! The only restriction is: the pattern size must be smaller than the file size!If you do multiple passes over the file you can end up replacing bytes in a part you replaced in a previous pass, which is usually not what you want.
-
17 hours ago, programmerdelphi2k said:This approach only works if you have one single search/replace pair.
-
On 11/27/2022 at 3:47 PM, robertjohns said:It is 32 bit Platform and the file size is 3GB
OK; i'm done with the example code. Find a small test project attached as a zip file. It contains a unit named PB.ByteSearchAndReplaceU that implements a class TByteSearchAndReplace that encapsulates all the code for this task. It compiles and runs but I have not checked that it does do the actual replacements properly, due to the lack of test data. I leave that to you, good luck.
-
18 hours ago, omnibrain said:We read the ansichars that come via the serial connection and put them into chars and them into strings and work from there. I think that's not ideal because strings are unicode (nowadays) but so far it worked fine.
That is the source of your problem because converting an AnsiChar to UnicodeChar ( = Char) is not a simple byte copy, it will convert characters not in the 7 bit ASCII set to Unicode codepoints that may have different ordinal values. This depends on the active ANSI codepage of the system as well.
The only sensible solution is to treat bytes as bytes and not as characters, use TBytes or other suitable containers to store sequences of bytes instead of strings (ANSI or Unicode). Writing a Pos equivalent for TBytes is easy and there are likely dozens of implementations around, you just have to find one
.
-
1
-
-
23 hours ago, robertjohns said:It is 32 bit Platform and the file size is 3GB
You should have given us this info in your first post since it is very relevant to the way this needs to be approached. If the whole file does not fit into available process memory you have to process it in chunks, and this opens a whole new can of worms (only a chicken would be happy about that
). You have to deal with source byte sequences exceeding the end of a chunk, for example. And do you really want to do the replacement directly on the original file, potentially risking to corrupt it if something goes wrong?
Anyway, I don't have time today to whip up any coding example, so be patient.
P.S. : No PM unless explicitely requested! This forum is also intended as an information source for future problems from other people.
-
1
-
-
31 minutes ago, William23668 said:Thanks this is the last version 28.0.46141.0937 ?
Mine shows 28.0.46481.1287.
-
1
-
-
48 minutes ago, robertjohns said:Thanks a lot for your help but I get error Out of memory while expanding memory stream.
How large is the file you are trying to load? Did you build for a 32 or 64 bit platform? Try the latter.
-
23 hours ago, robertjohns said:Thanks .. No Actually I am confused with
var
theFile: string;
SearchFor, ReplaceWith: TBytes;
begin
SearchFor := [$76, $00, $61, $00, $6F, $00, $70, $00, $5F, $00, $00];
ReplaceWith := [$00, $00, $61, $00, $6F, $00, $70, $00, $5F, $00, $5F];
ReplaceBytesInFile(theFile, SearchFor, ReplaceWith);$76, $00, $61, $00, $6F, $00, $70, $00, $5F, $00, $00
$5F, $00, $74, $00, $7A, $00, $5F, $00, $00
$77, $00, $68, $00, $79, $00, $70, $00, $5F, $00, $00
$44, $10, $6D, $00, $6F, $00, $64, $00, $65, $00, $6D, $00, $5F, $00, $00
$69, $10, $00, $00, $6C, $00, $75, $00, $65, $00, $74, $00, $6F, $00, $6F, $00, $74, $00, $68, $00, $5F, $00, $00
$6F, $10, $6D, $00, $64, $00, $74, $00, $70, $00, $73, $00, $65, $00, $63, $00, $61, $00, $70, $00, $70, $00, $5F, $00, $00
$65, $10, $6D, $00, $64, $00, $74, $00, $70, $00, $5F, $00, $00
$00, $10, $61, $00, $00, $00, $6C, $00, $5F, $00, $00
$34, $10, $64, $00, $73, $00, $70, $00, $5F, $00, $00
$8C, $10, $6B, $00, $65, $00, $79, $00, $6D, $00, $61, $00, $73, $00, $74, $00, $65, $00, $72, $00, $5F, $00, $00
$3B, $00, $00, $00, $6F, $00, $6F, $00, $74, $00, $5F, $00, $00How can declare other hex lines for variable SearchFor, ReplaceWith: TBytes;
Thanks in advance
D11 actually accepts initialized TBytes arrays in typed constants, so yo can do this:
procedure ReplaceBytesInFile(aStream: TMemoryStream; const aSearchBytes, aReplaceBytes: TBytes); var LNumBytes: Integer; LPos, LEnd: PByte; begin LNumBytes := Length(aSearchBytes); Assert(LNumBytes = Length(aReplaceBytes), 'Arrays have to be of the same length!'); if LNumBytes = 0 then Exit; LPos := aStream.Memory; LEnd := LPos; Inc(LEnd, aStream.Size - LNumBytes ); while LPos < LEnd do begin if LPos^ = aSearchBytes[0] then begin if CompareMem(LPos, @aSearchBytes[0], LNumBytes) then begin CopyMemory(LPos, @aReplaceBytes[0], LNumBytes); // or // Move( aReplaceBytes[0], LPos^, LNumBytes ); Inc(LPos, LNumBytes); end else Inc(LPos); end else Inc(LPos); end; {while} end; type TDataRec = record SearchFor, ReplaceBy: TBytes end; const Data: array [0..1] of TDataRec = ( ( SearchFor: [$74, $00, $6f, $00, $7, $00, $73]; ReplaceBy: [$68, $00, $6f, $00, $7, $00, $73]), ( SearchFor: [$76, $00, $61, $00, $6F, $00, $70, $00, $5F, $00, $00]; ReplaceBy: [$00, $00, $61, $00, $6F, $00, $70, $00, $5F, $00, $00]) // add more data as needed, adjust array upper bound accordingly ); procedure TForm2.Test; var I: Integer; theFile: string; LBuffer: TMemoryStream; begin theFile := 'pathname here'; LBuffer := TMemoryStream.Create(); try LBuffer.LoadFromFile(theFile); for I := Low(Data) to High(Data) do ReplaceBytesInFile(LBuffer, Data[I].SearchFor, Data[I].ReplaceBy); LBuffer.SaveToFile(theFile); finally LBuffer.Free; end; end;
Untested!
-
Please use your brain, its not just there to keep your head from imploding, you know
.
The code works for every byte sequence as long as both arrays are of the same length, so the total size of the data does not change.
-
3 minutes ago, Clément said:Hi,
My customer has a database with a lot of employee picture ( for smartcard tags).
He wants to overlap each photo to a custom background.
The idea is to trim out as much as possible the white rectangular background of the employee photo, leaving only his face, and then apply it over a custom background.What are my options?
If the background is indeed a single color you can treat that as transparent while drawing, using the TransparentBlt API function. You may have to convert the JPG to a TBitmap first, though. TBitmap has TransparentColor and Transparent properties, and a TImage with a TBitmap loaded also has a Transparent property that makes use of the TBitmap properties when rendering the image.
If the background is not a single color you may have to preprocess the Tbitmap to turn pixels with colors "close enough" to clWhite to clWhite first.
-
1 minute ago, DavidJr. said:The actions in the timer do work, but methods running in UI thread are not finishing (writing to fields or increasing progressbar) unless my mouse is in the window.
That cannot be unless you are doing something seriously wrong in you UI updating or your timer intervals are very short, so the UI has no time to repaint properly. We cannot diagnose this without seeing some code...
-
29 minutes ago, DavidJr. said:Hi,
On a fairly large sized application with a few threads doing most of the work the UI does have 2 timers for updating fields based on calls to Thread class properties, I get a almost consistent pauses in the UI (ie... progress bar updates, TRichEdit line adds and TLabel caption updates) unless my mouse pointer is moved over the window. This is on a PC with two monitors. Is there something I can call to keep the UI from pausing? I tried finding other posts that ask this before posting here. Thanks.
David
The description sounds as if the UI thread does not process the timer messages in the expected fashion unless other messages are also in the message queue, in this case WM_MOUSEMOVE messages. This is not the normal behaviour of a Windows application. Add some logging to the timer events to check whether the events are triggered at the expected interval (OutputDebugStr should do if you run from the IDE).
-
On 11/22/2022 at 5:00 PM, robertjohns said:Thanks the code works but I am sorry I did not explained my question properly . yes '.' represents 00 in hex viewer .
HEX value for t.o.p.s is
74 00 6f 00 70 00 73
and HEX value for h.o.p.s is
68 00 6f 00 70 00 73
so I have to change hex value from 74 to 68
value should be changed by hex method not tops to hops
Thanks in advance
So what is the problem? The procedure takes an array of bytes, just feed it the correct one, e. g.
var theFile: string; SearchFor, ReplaceWith: TBytes; begin SearchFor := [$74, $00, $6f, $00, $70, $00, $73]; ReplaceWith := [$68, $00, $6f, $00, $70, $00, $73]; ReplaceBytesInFile(theFile, SearchFor, ReplaceWith);
-
10 hours ago, robertjohns said:Thanks , no it is not a text file it is binary file where I need to search all instances of t.o.p.s and need to replace only t as h in all the instances by inc method and save the file
Since the replacement does not change the total size of the data you can load the file into a buffer suitable for binary data, do the replacement in this buffer and finally write it back to the file. A suitable buffer would be a TMemoryStream. The question is what these '.' bytes in your target string are. If these are actually zero bytes displayed as '.' in a hex viewer the target would be simply the UTF16 string 'tops', if these are real dot characters it would probably rather be the ANSI string 't.o.p.s'. You can probably answer that by looking at the byte following the 's', it should be 0 if this is UTF16 text. Let's assume it is, then the algorithm would be like this (untested!):
procedure ReplaceBytesInFile(const aFilename: string; const aSearchBytes, aReplaceBytes: TBytes); var LBuffer: TMemoryStream; LNumBytes: Integer; LPos, LEnd: PByte; begin LNumBytes := Length(aSearchBytes); Assert(LNumBytes = Length(aReplaceBytes), 'Arrays have to be of the same length!'); if LNumBytes = 0 then Exit; LBuffer := TMemoryStream.Create(); try LBuffer.LoadFromFile(aFilename); LPos := LBuffer.Memory; LEnd := LPos; Inc(LEnd, LBuffer.Size - LNumBytes ); while LPos < LEnd do begin if LPos^ = aSearchBytes[0] then begin if CompareMem(LPos, @aSearchBytes[0], LNumBytes) then begin CopyMemory(LPos, @aReplaceBytes[0], LNumBytes); // or // Move( aReplaceBytes[0], LPos^, LNumBytes ); Inc(LPos, LNumBytes); end else Inc(LPos); end else Inc(LPos); end; LBuffer.SaveToFile(aFilename); finally LBuffer.Free; end; end; ReplaceBytesInFile(theFilename, TEncoding.Unicode.GetBytes('tops'), TEncoding.Unicode.GetBytes('hops') );
-
1 hour ago, aehimself said:Yes, and unfortunately loading the stream overwrites this setting; it has no effect in the new document being loaded.
My issue with ConsistentAttributes is that it needs a selection - and for that I need to reposition the cursor again, most probably ending up at the same slowdown.
I'm attempting to experiment with EM_GETTEXTRANGE but unfortunately it doesn't seem to care about formatting at all, just returns as many characters as I desire.
As far as I know the MS richedit common control does not support owner drawing at all, which is the reason why styling does not work for it. You could try to parse the rich text and modify the main color table in it before it is loaded, but I would rate that as a desparate measure; the RTF format is complex, to say the least.
You could try to select larger blocks of text (e.g. lines or paragraphs) to find some with consistent text color; if your text is mainly the default color that may reduce the number of SelStart/SelLength calls needed to a managable number.
-
Have you tried to just set DefAttributes.Color before calling the inherited StreamIn method? SelAttributes.ConsistentAttributes may also be of use if you really need to manually correct the font color.
-
3 hours ago, Al T said:I'm trying to find a automatic solution that will force Delphi to reload a design time package every time the project that contains that component loads.
Anyone know of a solution?
I'm not sure I understand your requirement, but what you can do is this:
With no project or project group loaded in the IDE, go to the Component -> Install packages menu. The appearing dialog list all design-time packages the IDE knows about (from the registry). Make sure package in question is not checked in the list. Close the dialog with OK. You may want to close and restart the IDE and call up the dialog again to vertfy that the package ist still unchecked.
Now open the project in question, call up the dialog again and this time check the package. OK the dialog, do a save all for good measure.
These steps should make sure the component package is only loaded for projects that explicitely want that. The project-specific package selection is stored in the project's DPROJ file.
-
2 hours ago, Chris-J said:Hello All,
I hope this is the right place to ask this question.
I am trying to make my desktop app (written in C++Builder) look slightly more modern/cloud/browser-like. Researching this, I find that one (aesthetic) way of giving more of a cloud impression, is to use use (Google) web-fonts rather than (Microsoft) desktop fonts. But when I click on "Font" in any of my VCL components (labels, etc) the fonts offered to me are all (Microsoft) desktop fonts.
So my question is: how can I use a web-font such as 'Open Sans', which is free/open-source: https://fonts.adobe.com/fonts/open-sans ... in C++Builder ?
Thanks in advance for any suggestions.To be able to use a font on Windows it has to be installed (Font applet in the control panel or using the Windows font API, i. e. AddFontResourceEx). You have to do this on your user's systems as well, so have to distribute the font with your application.
-
10 hours ago, Heremik said:Hello,
I work with Delphi from the begining (even begun with turbo pascal).
I have to make calculation with very big array. if I use dynamic array no problem for the size.
But dynamic array are very slow vs static array (about at least 2X).
So my intention was to use static array to perform my objective.
But, i have a problem.
When I try a clean VCL projet and I declare that :
Table : array[0..536870473] of integer; => Ok
Table : array[0..536870474] of integer; => Access violation (74 to 76)
Table : array[0..536870477] of integer; => Compilation error, data too big > 2Go...I have tried with boolean :
Table: array [0 .. 2147481895] of Boolean; => Ok
Table: array [0 .. 2147481896] of Boolean; => Access violation (896 to 911)
Table: array [0 .. 2147481911] of Boolean => Compilation error, data too big > 2Go...Ok, Access violation is just an error to the limitation. But in 64 bits why limitation to 2 Go ???????
I have 80 Go of RAM on my computer, and I don't understand why my static array are limited.
Is there a solution ? (with performance, because I always need speed).
This seems to be a limitation of the compiler, System.GetMem does use NativeInt for the size parameter, so can allocate more than 2GB for a 64 bit target.
This works:
procedure TForm2.Test; var p: pinteger; begin GetMem(p, NativeInt(High(Integer)) * Sizeof(Integer)); try Caption := Format('p= %p',[p]); finally FreeMem(p); end; end;
The only problem is that you cannot declare a proper static array type for this memory block, so would have to do all the index calculations in code.
However, you can size a dynamic array to more than 2GB:
procedure TForm2.Test2; var a: array of integer; begin SetLength(a, High(Integer)); try Caption := Format('p= %p',[pointer(a)]); finally setlength(a, 0); end; end;
-
16 hours ago, Al T said:I'm just worried "Developer license" will downgrade all previous versions like my Enterprise license did...
When I upgraded from 10.4 developer to Delphi 11.0 Enterprise... all previous versions of Delphi upgraded to Enterprise. I'm wondering if I install Delphi 12 Developer... would it downgrade all previous versions to developer?
No, all previous licences for higher editions will stay valid.
Include External Text Files in Output Folder
in General Help
Posted
Build events allow you to execute shell commands, like "copy" or "rename", using macros that get replaced with project related pathes etc.. Since the files are used by the finished program I would use the post build event for that. The deployment stuff is for non-Windows targets only if I understood that correctly.