Jump to content

Vandrovnik

Members
  • Content Count

    583
  • Joined

  • Last visited

  • Days Won

    6

Posts posted by Vandrovnik


  1. 5 hours ago, corneliusdavid said:

    ... the only other way to get everyone to use a central program/database from various geographical locations would be to rearchitect the program as a web app...

    ....

    What about clients connected directly to central database server through a VPN?


  2. Hello,

     

    I tried to define a conditional symbol in .dpr file (before "uses"). Well, I can define it:

     {$DEFINE Test}

     

    but later in units, this symbol seems to be undefined.

    {$IFDEF Test}
     xx; // causes compiler error in .dpr, but is ignored in units.
    {$ENDIF}

     

    Is that by design (and why?!), or is that a bug? From help (The symbol is recognized for the remainder of the compilation of the current module in which the symbol is declared), I am not sure what they mean by a module: a unit, or a dll/exe?

    I defined the symbol in Project, Options, but still would like to know why it is not possible to define it in .dpr.

     


  3. I have found no official way, but created this, which seems to work (after calling JPEGNeeded):

     

    type tJpegImageClassHelper = class helper for tJpegImage
          public
           procedure SetResolution(aDpiX, aDpiY: word);
         end;
    
         tJpegDataClassHelper = class helper for tJpegData
          public
           procedure SetResolution(aDpiX, aDpiY: word);
         end;
    
    procedure tJpegImageClassHelper.SetResolution(aDpiX, aDpiY: word);
     begin
     with self do if fImage<>nil then fImage.SetResolution(aDpiX, aDpiY);
    end;
    
    procedure tJpegDataClassHelper.SetResolution(aDpiX, aDpiY: word);
     type tJpegApp0Rec = packed record // 18 B including the marker; starts on position 2 in the file
           APP0Marker: word; // 2, FF E0
           Length: word; // 2, Length of segment excluding APP0 marker
           Identifier: array[1..5] of AnsiChar; // 5, 4A 46 49 46 00 = 'JFIF' in ASCII, terminated by a null byte
           JFIFVersion: word; // 2,  First byte for major version, second byte for minor version (01 02 for 1.02)
           DensityUnits: byte; // 1, Units for the following pixel density fields; 00 : No units, 01 : Pixels per inch (2.54 cm), 02 : Pixels per centimeter
           XDensity: word; // 2, Horizontal pixel density. Must not be zero
           YDensity: word; // 2, Vertical pixel density. Must not be zero
           XThumbnail: byte; // 1, Horizontal pixel count of the following embedded RGB thumbnail. May be zero
           YThumbnail: byte; // 1, Vertical pixel count of the following embedded RGB thumbnail. May be zero
           // ThumbnailData... // 3 × n, Uncompressed 24 bit RGB (8 bits per color channel) raster thumbnail data in the order R0, G0, B0, ... Rn-1, Gn-1, Bn-1; with n = Xthumbnail × Ythumbnail
          end;
          pJpegApp0Rec = ^tJpegApp0Rec;
     var App0: pJpegApp0Rec;
     function Swap(Value: word): word;
      begin
      result := (Value shr 8) or ((Value and $FF) shl 8);
     end;
     begin
     with self do begin
      if fData = nil then exit;
      if fData.Size < 20 then exit;
      App0:=pointer(NativeUInt(fData.Memory) + 2);
      if App0^.Identifier = 'JFIF'#0 then begin
       App0^.DensityUnits := 1;
       App0^.XDensity := Swap(aDpiX);
       App0^.YDensity := Swap(aDpiY);
      end;
     end;
    end;

     


  4. For me, the only way to handle all HDPI related problems and bugs, is to use Delphi in DPI-unaware mode and keep all designed forms and frames at 96 dpi. On runtime they scale fine.

    Even then Delphi IDE 12.3 on monitor set to 150 % sometimes shows hint too small and moved to top left corner of the screen...


  5. Hello,

     

    Please is it possible to have memory manager in Delphi 12.3 to call my routine when it is unable to allocate new block of memory? My routine would release some memory (cache of bitmaps) and memory manager should try again, without raising an exception. Or is there another way of creating a cache as big as possible, but without limiting "normal" operation of the application?

    • Like 1

  6. On 3/20/2025 at 11:26 AM, MikeMon said:

    I have a problem with my application crashing on Windows XP / Windows Server 2003. It wouldn't even give any exceptions. After troubleshooting, I found out that the issue is caused by IBX. Just adding an IBX unit, e.g., IBSQL, to the uses clause of an empty application causes the crash. I'm not sure after which Delphi upgrade this started, but I think it was after upgrading to 12.1 or 12.2.

     

    Has anyone come across this? If yes, any solution or workaround? 

    We had the same problem (Windows XP as virtual machines). Did not succeed finding a solution in Delphi app, so virtual machines upgraded to Windows 7...


  7. On 3/8/2025 at 4:24 PM, mfeger said:

    How can you use SetEnvironmentVariable() function when it is designed to work on Windows platform? What function should be used for Android platform?

    {$IFDEF ANDROID}
    
    function SetEnvironmentVariable(Name:string; Value:string): boolean;
     begin
     result:=false; //assume failure
     if Value='' then begin
      // Assume user wants to remove variable.
      if unsetenv(MarshaledAstring(UTF8String(Name)))=0 then result:=true;
     end else begin
      // Non empty so set the variable
      if setenv(MarshaledAstring(UTF8String(Name)), MarshaledAstring(UTF8String(Value)), 1)=0 then result:=true;
     end;
    end;
    

     


  8. 21 minutes ago, PeaShooter_OMO said:

    One would think to look at DrawGrid.Row and DrawGrid.Col. They are set before Double-click and you can read them to get the cell where the click took place. The problem with them is when you click outside the cell range, a blank space in the grid for instance, then the last cell that was set will be given to you instead of the expected (-1,-1) coordinates. So you can look at DrawGrid.MouseToCell which will translate the mouse cursor position into the cell underneath the mouse cursor. Keep in mind MouseToCell takes Grid-relative cursor position as input. Thus you will have the cell that was underneath the cursor and now you can decide whether you wanna act or not.

     

    Thank you for your reply. I did not write, that in this grid, RowSelet is set, so in OnDblClick I get Col=0.

    So instead I used:

     var Cell: TGridCoord;
         Pt: tPoint;
     begin
     fSkipDrag:=true;
     Pt:=Mouse.CursorPos;
     Pt:=Grid.ScreenToClient(Pt);
     Cell:=Grid.MouseCoord(Pt.x, Pt.y);
     if (Cell.X<1) or (Cell.X>3) then ...
    
    

    It is not perfect - if computer is really busy / slow, mouse may move before OnDblClick is run.


  9. Hello,

     

    I have a DrawGrid, on some columns user can click to switch between values (enable / disable them). Is it possible to allow OnDblClick on some columns, while not allowing OnDblClick on these columns with "switches"? OnDblClick is used to open modal dialog to change some values.

    Thank you, kind regards,

     

    Karel

     


  10. 16 minutes ago, Brandon Staggs said:

    Interesting. I know this was a concern in the early days of SSD drives, but I've never replaced an SSD drive due to it "running out of writes."

     

    Obviously your RAM is going to be your fastest storage, but just doing a full build and letting your OS cache do its work ought to be enough. Have you actually tested the speed of both methods? I have long since quit trying to do a better job than my OS cache does on its own, especially in these days of NVME solid state drives...

    I did not make speed tests, the speed will probably be almost the same, because of large file cache and fast NVME drives.


  11. 31 minutes ago, Paul H said:

    I am totally tearing my hair out over this one. I have a largish VCL project (100+ forms and frames) and recently I have started to reegularly "lose" ALL the <FormType>dfm</FormType> tags in the drpoj file, so when I try to add a frame to a form all I get is an empty frame list.

     

    Re-adding all the FormType tags to the dproj file every week or so is a pain. Before I give up and rebuild the project from scratch, has anyone any idea what is happening with the IDE? I am using Delphi 12.2

    It did not happen to me in 12.2 (yet). In older versions, i just replaced <DesignClass>TFrame</DesignClass> with <FormType>dfm</FormType><DesignClass>TFrame</DesignClass> in .dproj file.

    T thought it was happening mostly after Delphi upgrade.


  12. On 12/11/2024 at 4:16 AM, Fudley said:

    Windows 11

    Delphi 12.1  (haven't dived into 12.2 yet)

    GExperts, CnPack, MMX are installed.

     

    Right-clicking on the toolbars and selecting "Customize" I can then arrange the toolbars and icons, add new icons etc.

    All is well until I restart Deephi, and the toolbars are not as I left them.  Some icons are missing. Some toolbars have blank spaces where the icons should be.

     

    I have tried locking the toolbars, and saving the desktop.

     

    Has anyone else run into this?

    My futile fight with toolbars in Delphi started with Delphi X?? and continues to this day. But I found a solution: I turned off all toolbars and left only the palette on top 🙂(To be honest, I did not try to enable any of toolbars in Delphi 12.2, so I am not sure that problems persist.)

    • Like 1

  13. On 11/21/2024 at 8:23 AM, Henry Olive said:

    D-10,4

    Good Day

     

    MyField = Varchar(1500)

    MyDBGrid.Width = 400

     

    Is it possible to wrap texts inside each row if my field's data longer than dbgrid field width ?

    Something like below

     

    ID    History

    1      aaaaaa

            bbbbb

            cccccc

    2      xxxxxx

     

    Thank You

     

    You can draw whatever you want in OnDrawColumnCell but AFAIK, all rows must have the same height.


  14. 30 minutes ago, dummzeuch said:

    I have actually been using this "feature" when I needed an event handler but didn't have an object ready, by declaring a local variable of a simple class type declared just for this purpose, setting it to nil (just to shut up the compiler) and assigning its method to the event. That method simply doesn't do anything that requires self to have a value, so it works fine (it also must not be virtual). No constructor/destructor calls required and also no memory leak created. 

    Alternatively one could create a plain procedure with the right signature, assign that to the code pointer of a TMethod record, leave the data pointer unassigned or set it to nil, and assign that record to the event using appropriate type casting. But that somehow feels hackier than the nil object instance.

    What about a class procedure?
     

    type tTest = class(tObject)
          public
           class procedure MyFormShow(Sender: TObject);
         end;
    ...
     self.OnShow:=tTest.MyFormShow;

     

    • Like 3
×