0
votes

Aplogies for top posting. This has buggged me for years and now I really need to know the answer. I put 150 points bounty to attract interest, but could increase for the right answer.

Here is what I need:

I use the TMS obejct inpsctor from TMS Scripter Pro to allow users to design a form at run-time. You can assume that it derives from the standard Delphi Object Inspector and adds a little functionality but 90% of it just calls inherited methods.

When I click the ellipsis next to the Picture property of a TImage it calls an inherited method - I don't know which - to allow me to load a picture. When I have done so, I do not know which file the image was loaded from and I want to save it with the same name in a different directory.

  • I could prompt the user for a file name, but that looks confusing to him and is just plain sloppy.
  • I could find a TImage / TPicture descendant which stores the file name and allows me to query it. Anyone who can point out such a FOSS component gets the bounty.
  • I could derive from TPicture and or TImage and code it myself, but am not certain what to change. Anyone who can tell me exactly how to code it gets the the bounty. By exactly, I mean naming classes and methods.

Thanks in advance for any help. This one really annoys me.


Further to my previous question, which did not get a useful answer despite a bounty, I will try rephrasing the question.

Basically, when the user clicks the ellipsis in the object inspector, Delphi opens a file/open dialog. I want to replace this handling with my own, so that I can save the image's path.

I would have expected that all I need to do is to derive a class from TImage and override the Assign() function, as in the following code. However, when I do the assign function is never called. So, it looks like I need to override something else, but what?

unit my_Image;


interface

uses
  Classes, ExtCtrls, Jpeg, Graphics;

type
  Tmy_Image = class(Timage)
    private
      FPicture : TPicture;

    protected
      procedure OnChange(Sender: TObject);

    public { Public declarations }
      Constructor Create(AOwner: TComponent); override;  
      procedure   SetPicture(picture : TPicture); 
      procedure   Assign(Source: TPersistent); override;

    published  { Published declarations - available in the Object Inspector at design-time }
      property Picture : TPicture read FPicture write SetPicture;
  end;  // of class Tmy_Image()

  procedure Register;

implementation

uses Controls, Dialogs;

  procedure Register;
  begin
    RegisterComponents('Standard', [Tmy_Image]);
  end;

  Constructor Tmy_Image.Create(AOwner: TComponent);
  begin
    inherited;  // Call the parent Create method
    Hint := 'Add an image from a file|Add an image from a file'; // Tooltip | status bar text
    AutoSize := True;  // Control resizes when contents change (new image is loaded)
    Height := 104;
    Width  := 104;
    FPicture := TPicture.Create();
    self.Picture.Bitmap.LoadFromResourceName(hInstance, 'picture_poperty_bmp');
  end;

  procedure Tmy_Image.OnChange(Sender: TObject);
  begin
    Constraints.MaxHeight := Picture.Height;
    Constraints.MaxWidth  := Picture.Width;
    Self.Height := Picture.Height;
    Self.Width  := Picture.Width;
  end;

  procedure   Tmy_Image.SetPicture(picture : TPicture);
  begin
    MessageDlg('Tmy_Image.SetPicture', mtWarning, [mbOK], 0);   // never called
  end;


  procedure Tmy_Image.Assign(Source: TPersistent);
  begin
    MessageDlg('Tmy_Image.Assign', mtWarning, [mbOK], 0);   // never called
  end;

end.
2
Do you want something to change the Object Inspector, or do you want something to work at run time? Are you really talking about the Object Inspector, or are you talking about some other similar-looking component by a third-party vendor that your forgot to mention?Rob Kennedy
The TMS object inspector cannot be "Delphi standard." The Delphi Object Inspector uses design-time code from Delphi's packages, and those can't be redistributed to customers.Rob Kennedy
"Delphi Standard" here means shipped in the box, as it were, not "un-Delphi". What you seem to want is a way to alter this third party software's behaviour (TMS). "The object inspector" is thus a really bad title for this question: it should be specific to the third-party software, and included in the tags etc. It may be so specific that you won't get a question here, and may have to ask TMS's support line. Delphi doesn't include an object inspector in the box and design-time support is not user distributable, so TMS must have reimplemented almost everything manually. You may have to ask them.Barry Kelly
A quick search of tmssoftware.com/site/products.asp?t=vcl shows no component called the "object inspector". If you want help with a specific component, provide the name of that component. Otherwise, you're wasting your time and ours while we try and guess what you're talking about; you'd be better off just flailing wildly at the keyboard hoping you hit the right keys.Ken White
You shall try to put all the information in your post to get help. But, before writing a question I think you should read documentation about the product you're using: What you want should be stated somewhere (if possible) or is there a support available for TMS products? just ask they if what you want is possible. Maybe something like a user forum on TMS Software you'll find people with experience in that set of controls/components willing to help you.jachguate

2 Answers

0
votes

See if this works:

  [...]

  procedure Tmy_Image.PictureChange(Sender: TObject);
  begin
    ShowMessage('Should work');
  end;

  [...]

  constructor Tmy_Image.Create(AOwner: TComponent);
  begin
    inherited;  // Call the parent Create method
    Hint := 'Add an image from a file|Add an image from a file'; // Tooltip | status bar text
    AutoSize := True;  // Control resizes when contents change (new image is loaded)
    Height := 104;
    Width  := 104;
    FPicture := TPicture.Create();
    FPicture.OnChange := PictureChange; /// <<<<
    self.Picture.Bitmap.LoadFromResourceName(hInstance, 'picture_poperty_bmp');
  end;

  [...]

God bless you!

0
votes

Ok, I hacked the TMS code. It seemed to be the only way.