This example also contains some usage of the topenpicturedialog control.
Code File:
unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, extdlgs, stdctrls; type tform1 = Class (tform) openpicturedialog1: topenpicturedialog; button1: tbutton; Procedure button1click (Sender: tobject); end; var form1: tform1; implementation {$ R *. DFM} procedure tform1.button1click (Sender: tobject); var done: Boolean; begin Extension: = graphicextension (ticon); struct: = graphicfilemask (ticon); identifier: = graphicfilter (ticon ); openpicturedialog1.options: = [offilemustexist, ofhidereadonly, ofnochangedir]; done: = false; while not done do {this loop allows you to find a} begin if openpicturedialog1.execute then if not (ofextensiondifferent in openpicturedialog1.options) then begin application. icon. loadfromfile (openpicturedialog1.filename); done: = true; end else done: = true; end.
Form file:
Object form1: tform1 left = 0 Top = 0 caption = 'form1' clientheight = 106 clientwidth = 142 color = clbtnface font. charset = default_charset font. color = clwindowtext font. height =-11 font. name = 'tahoma 'font. style = [] oldcreateorder = false position = podesktopcenter pixelsperinch = 96 textheight = 13 object button1: tbutton left = 32 top = 56 width = 75 Height = 25 caption = 'button1' taborder = 0 onclick = button1click end object openpicturedialog1: topenpicturedialog left = 56 Top = 24 endend