Recent

Recent Posts

Pages: [1] 2 3 ... 10
1
General / Re: How to: create DLL file for Windows 10 64-Bit Pro
« Last post by paule32 on Today at 09:27:34 am »
Hello  ;D

I did a 1:1 copy of @KodeZwerg's test case.
Under Microsoft Windows 11 64-Bit Professional, I get a crash, after the MessageBox at Line:
https://github.com/paule32/Qt_FPC/blob/main/src/tests/fpc_rtl.pas#L70

is reached.
So, something happends - but what ?
2
General / Re: Assign (textfile) not compiling - sometimes.
« Last post by dsiders on Today at 08:51:13 am »
Or use AssignFile and CloseFile procedures from the SysUtils.

Curiously, I don't see those indexed in the RTL documentation.

MarkMLl

None of the procedure or functions in objpas.pp are indexed or generated in the documentation. Probably because they're wrapped with $ifdefs that weren't defined when the docs were built. My guess.

[Edit]
And I just checked... they are present in the FPDoc xml file.
3
General / Re: Text orientation in TMemo?
« Last post by CM630 on Today at 08:41:53 am »
I reproduced it and found a solution that solves the dragging issue, it does not seem to affect the AxisClick behaviour.
A sample code is attached, with the same code, as shown below.
It is as you proposed. If ctMainAxisClick.Toolset:=ctMain; is before ctMainDataPointDrag.Toolset:=ctMain; I cannot drag,
but when I reversed the order of these two lines, I can drag.
But if you run the app, you might also notice, that Label2 changes its caption when clicking/dragging on places which are too far from the axises. Maybe this behaviour is not okay?

Code: Pascal  [Select][+][-]
  1.  
  2.   Chart1.Toolset := ctMain;
  3.   ctMainAxisClick.Toolset:=ctMain;
  4.   ctMainDataPointDrag.Toolset:=ctMain;  
  5.  




