Recent

Recent Posts

Pages: [1] 2 3 ... 10
1
LCL / Re: TTrayIcon do not work properly on Raspberry Pi OS(Raspi400)
« Last post by Thaddy on Today at 07:36:19 am »
MainformOnTaskbar is only for Windows. you don?'t need it for Raspberry Pi OS.
If everything is installed correctly it should work out of the box.
(will test later for aarch64 Pi)
As a side note: did you make sure that the OS is up-to-date?
That is important, because Wayland is a moving target and a lot of updates happen to improve compatibility with X-windows.
So:
sudo apt update && sudo apt upgrade -y

You may also add backports to the apt configuration to get even more recent updates.
So for the moment don't touch fpc and lazarus, but do upgrade the system.
Big chance that is enough.
[edit]
TTrayIcon works on one of my RPi aarch64's
2
Add 'Interfaces' to the USES section
like,

uses Interfaces;
3
General / Re: Map vs dataset
« Last post by Packs on Today at 07:03:19 am »
Map and dataset both store inside memory

Map is useful for json manipulation.

Dataset I will get filter and locate option.

4
FV/Textmode IDE / Re: Arrow keys in FV
« Last post by Thaddy on Today at 06:33:08 am »
In what terminal do you run FV? Because the only thin I can think of is that the terminal has the arrow keys ialready hooked. If I test on a plain gnome based ubuntu machine everything works.
I didn't use kde konsole for a very long time, but it may be that is the cause.
5
Many thanks to the advises. I'll review the uses of records, and search for the optimal solution.
6
LCL / TTrayIcon do not work properly on Raspberry Pi OS(Raspi400)
« Last post by atell on Today at 06:10:05 am »
Hi, All.

I'm a programming beginner living Sapporo City, Hokkaido, Japan.

Raspberry Pi 400 and Raspberry Pi OS 64bit 6.6.51+... with Lazarus 4.0RC1 and FPC 3.2.3. Revision: Unknown, aarch64-linux-gtk2. On Wayland.

My test-program of task tray icon won't activate. Please help me.

https://forum.lazarus.freepascal.org/index.php/topic,68967.msg534292.html#msg534292
https://wiki.freepascal.org/How_to_use_a_TrayIcon

Panel?..., 'ONLY gtk2 and Lazarus >= 3.0.0'? higher?

Below is my source code.

Best Regard,
Thank you.

atell.

---

(lpr)

Code: Pascal  [Select][+][-]
  1. program trayon01;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. uses
  6.   {$IFDEF UNIX}
  7.   cthreads,
  8.   {$ENDIF}
  9.   {$IFDEF HASAMIGA}
  10.   athreads,
  11.   {$ENDIF}
  12.   Interfaces, // this includes the LCL widgetset
  13.   Forms, Unit1_trayon01
  14.   {$ifdef LCLGTK2}
  15.   , unitywsctrls
  16.   {$endif}
  17.   { you can add units after this };
  18.  
  19. {$R *.res}
  20.  
  21. // ----------------------------------------------------------------------------
  22. //   This about reading the command line and env for instructions re TrayIcon
  23. //   It applies to ONLY gtk2 and Lazarus >= 3.0.0 !
  24. // ----------------------------------------------------------------------------
  25. {$ifdef LCLGTK2}
  26.  function GetUseAppInd() : UnityWSCtrls.TUseAppIndInstruction;
  27.  var
  28.     EnvVar : string;
  29.  begin
  30.  Result := UnityWSCtrls.GlobalUseAppInd;
  31.  if Application.HasOption('useappind') then begin              // Command line
  32.     if Application.GetOptionValue('useappind') = 'yes' then    // if not set, leave it alone.
  33.         Result := UseAppIndYes
  34.     else if Application.GetOptionValue('useappind') = 'no' then
  35.         Result := UseAppIndNo;                            // Anything other than yes or no is ignored
  36.  end else begin
  37.     EnvVar := Application.EnvironmentVariable['LAZUSEAPPIND'];   // EnvironmentVariable
  38.     if EnvVar = 'YES' then
  39.         Result := UseAppIndYes
  40.     else if EnvVar = 'NO' then
  41.         Result := UseAppIndNo;
  42.     end;                        // EnvVar : 0x0
  43. end;
  44. {$endif}
  45.  
  46. begin
  47.   RequireDerivedFormResource:=True;
  48.   Application.Scaled:=True;
  49.   Application.{%H-}MainFormOnTaskbar:=True;
  50.   Application.Initialize;
  51.   {$ifdef LCLGTK2 }
  52.       {$ifdef CPUi386}             // Note: unless Ayatana fix their problem, no option for Gnome users
  53.                                   // https://github.com/AyatanaIndicators/libayatana-appindicator/issues/76
  54.       UnityWSCtrls.GlobalUseAppInd := UnityWSCtrls.UseAppIndNo;     // 32bit must be a 'no'.
  55.       {$endif}
  56.       UnityWSCtrls.GlobalUseAppInd := GetUseAppInd();
  57.       //UnityWSCtrls.GlobalUseAppInd := UnityWSCtrls.UseAppIndAuto;
  58.   {$endif}
  59.   Application.CreateForm(TForm1, Form1);
  60.   Application.Run;
  61. end.
  62.  


