Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 12/23/21 in all areas

  1. There is a function for that in System.IOUtils: MyByteArray := TFile.ReadAllBytes(filename);
  2. I have it this way (only for VCL). In the manner of Attila Kovacs. I only hide the main form by placing it off the screen. procedure NewForm(ATypeForms: TTypeForm); const Position = 200; var BasalFormClass: TBasalFormClass; LeftMainForm, TopMainForm: Integer; BasFrm: TBasalForm; begin ServeMainForm(LeftMainForm, TopMainForm); BasalFormClass := GetForm(ATypeForms); try BasFrm := BasalFormClass.CreateBasalForm(nil); BasFrm.Position := poDesigned; SupObjJson.ReadForm(BasFrm); BasFrm.ShowModal; finally if (oGlobVar.ActualForm = Application.MainForm) then begin if (LeftMainForm < 0) then begin LeftMainForm := Position; TopMainForm := Position; Application.MainForm.Left := LeftMainForm; Application.MainForm.Top := TopMainForm; end; end; end; end;
  3. I think this is a bad idea, however here is a code for VCL: procedure ShowForm ( ThisForm: TFormClass ) ; var lForm: TForm; begin lForm := ThisForm.Create(nil); try lForm.ShowModal; finally lForm.Free; end; end; {Example to use} procedure TForm1.Button1Click(Sender: TObject); begin ShowForm(Tform1); end; procedure TForm1.Button2Click(Sender: TObject); begin ShowForm(Tform2); end; The difference between VCL and Fmx is that in Fmx you've to define TFormClass: type TFormClass = class of TForm;
  4. For VCL: TWhateverForm.Create(whoever).Show[Modal]; and in OnClose event Action := caFree; and remove every form reference like "Form1: TForm1" except the main form's which is needed. If you need to pass arguments or need results then you can add a method to the Form class like public function ShowForm(myarguments): resulttype etc.. FMX, I don't know, I'd be surprised if it would be much different.
  5. Lajos Juhász

    How to set TBytes array to the file size ?

    It guess with the edit the source was removed. HexViewSource.zip
  6. Lajos Juhász

    How to set TBytes array to the file size ?

    Here is the content (I assume by Gary Darby): HexView will display the contents of any file using hexadecimal (base 16) digits. There are 16 hexadecimal digits with values 0 through 15 but labeled "0" through "9" and "A" though "F" for convenience. Each hex digit could also be written with 4 binary bits (0000 to 1111). Hexadecimal numbers are convenient for use in displaying computer memory or files because two of those 4 bit hex digits can represent the basic unit of memory storage, the 8-bit "byte" I've had a version of this one floating around for my own use for years, but just recently realized that i had never posted it. Use of the program is self explanatory; , select a file to browse and use PgUp, PgDn keys to page through it. Ctrl+PgUp will jump to page 1, Ctrl+PgDn will jump to the last page. The "Esc" escape key will close the file. Characters which represent valid characters will be displayed on each line beside the hexadecimal data. Programmer's Notes A TFileStream control is used to access the file to be displayed. In order to avoid memory problems with large files, the amount of data (BufLen) to fill a page is calculated for each display operation based on the current size of the TMemo control. For each page, procedure ShowPage seeks to the start of the next page to be displayed (CurPage*BufLen) and reads BufLen bytes of data. Hexchars is the array containing the 16 hexadecimal character labels. The Delphi code uses a loop on N and J to convert each byte for each line into two display characters and add it to the string, Hex. N reflects the position of the current line start within the buffer and J points tpo the current character being converted. The conversion line of code looks like this: hex:=hex+hexchars[(buffer[n+j] and $F0) shr 4] + hexchars[(buffer[n+j] and $0F)]; The left hand "nibble" (4 bits of a byte) is converted by "and"ing it with hex F0 (11110000 binary) to clear out the right side nibble and then shifted right (= divided by 16) to get it back in the range 0-15 which is then used as an index into the Hexchars array. The right half of the bite is then converted similarly except that there's no need to divide by 16.HexViewSource.zip The displayed lines are added to a TStringlist (List) whose strings are assigned to the Memo1.Lines property after the page has been built. This eliminated a flicker problem that occurred when lines were built directly into Memo1. One more interesting problem that I ran into and which might save some time for you in the future. When a control is aligned to the bottom of the form (like the TStatictext control in this case), and the form is resized to a smaller height, the control is placed below any existing controls. Adjusting the sizes in the OnResize exit is too late to prevent this problem. The solution is to use the OnCanResize exit to predict where the bottom aligned control will be and readjust the size and tops of the other controls in advance of the actual resize operation..
  7. Lajos Juhász

    How to set TBytes array to the file size ?

    You can take a look at http://delphiforfun.org/programs/utilities/hexview.htm.
  8. David Heffernan

    How to set TBytes array to the file size ?

    Well you have all of the information you need in a byte array. The index into the array is the address, and the byte value at that index is your value. Job done.
  9. David Heffernan

    How to set TBytes array to the file size ?

    Then why do you try to convert to a string as if it were UTF16? You seem very confused. Well, yeah, it probably isn't UTF16 is it? It looks like you tried 10 things at random and left them all in the code you posted.
  10. Lajos Juhász

    How to set TBytes array to the file size ?

    The file doesn't contains UTF-16LE text. You should check for the encoding of the file.
  11. Lajos Juhász

    How to set TBytes array to the file size ?

    If it's a textfile you can use memo.lines.loadfromfile or read it using TFileStream. For example: var f: TFileStream; buff: TBytes; begin f:=TfileStream.Create('d:\temp\test.txt', fmOpenRead+fmShareDenyNone); try SetLength(buff, f.Size); f.ReadBuffer(buff, f.Size); memo1.lines.text:=TEncoding.ANSI.GetString(buff); finally f.Free; end; end;
  12. David Heffernan

    How to set TBytes array to the file size ?

    The size of the file is AFile.Size. You read the entire file into a byte array, but then go at the same stream with a binary reader. There are so many mistakes here. Do you want to read it into a byte array and covert to string. Or do you want to read it as binary.
  13. Remy Lebeau

    TNetHTTPRequest request_id

    For what, exactly? There is no request_id in the HTTP protocol. Perhaps you are working with a particular REST protocol instead that defines a request_id in its data, outside of HTTP?
  14. Alexander Elagin

    Opinions about Pascal vs C/C++ IDE

    I also wrote a lot of assembly code a while ago, mostly for the 8051 family. Nothing beats a good assembler code when you need to get the most from the hardware. All those fancy higher level languages make it easier to write programs, but when all you have is 8K of program memory and 256 bytes of RAM shared with bits and register banks, then the real work begins
  15. Dear visitors, We like to inform you that we are offering 35% discount on our products. Just use HOLIDAYS21 coupon code on the checkout page to get 35% off. Click here for Online Store and Prices . NextSuite includes always growing set of VCL components. Most important components are: NextGrid6 (StringGrid/ListView replacement, written from scratch). NextDBGrid6 (Db variant of the grid) NextInspector6 - An object inspector component. Next Collection 6 - A set of smaller components that are both useful and easy to use. Next Canvas Application - a drawing application that wysiwyg convert your drawings into a valid Delphi TCanvas code.   and many more.  Few screenshots:     Download big demo project from: http://www.bergsoft.net/downloads/vcl/demos/nxsuite6_demo.zip Boki (BergSoft) boki@bergsoft.net | LinkedIn Profile -- BergSoft Home Page: www.bergsoft.net Members Section: bms.bergsoft.net Articles and Tutorials: developer.bergsoft.net (Developers Network) -- BergSoft Facebook page -- Send us applications made with our components and we will submit them in news article. Link to this page will be also set on home page too.
  16. Serge_G

    TControlList - Jump to Selected

    Hi, if you read French (or if you can translate it easily) I wrote some posts, sort of "Deep Diving in TControlList" in my blog starting from this one. I am certain you will find some clues in this post
  17. Alexander Elagin

    Opinions about Pascal vs C/C++ IDE

    As for embedded controllers - yes, plain C is the best choice. The new generations of coders may prefer Rust or C++ for this, current microcontrollers are way more powerful than a two decades old desktop PCs. But one can use a custom edition of Lazarus for bare metal programming of Raspberry Pi: https://ultibo.org/
  18. Lajos Juhász

    Opinions about Pascal vs C/C++ IDE

    You mean something like this? https://blogs.embarcadero.com/start-building-apps-for-single-board-computers-with-delphi-or-c-builder-now/ I didn't watched it as it is not my thing.
  19. Between the years we offer subscription extensions for both full version and update orders. Please check the announcement on our web site.
  20. Anders Melander

    List of most popular UI components for VCL

    Makes sense then. The learning curve is ...um... spectacular 🙂
  21. Lars Fosdal

    List of most popular UI components for VCL

    I use only TMS VCL UI Pack and FastReports for VCL. The more third-party libs you use, the more dependencies you have on the next major upgrade, and the more testing you must do on the arrival of new versions of the libs. Less is more.
  22. Lajos Juhász

    TTitleBarPanel and System/Custom Buttons

    This is on Delphi 10.4.2. CustomTitleBar.zip
  23. David Heffernan

    Opinions about Pascal vs C/C++ IDE

    That's a tool chain limitation rather than language though.
×