Forum > LCL

TDateTimePicker: Setting Min and Max Date

<< < (2/2)

I created a new project with my code. I had the same problem.

As lucamar and I told you...

You access frmAstCont in the OnCreate event of Form1. Looking at the project file you will see that at this time the frmAstCont is not yet created and thus nil.

You can use the OnShow or OnActivate events instead. On the other hand, these events may be fired later during execution of the program again. To prevent unwanted side-effects when this happens, I often implement a method "BeforeRun" of the mainform which is called in the project unit immediately before Application.Run.

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---type  TForm1 = class(TForm)  ...  public    procedure BeforeRun;    ...  end; procedure TForm1.BeforeRun;begin  _MinMaxFechaContable; end; ---------- program Project;...begin  ....  Application.Initialize;  Application.CreateForm(TForm1, Form1);  Application.CreateForm(TfrmAstCont, frmAstCont);  Form1.BeforeRun;  Application.Run;end.  
This way the crash due to nonexisting frmAstConCont is prevented. But as you'll notice there is another problem with your comboboxes - I'll leave this to you to find a solution...



[0] Message Index

[*] Previous page

Go to full version