The full code of the snippet:
Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3.  
  4. {$mode objfpc}{$H+}
  5.  
  6.  
  7. interface
  8.  
  9.  
  10. uses
  11.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, TAGraph,
  12.   TATools, TASeries, TADrawUtils, TACustomSeries, Types, TAChartAxis, TASources, TACustomSource,TAChartUtils;
  13.  
  14.  
  15. type
  16.  
  17.  
  18.   TFloatPoint = Record
  19.     X: Double;
  20.     Y: Double;
  21.   end;
  22.  
  23.  
  24.   TFloatPointArray = array of TFloatPoint;
  25.   { TForm1 }
  26.  
  27.  
  28.   TForm1 = class(TForm)
  29.     Chart1: TChart;
  30.     Chart1LineSeries1: TLineSeries;
  31.     Label1: TLabel;
  32.     Label2: TLabel;
  33.     Label3: TLabel;
  34.  
  35.  
  36.     ctMain: TChartToolset;
  37.     ctMainDataPointDrag: TDataPointDragTool;
  38.     ctMainAxisClick: TAxisClickTool;
  39.     procedure ctMainAxisClickToolOnClick(ASender: TChartTool; Axis: TChartAxis; AHitInfo: TChartAxisHitTests);
  40.     procedure ctMainDataPointDragAfterMouseMove(ATool: TChartTool; APoint: TPoint);
  41.     procedure ctMainDataPointDragTool1DragStart(ASender: TDataPointDragTool; var AGraphPoint: TDoublePoint);
  42.     procedure FormCreate(Sender: TObject);
  43.   private
  44.  
  45.  
  46.   public
  47.  
  48.  
  49.   end;
  50.  
  51.  
  52. var
  53.   Form1: TForm1;
  54.  
  55.  
  56. implementation
  57.  
  58.  
  59. {$R *.lfm}
  60.  
  61.  
  62. { TForm1 }
  63.  
  64.  
  65. function GenSin (Frequency: Extended; Amplitude: Extended; SamPerSec:single; Offset: Extended=0; Duration: integer= 1000;PhaseShift:single=0): TFloatPointArray;
  66. var
  67.   i: integer;
  68.   SampleCount: integer;
  69.   dt: double;
  70.   debY: double;
  71. begin
  72.   SampleCount:=trunc(SamPerSec*Duration/1000)+1;
  73.   SetLength(Result,SampleCount);
  74.   dt:=1/SamPerSec;
  75.   for i:= 0 to SampleCount-1 do
  76.   begin
  77.     Result[i].X:=i/SamPerSec ;
  78.     debY:=sin(i*2*pi*Frequency/SamPerSec+(PhaseShift*2*pi/360))*Amplitude+Offset;
  79.     Result[i].Y:=sin(i*2*pi*Frequency/SamPerSec+(PhaseShift*2*pi/360))*Amplitude+Offset;
  80.   end;
  81. end;
  82.  
  83.  
  84. procedure TForm1.FormCreate(Sender: TObject);
  85. var
  86.   LSeriesArray: array of TLineSeries;
  87.   i: integer;
  88.   sin1: TFloatPointArray;
  89. begin
  90.   ctMain:=TChartToolset.Create (Chart1);
  91.  
  92.  
  93.   ctMainAxisClick := TAxisClickTool.Create(ctMain);
  94.   ctMainAxisClick.Shift := [ssLeft];
  95.   ctMainAxisClick.Enabled := True;
  96.   ctMainAxisClick.OnClick := @ctMainAxisClickToolOnCLick;
  97.  
  98.  
  99.   ctMainDataPointDrag:=TDataPointDragTool.Create(ctMain);
  100.   ctMainDataPointDrag.Shift:=[ssLeft];
  101.   ctMainDataPointDrag.Enabled:=True;
  102.   ctMainDataPointDrag.OnDragStart := @ctMainDataPointDragTool1DragStart;
  103.   ctMainDataPointDrag.OnAfterMouseMove:=@ctMainDataPointDragAfterMouseMove;
  104.  
  105.  
  106.   Chart1.Toolset := ctMain;
  107.   ctMainAxisClick.Toolset:=ctMain;
  108.   ctMainDataPointDrag.Toolset:=ctMain;
  109.  
  110.  
  111.   sin1 := GenSin(50,5,1000,0,1000);
  112.   for i:=0 to Length(sin1) do
  113.     Chart1LineSeries1.AddXY(sin1[i].x,sin1[i].y);
  114.  
  115.  
  116.   SetLength (LSeriesArray ,10);
  117.   for i:=0 to 9 do
  118.   begin
  119.     LSeriesArray[i] := TLineSeries.Create(self);
  120.     Chart1.AddSeries(LSeriesArray[i]);
  121.     LSeriesArray[i].Pointer.Visible := true;
  122.     LSeriesArray[i].AddXY(i/10,i);
  123.   end;
  124. end;
  125.  
  126.  
  127. procedure TForm1.ctMainDataPointDragAfterMouseMove(ATool: TChartTool; APoint: TPoint);
  128. begin
  129.   if ctMainDataPointDrag.Series = nil then Label3.Caption := 'nil' else Label3.Caption := IntToStr( ctMainDataPointDrag.Series.Index);
  130.   Label1.Caption := {ChartToolset1DataPointDragTool1.Series.Name + '; ' +}  IntToStr(APoint.X) + '; ' + IntToStr(APoint.y)  ;
  131. end;
  132.  
  133.  
  134. procedure TForm1.ctMainAxisClickToolOnCLick(ASender: TChartTool; Axis: TChartAxis; AHitInfo: TChartAxisHitTests);
  135. begin
  136.   Label2.Caption := Axis.DisplayName;
  137. end;
  138.  
  139.  
  140. procedure TForm1.ctMainDataPointDragTool1DragStart(ASender: TDataPointDragTool; var AGraphPoint: TDoublePoint);
  141. begin
  142.   if ctMainDataPointDrag.Series = nil then exit; //Checks if a dot is dragger, to prevent crashing
  143.   if ctMainDataPointDrag.Series = Chart1LineSeries1 then       ASender.Handled;; //Prevent dragging the main curve
  144. end;
  145.  
  146.  
  147. end.
4
General / Re: Linux Workspaces -- StayOnTop?
« Last post by AmatCoder on Today at 08:21:27 am »
Quote
Hi, I need an app to stay visible on all workspaces.

Wayland  ->  You (as developer) can't force that.
X11  ->  You can force it but ultimately it depends on Window Manager (normally it works).

Quote
I know it is possible as the Linux App, "sticky" (yellow notes) does it.

GTK has a function for that (only works on X11): https://developer-old.gnome.org/gtk2/stable/GtkWindow.html#gtk-window-stick

