Author Topic: Using a TShape as a [Button] - any 'Issues' ? + sub-form access  (Read 2632 times)

paweld

  • Hero Member
  • *****
  • Posts: 1796
Re: Using a TShape as a [Button] - any 'Issues' ? + sub-form access
« Reply #75 on: September 13, 2026, 05:55:59 pm »
@J-G but there are no source files there; there's just an .exe file and a compressed .exe file (in a ZIP archive)
Best regards / Pozdrawiam
paweld

J-G

  • Hero Member
  • *****
  • Posts: 1375
Re: Using a TShape as a [Button] - any 'Issues' ? + sub-form access
« Reply #76 on: September 13, 2026, 06:07:09 pm »
@J-G but there are no source files there; there's just an .exe file and a compressed .exe file (in a ZIP archive)
D'Oh!  -  There is now  :-[

In haste, I moved an old .Zip file from the main folder rather than the real one form the [Published] folder  %)

I should have mentioned that there is a lot of redundant code which will ultimately be stripped out - specifically as I've reverted to TLabels rather than TBCImageButtons.
FPC 3.0.0 - Lazarus 1.6 &
FPC 3.2.2  - Lazarus 2.2.0 
Win 7 Ult 64

dseligo

  • Hero Member
  • *****
  • Posts: 1707
Re: Using a TShape as a [Button] - any 'Issues' ? + sub-form access
« Reply #77 on: September 13, 2026, 07:51:13 pm »
I found range check error: in main.pas, procedure CreateBlankRecords, at line 463 you have:
Code: Pascal  [Select][+][-]
  1.       for I := 0 to 15 do
  2.         Issue[I] := blank;

Yet, 'Issue' is declared as:
Code: Pascal  [Select][+][-]
  1. Issue      : Array[0..14] of RefStr;  // 135

How do you get beep? I mean, what exact action do you perform to get it?

P.S.: I also had to comment line 953 in main.pas because of error: main.pas(953,7) Error: Identifier not found "FormClose":
Code: Pascal  [Select][+][-]
  1.       FormClose(self,Arg);

dseligo

  • Hero Member
  • *****
  • Posts: 1707
Re: Using a TShape as a [Button] - any 'Issues' ? + sub-form access
« Reply #78 on: September 13, 2026, 08:31:03 pm »
I played a little with your project and managed to get beep.

I clicked 'Add person', then typed '*' in 'Family Name (at Birth)'. That opened 'Selector' form. When I click one of two names that appear there, beep is heard.

That beep is from line 776 in p_page.pas: in method F_NameExit you call Alert procedure.

Other place you call Alert is in line 1497 in p_page.pas (procedure ShowMemoWarning).

J-G

  • Hero Member
  • *****
  • Posts: 1375
Re: Using a TShape as a [Button] - any 'Issues' ? + sub-form access
« Reply #79 on: September 13, 2026, 10:19:24 pm »
Great @dseligo thanks  - A fresh pair of eyes on anything will surely find errors  :D

. . .  and I'm well pleased that you could compile it - in the past, when I've posted code, even including my 'Units', there have been problems.

As far as the 'Beep' is concerned,  I really ought to have set a breakpoint on my [Alert] Proc  -  that would have found the issue I'm sure.

The error is that the test that takes place to determine if there is a problem that the user should be made aware of (Beep!) can NEVER be true  :o  The Ref is created from the name in Upper Case with a number added which can never be the same as the Name which is (at best) just capitalised.

I've changed that test to :
Code: Pascal  [Select][+][-]
  1.       S1 := UpCase(Copy(F_Name.Caption,1,4));
  2.       S2 := Copy(Person.Ref,1,4);
  3.       If S1<>S2 then
  4.         begin
  5.           Alert;
  6.  

NO BEEP !

It only compares the first four characters so is not really robust  -  I'll be looking at how I can improve it - for now it's OK.

