Jump to content

Lajos Juhász

Members
  • Content Count

    1078
  • Joined

  • Last visited

  • Days Won

    15

Posts posted by Lajos Juhász


  1. 7 hours ago, Qasim Shahzad said:

    Now Please guide why this is a bad idea. It reduces a lot of code duplication and we can add Form Creation procedure in a common library.

    When you're displaying the forms this way they are useless there are no input values to the form and the form doesn't produce any result. You're destroying the instance before the calling code could read the results back.

     

    I am aware that you can initialize the form in the formcreate and write the results back in formdestroy but that is a bad design.

    • Like 1

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

     

    • Thanks 1

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

    • Thanks 1

  4. I've tested with Delphi 10.4.2

     

    1. A dirty trick would be first set the ItemIndex under the control you would like to select on the top:

     

      ControlList1.ItemIndex:=40+(ControlList1.Height div ControlList1.ItemHeight);
      ControlList1.ItemIndex:=40;
     

    2. OnItemClicked is fired when the itemIndex changes (both from code or user navigation).

     

      


  5. Did you set the required properties for CustomTitleBar? For example:

      CustomTitleBar.Control = TitleBarPanel1
      CustomTitleBar.Enabled = True
      CustomTitleBar.SystemColors = False
      CustomTitleBar.SystemButtons = False
      CustomTitleBar.BackgroundColor = clRed
      CustomTitleBar.ForegroundColor = 65793
      CustomTitleBar.InactiveBackgroundColor = clWhite
      CustomTitleBar.InactiveForegroundColor = 10066329
      CustomTitleBar.ButtonForegroundColor = 65793
      CustomTitleBar.ButtonBackgroundColor = clRed
      CustomTitleBar.ButtonHoverForegroundColor = 65793
      CustomTitleBar.ButtonHoverBackgroundColor = 16053492
      CustomTitleBar.ButtonPressedForegroundColor = 65793
      CustomTitleBar.ButtonPressedBackgroundColor = 15395562
      CustomTitleBar.ButtonInactiveForegroundColor = 10066329
      CustomTitleBar.ButtonInactiveBackgroundColor = clWhite
     


  6. 33 minutes ago, Silver Black said:

    Not only in Alexandria... I just installed the CE 10.4.2 Sidney and there are no more Bookmarks / Navigator IDE plug-ins... WTH is happening?!

    Feature Matrix:

    IDE productivity tool: Bookmarks*, which extends the IDE’s previous marking of locations in the code editor. * Available for download in the GetIt Package Manager (not for Community Edition)

     


  7. Of course for this I cannot create a test case, but it's in a real code and all references are valid:

    PPodsetnik.fQuery.Connection:=PDatabase;

     

    image.png.bc0528c4113bbbee60e9a0654c0988b6.png

     

    image.png.3b12e941bbab26a5f22074414a45c311.png

     

    Now we would expect that PPodsetnik.fQery.Connection = PDatabase:

     

    image.png.6f20c67de253ffaf4a299af150e50487.png


  8. Just now, TimCruise said:

    Yes, if you are running Intel based PC, installing MacOS as a VirtualBox VM is straight forward!

    Only on Apple hardware is legal.
    Is it illegal to run Hackintosh?
     
    According to Apple, Hackintosh computers are illegal, per the Digital Millennium Copyright Act. In addition, creating a Hackintosh computer violates Apple's end-user license agreement (EULA) for any operating system in the OS X family.
×