(pas)

Code: Pascal  [Select][+][-]
  1. unit Unit1_trayon01;
  2.  
  3. interface
  4.  
  5. uses
  6.   Classes, SysUtils, Forms, Controls, Menus, ExtCtrls, Dialogs, StdCtrls;//, UnityWSCtrls;
  7.  
  8. type
  9.  
  10.   { TForm1 }
  11.  
  12.   TForm1 = class(TForm)
  13.     Button1: TButton;
  14.     MainMenu1: TMainMenu;
  15.     TrayIcon1: TTrayIcon;
  16.     PopupMenu1: TPopupMenu;
  17.     MenuItem1: TMenuItem;
  18.     procedure Button1Click(Sender: TObject);
  19.     procedure FormCreate(Sender: TObject);
  20.     procedure MenuItem1Click(Sender: TObject);
  21.   private
  22.     { private declarations }
  23.   public
  24.     { public declarations }
  25.   end;
  26.  
  27. var
  28.   Form1: TForm1;
  29.  
  30. implementation
  31.  
  32. {$R *.lfm}
  33.  
  34. procedure TForm1.FormCreate(Sender: TObject);
  35. begin
  36.   //Application.ShowMainForm := False;
  37.   //Form1.Hide;
  38. end;
  39.  
  40. procedure TForm1.Button1Click(Sender: TObject);
  41. begin
  42.   TrayIcon1.Icon := Application.Icon;
  43.   TrayIcon1.PopupMenu := PopupMenu1;
  44.   TrayIcon1.Visible := True;
  45.   TrayIcon1.Show;
  46. end;
  47.  
  48. procedure TForm1.MenuItem1Click(Sender: TObject);
  49. begin
  50.   ShowMessage('Menu item clicked!');
  51. end;
  52.  
  53. end.
  54.  


(lfm)
Code: Pascal  [Select][+][-]
  1. object Form1: TForm1
  2.   Left = 1480
  3.   Height = 300
  4.   Top = 250
  5.   Width = 500
  6.   Caption = 'Form1'
  7.   ClientHeight = 300
  8.   ClientWidth = 500
  9.   Menu = MainMenu1
  10.   LCLVersion = '4.0.0.1'
  11.   OnCreate = FormCreate
  12.   object Button1: TButton
  13.     Left = 341
  14.     Height = 25
  15.     Top = 170
  16.     Width = 75
  17.     Caption = 'Trayon!'
  18.     TabOrder = 0
  19.     OnClick = Button1Click
  20.   end
  21.   object TrayIcon1: TTrayIcon
  22.     PopUpMenu = PopupMenu1
  23.     Left = 176
  24.     Top = 152
  25.   end
  26.   object PopupMenu1: TPopupMenu
  27.     Left = 176
  28.     Top = 88
  29.     object MenuItem1: TMenuItem
  30.       Caption = 'Menu Item'
  31.       OnClick = MenuItem1Click
  32.     end
  33.   end
  34.   object MainMenu1: TMainMenu
  35.     Left = 129
  36.     Top = 232
  37.   end
  38. end
  39.  


