Jump to content

JonRobertson

Members
  • Content Count

    171
  • Joined

  • Last visited

  • Days Won

    3

Posts posted by JonRobertson


  1. I have not heard of VTK and decided to take a peak. The documentation references examples using MFC and C++ Builder. However, the Win32 folder is no longer present in the Examples\GUI folder in their git repo. Searching the history of the repo, the C++ Builder examples were removed five years ago. I suspect getting support for using VTK in Delphi will be challenging, since the group stopped supporting C++ Builder years ago. That said, the old code is available via git history. For example, vtkBorlandRenderWindow.cpp. This snippet is from GetRenderWindow:

     

        // Stuff the renderwindow into our window
        FRenderWindow = vtkWin32OpenGLRenderWindow::New();
        FRenderWindow->AddObserver( vtkCommand::AbortCheckEvent, FAbortCallback);
        FRenderWindow->SetParentId(Parent->Handle);

    Without a deep dive into the source, it appears VTK is using OpenGL for rendering and setting the OpenGL's window parent to a form.

     

    If I wanted to use VTK from Delphi, I would attempt:

    1. Use a supported open source C++ compiler to build the C++ source to either OBJ or LIB. There are multiple OBJ file formats. Delphi can link with OMF86 or COFF for 32-bit and ELF or COFF for 64-bit. See Link object file (Delphi) for more details.
    2. Translate the VTK headers to Pascal, which will be a challenge. From what little I have read, VTK appears to use features only available in newer versions of C++. There are some open source projects for converting headers, although they may not be able to convert the VTK headers. The second one specifically does not convert C++ headers. I included it because it uses libclang, which I suspect would provide a better translation for the "pure C" portions of headers.
      1. https://github.com/yunkot/HeaderParser
      2. https://github.com/neslib/Chet
      3. There are others. Search engines are your friends. ;) Well, most of the time.
    3. Another alternative is Python4Delphi, since VTK can be used from Python and appears to actively support use from Python. An advantage of this approach is the ability to "prototype" using standalone Python and then incorporate into a Delphi app via Python4Delphi. You have likely seen Pyscripter's posts in this forum.
      1. https://github.com/pyscripter/python4delphi

  2. 52 minutes ago, PeterPanettone said:

    This shortcoming has given Delphi the unjustified reputation of being an unprofessional amateur developer tool.

    I have heard or read many "justifications" for dismissing Delphi, but never that one.

     

    That said, DevExpress does have excellent components. I currently do not have the privilege of a license for any. Thank you for pointing out TdxLayoutControl , along with the video. I need to spend a little time to put together a proposal, I suppose, for my managers. :classic_smile:


  3. On 2/29/2024 at 1:18 PM, Jeff Steinkamp said:

    Can someone point me in the direction to help me devise a quick and easy way to send the data I have in a DBGrid to a printed output.   I do have a couple of PDF components that should do this, PowerPDF and Winsodt's TPDF, but I am unbale to find much in the way of basic documentations for either of these components.

    I found FortesReport Community Edition on GitHub. The only documentation that I saw is in the source code and is in Portuguese. 

     

    Or you could roll-your-own. There is some example code in this StackOverflow answer: https://stackoverflow.com/questions/7496813/print-a-tdbgrid/7500147#7500147


  4. 1 hour ago, EugeneK said:

    if you change query compiler will tell you about errors in dependent code

    If you are referring to persistent fields added via the Field Editor IDE window, the compiler will only complain if you update the field list after you update a query. If the query is changed and no longer returns one of the persistent fields, or returns a different data type for a persistent field, the code will still compile. Those "errors in dependent code" will not occur until run-time.


  5. On 2/29/2024 at 3:08 AM, dormky said:

    I honestly have no idea what I'm supposed to do here ? Looking at other fields in that table, they all look the exact same. They all exist in the exact same places (in the dfm file and the code).

    The error "42S22 Unknown column" is not coming from the Delphi compiler, MyDAC, or the underlying TDataSet. It is coming from MySQL. From an online search, the error means that the field specified (FILEVERSION) in the field list of the SQL statement is not a column in the table.

     

    https://sebhastian.com/mysql-unknown-column-field-list/

    When you call MyTable.Open, MyDAC is generating a SELECT statement based on the fields that you have added to your MyTable component. That SELECT statement has FILEVERSION in its field list. When executed by MySQL, the unknown column error occurs.

     

    I don't know if the following will work with TMyTable, but it might since TMyTable has TDataSet as an ancestor.

    1. Drop another TMyTable component on the form or datamodule.
    2. Set its properties to the same connection, database, and table as your current TMyTable component.
    3. Double-click on the new TMyTable component.
    4. If a fields window appears, right-click it and select Add Fields (or press Ctrl-A).
    5. When the Add Fields dialog appears, is FILEVERSION in the list?

    Using the debugger, ShowMessage, or logging, verify at run-time that the Connection and Database properties on your MyTable component are set to the expected values.


  6. On 2/29/2024 at 5:59 AM, Hrushikesh Shet said:

    However, when we try to export it for the second consecutive time, the file is not generated. If we restart the application then the report is generated and exported only for the first time instance.

    Is the report's pipeline a TppDBPipeline? If so, add a BeforePrint event handler to the TppReport component. In the event handler, call Dataset.First on the master/primary dataset used by the report. I do not have 22.04 available to test whether that is an issue. With 22.03, the dataset is Eof after the report is exported and attempting to generate or export the same report a second time results in an empty report.

     

    On 2/29/2024 at 5:59 AM, Hrushikesh Shet said:

    When we tried to debug this behavior we came to know that we were getting an access violation error in the RequestPage procedure inside that generate method of ppEngine.pas file. This error comes up when we execute the line CustomReport.PrintReport.

    I would expect you would have seen some dialog informing you of an Access Violation before you tried to debug, unless there is code in your unit that is "eating" exceptions (an empty except/end block).

     

    Looking at RequestPage in 22.03, my first thought is that a pipeline, datasource, or dataset is being destroyed before the TppReport component is destroyed. In the unit containing the line CustomReport.PrintReport, is there any code that calls Free to destroy an object?


  7. 4 hours ago, JonRobertson said:

    Open PReport.pas and add PDFFonts to its uses clause. I'd suggest after PdfImages:

    
      PdfImages,
      PdfFonts
      {$IFDEF USE_JPFONTS}

    Close PReport.pas. Open the DelphiPowerPDF group project and do Build All. If you don't have the group project, build PowerPDFDR followed by PowerPDFDD. (Building PowerPDFDD should not be required, but I always build run-time followed by design-time when rebuilding packages.)

     

    Now go back to your project and see if you can add a TPrPage without getting the exception.

     

    2 hours ago, JGMS said:

    But, bad luck indeed: the error remains after rebuilding and restarting D12.

    I installed PowerPDF in Delphi 12 from GetIt Package Manager. Delphi 12 locked up on me due to LSP not responding. I killed that, Delphi 12 closed, and I went to try again.

     

    When I opened Delphi 12 again, the PowerPDF components were installed (despite the earlier lockup). I dropped a PReport on a form, followed by a PRPage, and the IDE showed the same "Class Arial not found" message that you have.

     

    I opened PowerPDFDR.dproj, opened PReport.pas from the Project Manager, and added PdfFonts to the uses clause (as suggested above). "Build" PowerPDFDR,dproj, "Build" PowerPDFDD.dproj, "Install" PowerPDFDD.

     

    I am now able to drop a PRPage on a form without error.


  8. I am not sure what you are comparing. PDFFonts.pas on github does not have different versions of the source units by Delphi version. There is only one PDFFonts.pas.

     

    SysUtils not being in the uses clause of PDFFonts.pas would not cause the issue that you are seeing. If SysUtils is needed by PDFFonts, a compile error would occur when building the component package or compiling any unit that references PDFFonts.


    It is also possible that SysUtils was moved from the interface uses clause to implementation, or vice-versa.


  9. Open PReport.pas and add PDFFonts to its uses clause. I'd suggest after PdfImages:

      PdfImages,
      PdfFonts
      {$IFDEF USE_JPFONTS}

    Close PReport.pas. Open the DelphiPowerPDF group project and do Build All. If you don't have the group project, build PowerPDFDR followed by PowerPDFDD. (Building PowerPDFDD should not be required, but I always build run-time followed by design-time when rebuilding packages.)

     

    Now go back to your project and see if you can add a TPrPage without getting the exception.


  10. 5 minutes ago, JonRobertson said:

    My guess is the design-time support in PowerPDF is lacking and that the unit PdfFonts is not added to the uses clause when you drop a TPrReport on it. (I do not have PowerPDF installed to test.)

     

    If PdfFonts is not in your uses clause, add it and then try adding/dropping a TPrPage on the form.

    Actually, that would only solve a run-time exception. If the exception is occurring in the designer, then the code that registers the components in the IDE is not registering the PDF font classes.


  11. 1 hour ago, JGMS said:

    Arial is a standard font and cannot be removed nor reinstalled. Moreover, it is not missing.

    Hence it does not seem to be a Windows 11 issue, but rather something wrong in PowerPDF.

    Windows fonts are not represented as individual classes in the Delphi VCL. This error is occurring because PowerPDF is trying to create an Arial class implemented by PowerPDF. The actual class name is TPdfArial. It is registered in PdfFonts.pas.

     

    On 2/21/2024 at 4:37 PM, JGMS said:

    Anyway, it looks like the installation was a success: all controls are in place, and I can drop a TPrReport component on a form.

    However, the next step, i.e. to drop a TPrPage, fails, showing the "Class Arial not found" message.

    My guess is the design-time support in PowerPDF is lacking and that the unit PdfFonts is not added to the uses clause when you drop a TPrReport on it. (I do not have PowerPDF installed to test.)

     

    If PdfFonts is not in your uses clause, add it and then try adding/dropping a TPrPage on the form.


  12. 8 hours ago, gwideman said:

    So does this apparatus expect us to first set the Graphic property to the desired type of TGraphic, and then perform operations like LoadFromFile?  The description makes it sound like this causes LoadFromFile to convert from the file's type of image data to the type of image data you've preset in Graphic.

    The Graphic property does not represent the "type of graphic". Think of it more as a helper class that is capable of loading multiple graphic formats. The only "conversion" is unpacking the image file format, such as color depth, color map or palette, compression, etc, to a Windows Bitmap GDI object. Once an image is loaded, SaveToFile or SaveToStream may be used to write the image to a different format.

     

    8 hours ago, gwideman said:

    Or is it OK starting with nothing set for Graphic, and then just calling LoadFromFile creates the object that Graphic points to, of a type that matches the input image data? 

    Yes. If you look at the source for TPicture.LoadFromFile, you will see that it internally uses TGraphic to load an image. Looking at the source code is an excellent way to find answers, particularly if the documentation seems lacking or confusing.

     

    3 hours ago, Lajos Juhász said:
    8 hours ago, gwideman said:

    And are the Bitmap, Icon, Metafile, and WICImage properties pointers to separate actual objects? Or are they just more-specifically typed pointers to the same object that Graphic points to (ie: at most one would be valid).  What happens if the graphic type is not one of the default ones, as with TPNGImage and TJPEGImage?

    They are used the same way. Depending on the file type you have loaded the required object is created.

    To expand a little, loading an image only creates one instance of a graphic class. Bitmaps, icons, metafiles, and WIC images are not the same type of image. Try loading a TImage with a PNG (Image1.Picture.LoadFromFile('image.png')) and using the Icon property to save it as an icon (Image1.Picture.Icon.SaveToFile('image.ico')). The exception "Icon image is not valid" will be raised. However, using Picture.SaveToFile('image1.ico') does work, at least in the test that I did.

     

    8 hours ago, gwideman said:

    Thanks for any further clues on how to work with this apparatus rather than against it, or via random flounder :-)

    Random flounder is an excellent way to learn. Create a new VCL project, throw a TImage on the form, and try various things to see what works and what doesn't. Take some time to look at the underlying source code. Start with Vcl.Graphics.pas for the foundation, then look at the Vcl.Imaging units, such as GIFImg.pas, JPEG.pas, and PNGImage.pas.

     

    That is what I did while writing this message. :classic_wink:


  13. Once you add pngimage to the uses clause of any unit, the TPNGImage class is registered with TPicture, which enables your application to load and save PNG images. This is done in the initialization section of pngimage.pas (TPicture.RegisterFileFormat('PNG', 'Portable Network Graphics', TPngImage);).

     

    This provides PNG support to any class that uses TPicture to load or save impages, for example: TImage.Picture.LoadFromFile.

     

    If you want more control over the image itself, then declare and use an instance of TPNGImage and the provided methods and properties to load, save, or modify the PNG image as desired.

    • Like 1

  14. I found a demo project at https://github.com/Walibeiro/DockDemo. And a 9 page article that Brian Long wrote, titled Drag & Dock, published in issue 63 (November 2000) of The Delphi Magazine.

     

    I did not find anything more recent. I don't recall any significant changes to docking in the Delphi VCL. It has also been 9 years since I worked on an application with dockable forms.


  15. 8 hours ago, Uwe Raabe said:

    You have already been told:

    10 hours ago, Vandrovnik said:

    In forward declaration of a class, compiler immediatelly knows the size of that type. For records, their size would be unknown in forward declaration.

     

    The Delphi compiler is also a single pass compiler, unlike C/C++. Being a single pass compiler is one of the reasons that Delphi builds projects much faster than a similar C++ project.

     

    I would expect changing Delphi to support multi-pass compiling would be a huge task with few benefits. But I don't know much about writing a compiler. :classic_wink:

    • Like 2

  16. 6 minutes ago, JOE-IFS said:

    This delete clue makes sense why I can't build by exe because it's having a problem deleting the existing exe before creating the new one.

    You could try a pre-build event as a workaround:

    CMD /C DEL $(OUTPUTFILENAME)

    If your output path or filename has spaces, try 

    CMD /C DEL "$(OUTPUTFILENAME)"

     

    • Thanks 1

  17. 7 minutes ago, PeterPanettone said:

    How do you set DPI Unaware mode?

    You don't "set" it. You launch it. Click the Windows Start Button and either expand the Embarcadero Delphi group, or type "Delphi" or "DPI" or "Unaware". One of those should reveal an icon for Delphi (DPI Unaware).

     

    If you launch BDS.exe by another method, add /highdpi:unaware as a command-line parameter.


  18.  

    8 minutes ago, dummzeuch said:
    1 hour ago, PeterPanettone said:

    Low-quality AI answers often are the result of poor prompts.

     

    I recently came across a company online developing AI "clones", and decided to ask an "Abraham Lincoln clone" the question "Why do you believe you were assassinated?" After giving a three or four paragraph response that I would expect from documented history, the AI then asked me what circumstances led to my assassination.

     

    That isn't artificial intelligence. That is a complete lack of intelligence. :classic_rolleyes: 


  19. 1 hour ago, Lars Fosdal said:

    the problem is that once you use the DPI aware IDE, the measurements and coordinates in forms are according to your current Windows DPI and scaling settings

    Yep, I fought that headache even as a solo developer on a project. My dev machine is a laptop. The laptop's display has a different recommended scaling than the monitors attached to my docking station at the office. I would get so frustrated during commits because I only commit intentional or needed changes. I do not want commits littered with changes to Left/Top/etc due to the form designer running at a different scale/dpi.

     

    All of that headache thankfully went away after I discovered DPI Unaware mode.


  20. 1 hour ago, Lars Fosdal said:

    Make HighDPI actually works as intended - it is useless in a team as is - unless everyone runs the same scaling

    Genuine question on HighDPI. So far, working in DPI Unaware mode works well for me. As long as the run-time handles scaling "correctly". Since switching to DPI Unaware mode, I have not needed to write (or borrow) workarounds for HighDPI issues.

     

    Are there scenarios where designing in HighDPI would be beneficial? Just to improve the development experience or to improve the user's experience when using the produced app?

×