windows – Lazarus How to make Music Loop

I was working on a tool using Lazarus IDE which starts external batch scripts to do things (I’ve been told that I can implement those thigns in Lazarus itself but I’m sticking with Batch scripts since I can change them in the future if I need to). Some config-entries are written to a .ini-file.

For example I have two scripts for two different languages (let’s call them english.bat and german.bat). With a TButton in Lazarus it changes the entry in my .ini file and then starts a batch-file called changeLang.bat and this is where I need help.

My changeLang.bat should check the entry in my .ini-file (there is a line (line 3) which either says lang=ger or lang=eng) and start the respective script (if lang=ger start german.bat / if lang=eng start english.bat).

The only Problem I have is I’m not sure how to read the third line in my .ini-file and set the conditions for both cases.

classes – Basic Color class for both Delphi and Lazarus

Intro

If you want to know, then about 10+ years ago, I started a journey on the (best in my country) color picker for WinXP, later Win7. Since now it is hardly compatible with Win10 and HiDPI (work in progress), and in no way compilable in Linux using Lazarus, it would take quite an effort to create a decent desktop color picker with zoom and everything on Linux. But first things first – in this question I would like to start with basic color class, i.e. class capable of holding single color, and providing easy access to each color component, except for hue sat lum, which I’m not able to program, and am not asking you to point me to any direction. At the bottom I attached this code to existing color picker for windows just to show what it is doing. I want to start from scratch and maybe re-invent the wheel just to practice my brain.


TBasicColor class

unit basic_color;

interface

uses
    Graphics;

type
    TBasicColor = class
    strict private
        FColorRef: TColor;
    protected
        function GetColorRef: Integer;
        function GetRed: Byte;
        function GetGreen: Byte;
        function GetBlue: Byte;
        function GetCyan: Byte;
        function GetMagenta: Byte;
        function GetYellow: Byte;
    public
        constructor Create; reintroduce;
        constructor CreateRandom;
        constructor CreateColorUsingRGB(const ARed, AGreen, ABlue: Byte);
        constructor CreateColorUsingCMY(const ACyan, AMagenta, AYellow: Byte);
        property ColorRef: Integer read GetColorRef;
        property Red: Byte read GetRed;
        property Green: Byte read GetGreen;
        property Blue: Byte read GetBlue;
        property Cyan: Byte read GetCyan;
        property Magenta: Byte read GetMagenta;
        property Yellow: Byte read GetYellow;
    end;

implementation

constructor TBasicColor.Create;
begin
    inherited Create;
    // implicitly initialize to white color
    CreateColorUsingRGB(255, 255, 255);
end;

constructor TBasicColor.CreateRandom;
begin
    inherited Create;
    FColorRef := Random($FFFFFF + 1);
end;

constructor TBasicColor.CreateColorUsingRGB(const ARed, AGreen, ABlue: Byte);
begin
    inherited Create;
    FColorRef := ARed or (AGreen shl 8) or (ABlue shl 16);
end;

constructor TBasicColor.CreateColorUsingCMY(const ACyan, AMagenta, AYellow: Byte);
begin
    CreateColorUsingRGB(255 - ACyan, 255 - AMagenta, 255 - AYellow);
end;

function TBasicColor.GetColorRef: Integer;
begin
    Result := Integer(FColorRef);
end;

function TBasicColor.GetRed: Byte;
begin
    Result := Byte(FColorRef);
end;

function TBasicColor.GetGreen: Byte;
begin
    Result := Byte(FColorRef shr 8);
end;

function TBasicColor.GetBlue: Byte;
begin
    Result := Byte(FColorRef shr 16);
end;

function TBasicColor.GetCyan: Byte;
begin
    Result := 255 - GetRed;
end;

function TBasicColor.GetMagenta: Byte;
begin
    Result := 255 - GetGreen;
end;

function TBasicColor.GetYellow: Byte;
begin
    Result := 255 - GetBlue;
end;

end.

Screenshot from Windows

Screenshot from Windows


Whatever you answer, I value all input. Thank you.

lazarus – External error: SIGSEGV tries to access the Application.Mainform property

An error occurred while attempting to access Application.Mainform.
I have tried it in many ways.

Additional Information: I can not declare a main form of using this device because it is a generic function and the main shape may be different in another application module.

The mistake that happens:

The project support has the exception class & # 39; External: SIGSEGV & # 39; triggered. In the archive
# Include / control.inc & # 39; in line 3501

The only way it worked was the Screen Class forms:

For i:= 0 to Screen.FormCount -1 do
         if ( pos( 'mainform', lowercase( Screen.Forms(i).Name ) ) > 0 ) then
            ( ( Screen.Forms(i) as TForm ).FindComponent( 'sbMensagem' ) as TStatusBar ).Panels(0).text:= cMensagem;

The build environment is Linux and all other functions seem to be ok. I do not know the cause.

Lazarus + Zeos DBgrid displays the AUTO_INCREMENT field without information after inserting a record

I have a database in MariaDB and an application in LAZARUS that uses the ZEOS component, which is my problem: When I use the components Zcontection + Zquery + DataSource + Dbgrid, it updates the base and data after inserting a new record get them updated with o like AUTO_INCREMENT in GRID, but if I use Zcontection + Zquery + ZUPDATESQL DataSource + Dbgrid updates the base and the data after adding a new record Do not bring or if AUTO_INCREMENT in GRID has been updated, the grid will be left with one column in white.

Thanks in advance for your help.