Jump to content
Sign in to follow this  
Martin Liddle

Problem using SpinEditEx in Delphi 12.1

Recommended Posts

I have been using a modification of TSpinEdit which I found somewhere on the Internet years ago.  It has worked fine with all the recent Delphi versions but I can't get it to work with Delphi 12.1.  It compiles but generates an exception when invoked.  The code is:

 

unit SpinEditEx;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Spin;

type
  TSpinEditEx = class(TSpinEdit)
  private
    FOnUpClick : TNotifyEvent;
    FOnDownClick : TNotifyEvent;
  protected
    procedure UpClick (Sender: TObject); OverRide;
    procedure DownClick (Sender: TObject); OverRide;
  public
    { Public declarations }
  published
    property OnDownClick : TNotifyEvent read FOnDownClick write FOnDownClick;
    property OnUpClick : TNotifyEvent read FOnUpClick write FOnUpClick;
    { Published declarations }
  end;

procedure Register;

implementation

procedure TSpinEditEx.UpClick (Sender: TObject);
Begin
  Inherited;
  If Assigned(FOnUpClick) then FOnUpClick(Self);
end;

procedure TSpinEditEx.DownClick (Sender: TObject);
begin
  Inherited;
  If Assigned(FOnDownClick) then FOnDownClick(Self);
end;

procedure Register;
begin
  RegisterComponents('Samples', [TSpinEditEx]);
end;

end.
 

Any thoughts on what I am doing wrong?

Share this post


Link to post
5 hours ago, Martin Liddle said:

It compiles but generates an exception when invoked.

What do you mean by "when invoked"? When you click on the buttons?

 

The code looks okay to me (apart from the funky casing) so the problem is probably in your application code.

It should be a fairly easy to determine the source of the problem if you run your application in the debugger. If you don't know how to do that then it's about time you learn.

Share this post


Link to post

@Anders Melander

9 hours ago, Anders Melander said:

It should be a fairly easy to determine the source of the problem if you run your application in the debugger. If you don't know how to do that then it's about time you learn.

Why are you not polite? and besides the guy says he works for years

Sorry it bothers me

Share this post


Link to post

 

3 hours ago, limelect said:

Why are you not polite? and besides the guy says he works for years

Sorry it bothers me

That's okay. I don't mind critique.

I don't think I was being impolite; I was direct.

 

I assumed that the OP was a hobby programmer (or not a professional) since:

  • He needed to ask the question at all.
  • He used 24 years old code copied verbatim from experts-exchange. Code that anyone with a bit of experience should be able to write on their own.
  • He didn't provide any details about the exception such as where it occurred, call stack, etc. which to me shows that he might be able to read code but doesn't understand debugging.

Hence the suggestion that he learns how to debug. Next step would be to explain how to debug.

  • Like 3

Share this post


Link to post
2 hours ago, Anders Melander said:

I don't think I was being impolite; I was direct.

FWIW, my wife who speaks "human" tells me that my directness was indeed impolite. So sorry, I guess.

Edited by Anders Melander
  • Like 1
  • Haha 4

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
Sign in to follow this  

×