Recent

Author Topic: [EXAMPLE TDBDateEdit/TDateEdit and Form1OnActivate]  (Read 366 times)

What I can do

  • Full Member
  • ***
  • Posts: 126
[EXAMPLE TDBDateEdit/TDateEdit and Form1OnActivate]
« on: November 14, 2024, 02:09:29 pm »
Lazarus 3.4
OS Windows 10@64
Project: use of a DBDateEdit to link to the Date field
errors:
1) both DBDateEdit and DateEdit when picking a day from the calendar causes an Fom1OnActive event is triggered
2) LCLBase is veied as loaded IDE->[Package]->(Install/Uninstall Packages...)-> "show that LCL 3.4, LCLBase 3.4 are installed
3) place the LCLBase in the [Unit1]->Uses  but it causes a compile error that it can't find the file
4) file search of Lazarus drive show these results (don't sure if it helps)

I'm hoping this is a common problem with a fix because after a Lazarus Form Search the top 5 question where not even addressed or solved
« Last Edit: November 14, 2024, 07:58:35 pm by What I can do »

wp

  • Hero Member
  • *****
  • Posts: 12513
Re: TDBDateEdit and TDateEdit both come from LCLBase BIG issues
« Reply #1 on: November 14, 2024, 03:12:48 pm »
1) both DBDateEdit and DateEdit when picking a day from the calendar causes an Fom1OnActive event is triggered
That's the way it works... The calendar is an internally created form, TCalendarPopupForm (in file lcl/forms/calendarpopup.pas). Therefore, before the popup drops down the form with the Dateedit is de-activated, and it is activated again when the popup closes. If you want the OnActivate event to fire only once after the form has been created define a status variable, maybe "FActivated: Boolen" which you check and set in the OnActivate handler:
Code: Pascal  [Select][+][-]
  1. type
  2.   TForm1 = class(TForm)
  3.     procedure FormActivate(Sender: TObject);
  4.   ...
  5.   private
  6.     FActivated: Boolean;
  7.   ...
  8.   end;
  9.  
  10.   procedure TForm1.FormActivate(Sender: TObject);
  11.   begin
  12.     if not FActivated then
  13.     begin
  14.       FActivated := true;
  15.       // do something, only once ...
  16.     end;
  17.   end;

I'm hoping this is a common problem with a fix because after a Lazarus Form Search the top 5 question where not even addressed or solved
I have no idea what you mean...

What I can do

  • Full Member
  • ***
  • Posts: 126
Re: TDBDateEdit and TDateEdit both come from LCLBase BIG issues
« Reply #2 on: November 14, 2024, 07:56:37 pm »
Thank you for the information wp
yes, I like crammed a lot in the Form activation totally confident that it only runs during activation. Not in my wildest imagination would the need to reactivate the main form   but I have learned that things like this is really what makes Lazarus more flexible and have come to accept and appreciate the support with this community.

My thought process was to trace down why would this event occur.
TDBDateEdit comes from TDateEdit that comes from LCLBase which is install LCLBase 3.4
check uses section and no "LCLBse" in the list
put LCLBase in the uses section and it will generate an compile error of file not found.
a windows search of the Lazarus installation folder reviles the file list from the above image.
Then I followed up with a quick history search in the Lazarus Form for all records that contain "LCLBase" which pops up a list of result and none have [SOLVED] in the title.
Feeling defeated, I made this post.
 and yet again I am most grateful for those who give up there time to share knowledge to those who have a passion to code

 

TinyPortal © 2005-2018