As far as I remember, Qt has nothing similar.
5
General / Re: Assign (textfile) not compiling - sometimes.
« Last post by MarkMLl on Today at 08:18:31 am »
Or use AssignFile and CloseFile procedures from the SysUtils.

Curiously, I don't see those indexed in the RTL documentation.

MarkMLl
6
Graphics / Re: Demoscene The Champs Cracktro
« Last post by Lulu on Today at 08:15:12 am »
Well done!
This remember me the circuits Copper, Blitter in the Amiga500! (may be other ? I forgot)
7
General / Re: Linux Workspaces -- StayOnTop?
« Last post by MarkMLl on Today at 08:12:09 am »
And it works in any windowed environment? Or maybe only in GNOME and KDE? I'm asking because Linux doesn't have a standard DE. Each of them works "in its own way".

I think it would be worth replacing "Linux" with "unix" there, and the situation with a Window Manager which might- or might not- be distinct from the overall desktop environment is highly variable.

In fact I believe that the whole idea of having multiple desktops is basically an MS Windows one, where originally they were implemented using the Windowstations layer which was added mainly to support Windows NT Terminal Server but then repurposed.

While unix introduced that sort of functionality with e.g. the fvwm Window Manager, X11 doesn't have an equivalent layer and so I believe has to emulate it by minimising/hiding and restoring each window. That makes "keep on top" etc. highly sensitive to hidden implementation details.

MarkMLl
8
Databases / Re: Azure sql database will not connect
« Last post by paweld on Today at 07:24:47 am »
Hi,
You need to install the previous version of msoledb: https://www.microsoft.com/en-us/download/details.aspx?id=56730
I misled a bit earlier, because the bitness of the driver is supposed to match the bitness of the operating system and not the application.
9
General / Re: Assign (textfile) not compiling - sometimes.
« Last post by bytebites on Today at 07:12:17 am »
Or use AssignFile and CloseFile procedures from the SysUtils.
10
Beginners / Re: Find child controls by name
« Last post by Handoko on Today at 04:17:05 am »
Done.

This demo below shows how to use FindChildControl as suggested by Josh and writing yourself a function for checking the existance of the control:

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Dialogs, StdCtrls, ExtCtrls;
  9.  
  10. type
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15.     btnFind: TButton;
  16.     Button1: TButton;
  17.     CheckBox1: TCheckBox;
  18.     Edit1: TEdit;
  19.     lbeName: TLabeledEdit;
  20.     Memo1: TMemo;
  21.     Panel1: TPanel;
  22.     RadioButton1: TRadioButton;
  23.     Shape1: TShape;
  24.     procedure btnFindClick(Sender: TObject);
  25.   end;
  26.  
  27. var
  28.   Form1: TForm1;
  29.  
  30. implementation
  31.  
  32. function HasControl(Container: TWinControl; const aName: string): Boolean;
  33. var
  34.   S: string;
  35.   i: Integer;
  36. begin
  37.   Result := False;
  38.   S := aName.ToUpper;
  39.   for i := 0 to Container.ControlCount-1 do
  40.   begin
  41.     if S = Container.Controls[i].Name.ToUpper then
  42.     begin
  43.       Result := True;
  44.       Exit;
  45.     end;
  46.   end;
  47. end;
  48.  
  49. {$R *.lfm}
  50.  
  51. { TForm1 }
  52.  
  53. procedure TForm1.btnFindClick(Sender: TObject);
  54. var
  55.   C: TControl;
  56.   S: string;
  57. begin
  58.   case HasControl(Panel1, lbeName.Text) of
  59.     True:
  60.       begin
  61.         C := Panel1.FindChildControl(lbeName.Text);
  62.         S := lbeName.Text + ' is found in Panel1.' + LineEnding +
  63.              'Class: ' +  C.ClassName              + LineEnding +
  64.              'Left: ' +   C.Left.ToString          + LineEnding +
  65.              'Top: ' +    C.Top.ToString           + LineEnding +
  66.              'Width: ' +  C.Width.ToString         + LineEnding +
  67.              'Height: ' + C.Height.ToString        + LineEnding;
  68.         ShowMessage(S);
  69.       end;
  70.     False:
  71.       ShowMessage(lbeName.Text + ' cannot be found in Panel1.');
  72.   end;
  73. end;
  74.  
  75. end.
Pages: [1] 2 3 ... 10

TinyPortal © 2005-2018