0

I'm familiar with delphi scripting so I basically need a strong direction to start from. I've done importing images from files in other languages and it has been quite trivial, but I can find little documentation about this for delphi.

I need to be able to register a control event on a button that will open up a "choose folder/file" dialouge, and then import an image into an object that I can append to a List of some sort.

Anyone have any documentation on this?

Michael
  • 9
  • 1
  • 3
  • 2
    Documentation on *"registering an event on a button that will open up a choose folder/file dialogue which will then import the selected image into an object that could be appended to a sort of List"* ? IMHO, not likely.. Perhaps you'd like to split up the task to pieces and ask one per question. – Sertac Akyuz Aug 17 '11 at 20:20
  • 1
    Welcome to StackOverflow. Your question has no meaning ("anyone have any documentation on this?"), especially when combined with details that are very vague. Please edit your question to add more information, particularly in regards to the meanings of "import an image into an object" and "append to a List of some sort". (I can guess that "register a control event on a button" means "create a TButton.OnClick event handler".) Also, just FYI: Delphi is *not* a scripting language, so you can't be familiar with Delphi "scripting". :) – Ken White Aug 17 '11 at 20:58

2 Answers2

0

Although your question is rather broad and "delphi scripting" sounds interesting here is an example that might get you started:

Project: Let the user select an image and display this image

This form contains a TButton, a TOpenPictureDialog and a simple TImage for displaying one image (sorry, no list of pictures in this example).

Simple form with TButton, TOpenPictureDialog and TImage

Part 1 ("register a control event on a button"):

Attach an OnClick event handler to the button by double clicking the button in the form designer. If your button's Name is btnOpenPicture then the auto-generated handler will have the name btnOpenPictureClick (see the following code). The code in this handler will be executed when the user clicks the button.

procedure TForm1.btnOpenPictureClick(Sender: TObject);
begin
  if OpenPictureDialog1.Execute(Self.Handle) then
    Image1.Picture.LoadFromFile(OpenPictureDialog1.FileName);
end;

Part 2 ("'choose folder/file' dialouge") is represented by OpenPictureDialog1.Execute which opens a dialog where the user can choose a picture. The Execute command waits until the user closes the dialog and returns True if the user chose not to cancel the dialog but rather chose an image file (the filename is stored in OpenPictureDialog1.FileName).

Part 3 ("import an image into an object") would then be Image1.Picture.LoadFromFile which instructs the TImage component to load and display the file the user chose.

I cannot immediately name a component included in Delphi which could be used easily as a list for displaying images visually (that's your "append to a List of some sort"). I only know some third-party components which are not available for free, thus not good for quick experimenting.

Maybe this can be a base for asking more specific questions (as already encouraged by the commentators of your question). I already have one: "Is there a VCL component I could use for displaying a list of images?"

Heinrich Ulbricht
  • 10,064
  • 4
  • 54
  • 85
-2

There are lots of articles and tutorials on how to do this. Code for loading images can be found in this Stackoverflow question; to complete your problem, you need a TButton and probably a TOpenPictureDialog.

Community
  • 1
  • 1
Leonardo Herrera
  • 8,388
  • 5
  • 36
  • 66
  • 1
    Since the question is "Anyone have any documentation on this?", and the meaning of "this" is totally undefined, this is not an answer. You might want to delete it before you start losing rep to downvotes. :) – Ken White Aug 17 '11 at 21:00
  • The fact I got only one downvote says more about the downvoter than my answer. I linked to one documentation page and an SO answer which actually shows how to do what the OP wants. – Leonardo Herrera Aug 18 '11 at 14:28
  • The fact the OP has 3 close votes and only one real answer (which isn't yours, BTW) should tell you what a poor question it was, and how lacking in information. But no problem - SO works by people upvoting what they consider good answers, and downvoting what they consider bad. (I could post a link to PhotoShop and it would qualify as a good answer as well, according to your definition, and based on the information provided in the question.) – Ken White Aug 18 '11 at 20:52