Jump to content

Recommended Posts

  • Administrators

Thank you. This is one of the really old demos where lots of code is in TForm1.InitializeObject. When that is done, you run the risk of everything not being initialized when your code runs.

Standard fix is to move the code to TForm1.InitializeForm:

type
  TForm1 = class(TW3Form)
  private
    {$I 'Form1:intf'}
    FIsCapture: boolean;
    function MakeMouseEvent(label: TW3Label; name: string): TMouseEvent;
    function MouseToStr(shift: TShiftState; x, y: integer; scrXY: TPoint): string;
  protected
    procedure InitializeForm; override;
    procedure InitializeObject; override;
  end;

implementation

{ TForm1}

procedure TForm1.InitializeObject;
begin
  inherited;
  {$I 'Form1:impl'}
end;

procedure TForm1.InitializeForm;

  procedure EndCapture;
  begin
    W3pnlSetCapture.Visible := true;
    W3pnlReleaseCapture.Visible := false;
    W3Panel2.OnMouseUp := nil;
    FIsCapture := false;
  end;

begin
  inherited;

  OnMouseMove := MakeMouseEvent(W3lblFormCoords, 'Form');
  W3Panel1.OnMouseMove := MakeMouseEvent(W3lblPanel1Coords, 'Panel1');

 

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...