Cannot fathom how I set the Array bounds mis-match either - in fact I'd considered that there will never be more than 12 'Issue' so I've now set both to [0..12] (I know that's potentially 13  %) -  but it will only come into effect when I start coding the [Family] Form.  -  They are at least now in agreement.

I've also now turned on Range Checking (I think?) 
Project.Options.Debugging - Checks and assertion ✔️ Range (-Cr)

The FormClose Event had been created - but was blank - I know I'll need it but haven't got around to putting any checks in there.  It was at the bottom of the code, now moved to the first Proc after the Vars in the Implimentation section but I can't understand how/why it didn't cause me trouble.
FPC 3.0.0 - Lazarus 1.6 &
FPC 3.2.2  - Lazarus 2.2.0 
Win 7 Ult 64

J-G

  • Hero Member
  • *****
  • Posts: 1375
Re: Using a TShape as a [Button] - any 'Issues' ? + sub-form access
« Reply #80 on: October 07, 2026, 02:14:51 pm »
I'm now having to re-visit this issue as I cannot fathom what I'm doing wrong to cause a non-compile.  :(

The list of 'potential' matches has now grown to be longer than the list that can be displayed at any one time (I knew it would!)  -  I therefore need to select which 'potential matches' to show. To this end I now have an array with name & record number - gleaned from a search - and that list can be as long as necessary. Showing the first 13 are no problem of course but then I have a [Next] button via which I can work out a new 'start' and 'finish' - that is all working fine - even taking account that should the total list be (say) 18, then the next display will show the last 13 matches (and a [Prev] button)

What I am unable to do though is transfer the record Numbers to the Array that determines which record has been selected. This is necessary because the Index Number of this array MUST remain 0 .. 12 - but hold the record number for whichever names are displayed  -  ie. on first listing the will be equal but on the second they could be any number different - with a total of 18 (say) the second list will show the record number of 6th in the total list in PotRecs[0], 7th in [1] . . . .  etc. . . . to 18th in [12].

The Array of 'Possibles' which is linked to the TLabels holding the potential match names  is declared under [Private] in the FPerson Class in Unit P_Page but the [Next] button is (and has to be) on the 'Selector' form & unit. The 'PotRecs' Array (of the Record numbers) and the 'full list' (PotList[] ) Array which includes the rec number, is declared in a 'common' unit accessable by all units.

The PotRecs array is set thus:
Code: Pascal  [Select][+][-]
  1. procedure SetRecIndex;
  2. Var
  3.   I,O : word;
  4. begin
  5.   O := S_Start;
  6.   for I := S_Start to S_End do
  7.     begin
  8.       FPerson.FPosibles[I].Caption := PotList[I].Name;
  9.       PotRecs[I-O] := PotList[I-O].Rec;
  10.     end;
  11. end;
  12.  
I have tried to set the PotRecs array by putting this proc in the Selector Unit (Interface & Implimentation) which is in the uses clause of P_Page - but the compiler tells me that FPosibles[] is not a property of FPerson - when that proc is in P_Page there is no such complaint ! and If I remove FPerson then the compiler says is can't find FPossibles ???

With SetRecIndex in P_Page then the complaint is that in the Selector Unit it can't be found - P_Page is in the uses clause under implimentation in Selector  -  and so on, round & round in circles 🙄

It may well be that I've mis-understood some aspect of the CallBack and in so doing am using an incorrect methodology to set the Record Numbers  -  any 'pointers' would be most welcome.

Happy to 'publish' the project if it might prove useful.



FPC 3.0.0 - Lazarus 1.6 &
FPC 3.2.2  - Lazarus 2.2.0 
Win 7 Ult 64

paweld

  • Hero Member
  • *****
  • Posts: 1796
Re: Using a TShape as a [Button] - any 'Issues' ? + sub-form access
« Reply #81 on: October 07, 2026, 07:15:33 pm »
@J-G: I modified the version from post #31 so that it can handle more entries in the filter: https://chmura.paweld.it/s/g6MHEciSGb3yGQm
Best regards / Pozdrawiam
paweld

J-G

  • Hero Member
  • *****
  • Posts: 1375
Re: Using a TShape as a [Button] - any 'Issues' ? + sub-form access
« Reply #82 on: October 08, 2026, 12:31:22 am »
@J-G: I modified the version from post #31 so that it can handle more entries in the filter: https://chmura.paweld.it/s/g6MHEciSGb3yGQm
Thanks @paweld  -  that looks to do the job - I've downloaded it but since I'm only just back from choir rehearsal I'll look at it properly tomorrow.
FPC 3.0.0 - Lazarus 1.6 &
FPC 3.2.2  - Lazarus 2.2.0 
Win 7 Ult 64

J-G

  • Hero Member
  • *****
  • Posts: 1375
Re: Using a TShape as a [Button] - any 'Issues' ? + sub-form access
« Reply #83 on: October 08, 2026, 06:44:58 pm »
'Life' has reared its ugly head for me today (that is I haven't had a great deal of time!) BUT I have compiled the example and stepped through some of it - even adding the display of the family name of the potential matches (eventually).

I cannot fully understand some of the procedures and find that the [Prev] button NEVER becomes active and the page number doesn't change - although the variable (APageIndex) that determines that IS correctly calculated.  This code is around lines 110 - 125 of your Form2.

I have changed some names to more closely align with MY thinking, such as Form1 >>> P_Page, (Person Page) Form2  >>> Sel_Page, (Selection Page) and Buttons 10 & 11 are now [PrevBut] & [NextBut]. Also Edit_1 has become F_Name etc.   My concern is that - as yet - I cannot understand how Buttons 1 to 9 operate when there are no 'Events' associated with them.  I have traced the action to BCMaterialEdit1Change but cannot find an 'Event' with that name.

Nor do I understand where FormKeyDown comes from - there is no 'Event' of that name in Form1.

The concept does seem effective but my understanding is still very far short of being able to translate it to my real program.  :(


FPC 3.0.0 - Lazarus 1.6 &
FPC 3.2.2  - Lazarus 2.2.0 
Win 7 Ult 64

Thausand

  • Hero Member
  • *****
  • Posts: 629
Re: Using a TShape as a [Button] - any 'Issues' ? + sub-form access
« Reply #84 on: October 08, 2026, 07:07:52 pm »
Nor do I understand where FormKeyDown comes from - there is no 'Event' of that name in Form1.
I have quick look.

Form1 onkeydown property is assign when have event formshow.
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormShow(Sender: TObject);
  2. begin
  3.   Edit1.OnChange := @BCMaterialEdit1Change;
  4.   OnKeyDown := @FormKeyDown;  // <------------
  5. end;
  6.  

Why this is work, have look wiki: https://wiki.freepascal.org/Event_order but can assign on create or other (example design) when want. But then have make good decision for how is work other events that paweld have show.
A docile goblin always follow HERMES.md

paweld

  • Hero Member
  • *****
  • Posts: 1796
Re: Using a TShape as a [Button] - any 'Issues' ? + sub-form access
« Reply #85 on: October 08, 2026, 10:57:28 pm »
Hi @J-G,
Share your example, and I'll try to implement it in your code
Best regards / Pozdrawiam
paweld

 

TinyPortal © 2005-2018