Thanks.
7
Databases / Re: SQLite3 Date Problem
« Last post by Wesbat on Today at 05:48:50 am »
Bear in mind that SQLite uses dynamic typing. In fact defining a data type is completely optional. Unlike traditional RMDBs where the datatype is coerced to match, SQLite allows you to put any value into any column, regardless.

To wit:
Code: SQL  [Select][+][-]
  1. DROP TABLE IF EXISTS datatypes;
  2.  
  3. CREATE TABLE "datatypes" (
  4.         "a"     INTEGER,
  5.         "b"     TEXT,
  6.         "c"     DATE
  7. );
  8.  
  9. INSERT INTO datatypes VALUES (1, 'hello', '2024-12-31');
  10. INSERT INTO datatypes VALUES ('hello', 1, '31/12/2024');
  11.  
  12. SELECT * FROM datatypes
  13.  

yields:
Code: [Select]
a b c
1 hello 2024-12-31
hello 1 31/12/2024

The data type in your db schema is only a hint for the developer and/or library. The Date type is in fact not even a strict SQLite type.

For this reason I prefer to store dates as Unix timestamps. A known quantitive value that can't be misinterpreted.

Code: Pascal  [Select][+][-]
  1. SQLQuery.Params.ParamByName('created').AsInteger := DateTimeToUnix(Now);
  2. ...
  3. Result := UnixToDateTime(SQLQuery.FieldByName('completed').AsInteger)
8
[...] I was specifically pointing you at a cat() function. I'd presumed that you'd already broadly read the rest of the stuff, otherwise I've been wasting my time for the last couple of weeks

the 'magic' of the linux cat utility is (as i discovered) that it can take a wildcard at the top of a path and will search all the branches from that wildcard down to find a match. in my case, this was starting at /sys/bus/serial-base/drivers/port and searching through */tty/ttyS0/type. within /sys/bus/serial-base/drivers/port are 32 directory structures, only one of which has a branch ending in ttyS0/type (and the same for each of the other ttySxx ports). the cat utility took all the hard work out of confirming this!

but then i realized (after writing the search code) that i could just look in /sys/class/tty/ttyS0/type for the same result - provided permissions allowed.

our discussion has yielded a far better understanding of how all the symlinks are used to create the /sys/class tree, and of the complexities of stepping up and down through it. also how to create a 'normalized' version of a path that yields the top-end marker "/sys/bus/serial-base/" that (for now) is a substitute for the previous "serial8250" bottom-end marker in distinguishing between fixed and removable serial ports.

[...] I've been looking at TIOCGSERIAL etc. today, be careful if you try using it in anger since the kernel might actually overspill the data strucure by around 10 bytes

i'll add an overrun area to the end of TSerialStruct to allow for this!


cheers,
rob   :-)
9
General / Re: storing string
« Last post by Wesbat on Today at 04:51:11 am »
Here is a slightly cleaner way without resorting to StrNew()/StrDispose():

Code: Pascal  [Select][+][-]
  1. var tag: Pointer;
  2. tag := nil;
  3. string(tag) := 'yourstringhere';
  4. TButton.Tag := PtrInt(tag);

Code: Pascal  [Select][+][-]
  1. var tag: Pointer;
  2. tag := Pointer(TButton.Tag);
  3. Somestring := string(tag);
  4. ...
  5. string(tag) := '';

As someone who is still learning, I find this example very instructive into how Pointers operate. Thanks for sharing.
10
I don't have Delphi in front of me atm, however, I Think this could be a bug because it makes no sense.

Reading online docs from the other guy leads me to believe that this should only report dragging as true when the threshold is reached.

Jamie the mad man!

Pages: [1] 2 3 ... 10

TinyPortal © 2005-2018