Jump to content

PeterBelow

Members
  • Content Count

    549
  • Joined

  • Last visited

  • Days Won

    13

Everything posted by PeterBelow

  1. PeterBelow

    Find, Replace and Save

    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);
  2. PeterBelow

    Find, Replace and Save

    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') );
  3. PeterBelow

    TRichEdit with VCL styles

    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.
  4. PeterBelow

    TRichEdit with VCL styles

    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.
  5. 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.
  6. PeterBelow

    Web-fonts v Desktop-fonts

    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.
  7. PeterBelow

    Array size 64bits

    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;
  8. No, they are the same major version. If you wait for 12.0 to come out (no idea when that will be) it could coexist with 11.0 Enterprise.
  9. Two different editions of the same Delphi/RAD Studio major version cannot coexist on the same PC, different editions of different major versions can, however. If you need the former you have to install one of the editions in a VM or different PC.
  10. Modify the SELECT statement for the query to include an ORDER BY clause for the code column. Then you can walk over the query result and just compare the current record's code to the one from the previous record (which you remember in a local variable in the loop). You can also formulate a SELECT statement that just returns the duplicates of course...
  11. PeterBelow

    Delphi 11.2 fatal error F2613

    The next thing to check would be whether the folder $(BDSLIB)\$(Platform) resolves to for your target platform ( should be C:\Program Files (x86)\Embarcadero\Studio\22.0\lib\android64 for an install using the default folders) is actually there, contains release and debug subfolders, and see if these contain the file(s) the error message moans about, e.g. system.classes.dcu and system.classes.o. I think that should be the file names. I have not installed Android platforms, so cannot check directly. If the files are there go and check the pathes in the specific project options, also check what path the BDSLIB environment variable resolves to.
  12. PeterBelow

    Delphi 11.2 fatal error F2613

    check the Library path in the Tools -> Options dialog, Language -> Delphi -> Library page. It should start with $(BDSLIB)\$(Platform)\release. The "debug dcus" path on the same page should be $(BDSLIB)\$(Platform)\debug. Check this for every of the platforms you have installed (combobox at the top of the page).
  13. PeterBelow

    Implement logic in TListView

    Does only work if only one item can be selected from the group, but IO think in OPs case selecting both OptionOne and OptionTwo would be valid.
  14. PeterBelow

    display hint

    The hint system is designed to show a hint for a certain time when the mouse enters a control's real estate. In your case the mouse stays over the paintbox, so the hint is not shown again even if its value changed. Try to call Application.CancelHint after changing the value. And if you draw the gauge anyway, why not draw the value as well instead of using a hint window?
  15. You have a timing issue here, the event fires before the page has become visible and the controls on it can be focused. The usual fix for such problems is to post (PostMessage) a custom message to the form and do the focus change in the handler for this message. There is also a OnTabVisibleChanged event for TRibbon, perhaps that fits better with your goal.
  16. PeterBelow

    FaVolumeId??

    I would rewrite this code using the routines from System.IOUtils. Use TDirectory.GetFiles to get a list of files in a directory you can then walk over. TPath.GetTempPath gets you the user's temp folder, TFile.Delete deletes a file. Use a try except block around this statement to catch a failure to delete a file.
  17. PeterBelow

    Corean write in explorer popup menu

    Scan you PC for malware, looks like something installed context menu extensions for Windows explorer...
  18. PeterBelow

    Set colour for TStaticText with themes.

    Deselect seFont in the StyleElements property.
  19. PeterBelow

    SingleStep with F7/F8 hang IDE

    Mh, never had a problem with those, but my projects are small to medium since i'm retired and use no 3rd party controls.
  20. PeterBelow

    SingleStep with F7/F8 hang IDE

    Are you working on a 32 or 64 bit target?
  21. PeterBelow

    Saving ProjectGroups to a new folder

    With your steps you are not creating a new project group, you just rename the project. If you saved the project group before closing the IDE (the IDE should prompt you to do this) the group should contain the renamed project the next time you open it. To have more than one version in the same project group you have to explicitely add the old version to the group.
  22. PeterBelow

    2 errors that do not exist?

    in Tbasicdm.DatamoduleCreate, is there really an underscore in the line after begin? That would be the source of the first error. The second may be a false positive, error insight is easily confused by conditional compilation...
  23. PeterBelow

    DBRadiobutton

    Set the form's ActiveControl property to some other control that can take the focus, e.g. a button.
  24. PeterBelow

    11.2 Patch 1 is out

    The installer will probably only be updated when (if) a 11.3 release comes out. Just run the installer and then check the IDE about dialog. Mine shows build 28.0.46481.1287 after the patch was installed.
×