Jump to content
Ian Branch

What is wrong with this component??

Recommended Posts

MyCustomCalendar.pas

Hi Team,

Delphi 12.2 p2.  32 bit App.

It builds and installs OK but when I go to add it to a form Delphi thinks about it for a while, way too long, and then falls over. 😞

It is a derivation of TMonthCalendar.

Appreciate any insights.

 

Regards & TIA,

Share this post


Link to post

Reading the code I believe it is the:

procedure TMyCustomCalendar.CreateWnd;
begin
  inherited CreateWnd;
  RecreateWnd; // Force the control to redraw and send MCN_GETDAYSTATE
end;
 

Why do you want to create windows handle all the time? (just after it was created?)

Share this post


Link to post

Tks Lajos,

You, that fixed it Tks.  I didn't think about the race condition it would set up.

 

Ian

Share this post


Link to post

TL;DR;

You should consider to separate the combined unit into separate designtime and runtime units.

procedure Register;
begin
  RegisterComponents('My Delphi Tools', [TMyCustomCalendar]);
end;

 

Share this post


Link to post
1 hour ago, Rollo62 said:

You should consider to separate the combined unit into separate designtime and runtime units.

There's no design-time code in it so unless the unit is used by other design-time packages there's really no reason to do that.

Share this post


Link to post

Perhaps, but I assume if there is already one custom control, then its very likely that there are several custom components units too, like

MyCustomCalendar.pas

MyCustomThis.pas

MyCustomThat.pas

 

wouldn't it be cleaner to combine the registration for the designer in a common registration unit?

MyCustomReg.pas

 

procedure Register;
begin
  RegisterComponents('My Delphi Tools', [TMyCustomCalendar, TMyCustomThis, TMyCustomThat]);
end;

 

Just saying, I haven't looked too deep into this, its also fine as-is.

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×