[Solved] Draw n random integers whose sum is equal to 100 [closed]

Using only integer numbers and Fisher-Yates shuffle: program cont3; {$APPTYPE CONSOLE} {$R *.res} uses System.SysUtils; const SummandsCount = 5; WantedSum = 100; var i, j, t, Cnt, WhereToInsert: integer; JustNaturalNumbers: array[1..WantedSum] of Integer; DividingPoints: array[0..SummandsCount] of Integer; begin Randomize; Cnt := 1; DividingPoints[0] := 0; DividingPoints[SummandsCount] := 100; for i := 1 to WantedSum – … Read more

[Solved] How to pass pointer to array of byte to function?

Because IVO GELOV did not updated his code and/or did not removed his answer, I am adding my current code, which I am using. type TBytes = array of byte; procedure Dictionary.WriteData(var Data: TBytes); begin try DataStream.Write(Data[0], sec[sid].grp[grp].META.dataLength); finally end; end; solved How to pass pointer to array of byte to function?

[Solved] Syntax error. in query expression -Delphi

Give a try; Procedure TFNewCarAct.BtnSaveClick(Sender: TObject); begin adoQueryCCA.Close(); adoQueryCCA.SQL.Clear; adoQueryCCA.SQL.Add(‘INSERT INTO tblcaractivity ([CCarID],[Date],[Millage],[SerRcd],[EOType],[EOQunt],[AirFil],[GOil])’); adoQueryCCA.SQL.Add(‘VALUES(:CCarID,:Date,:Millage,:SerRcd,:EOType,:EOQunt,:AirFil,:GOil)’); adoQueryCCA.Parameters.ParamByName(‘CCarID’).Value:= Integer(ComboBox2.Items.Objects[ComboBox2.ItemIndex]); adoQueryCCA.Parameters.ParamByName(‘Date’).Value:= Edit6.Text; adoQueryCCA.Parameters.ParamByName(‘Millage’).Value:= Edit1.Text; adoQueryCCA.Parameters.ParamByName(‘SerRcd’).Value:= memo1.Text; adoQueryCCA.Parameters.ParamByName(‘EOType’).Value:= Edit2.Text; adoQueryCCA.Parameters.ParamByName(‘EOQunt’).Value:= Edit3.Text; adoQueryCCA.Parameters.ParamByName(‘AirFil’).Value:= Edit4.Text; adoQueryCCA.Parameters.ParamByName(‘GOil’).Value:= Edit5.Text; adoQueryCCA.ExecSQL; ShowMessage(‘Done’); end; procedure TFNewCarAct.FromShow(Sender: TObject); begin ADOQueryCT.Open; while Not ADOQueryCT.Eof do begin ComboBox1.Items.Add(ADOQueryCT.FieldByName(‘Name’).AsString); ADOQueryCT.Next; end; ADOQueryCT.Close; if ComboBox1.Items.Count > 0 then ComboBox1.ItemIndex := 0; … Read more

[Solved] Why when we add an android service to an app, delphi automatically include in the dpr of the app the unit of the datamodule of the service?

Why when we add an android service to an app, delphi automatically include in the dpr of the app the unit of the datamodule of the service? solved Why when we add an android service to an app, delphi automatically include in the dpr of the app the unit of the datamodule of the service?

[Solved] I want to Thread and Form work together [closed]

Button1Click is stopping the execution of the main thread for 3 seconds. During the sleep(3000) execution, no GDI message is processed, so the dialog boxes are NOT displayed immediately. In fact, TCustomThread.doProc works as expected, but the dialog box is not displayed until the GDI messages are processed. You have to change this method e.g. … Read more

[Solved] How to change the ClientRect of a form?

type TForm1 = class(TForm) .. private procedure WmNCCalcSize(var Msg: TWMNCCalcSize); message WM_NCCALCSIZE; .. .. procedure TForm1.WmNCCalcSize(var Msg: TWMNCCalcSize); begin inherited; if Msg.CalcValidRects then begin InflateRect(Msg.CalcSize_Params.rgrc[0], -10, -6); Msg.Result := 0; end; end; Please, carefully read WM_NCCALCSIZE‘s documentation though, including the remarks section and also NCCALCSIZE_PARAMS, as I’m not sure this is what you want. But … Read more

[Solved] Loading many images and running out of memory when using NativeJpg

I don’t know for sure if this is your problem, but there is a huge design flaw with your current code. You are creating 1 thread per image. Assuming that you have hundreds or thousands of threads this design cannot scale. For a start there is a significant overhead associated with creating, starting and terminating … Read more