
05.05.2009, 20:11
|
 |
Гуру
|
|
Регистрация: 09.03.2009
Адрес: На курорте, из окна вижу теплое Баренцево море. Бррр.
Сообщения: 4,723
Репутация: 52347
|
|
Задача 22.15 - Насколько я ее понял.
Код:
unit Unit20;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm20 = class(TForm)
OpenDialog: TOpenDialog;
Button1: TButton;
Panel1: TPanel;
Memo1: TMemo;
Image1: TImage;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
end;
var
Form20: TForm20;
implementation
Uses JPEG;
{$R *.dfm}
procedure TForm20.Button1Click(Sender: TObject);
Var FileName: String;
begin
if not OpenDialog.Execute then Exit;
FileName := AnsiUpperCase(OpenDialog.FileName);
if (ExtractFileExt(FileName) = '.JPG') or (ExtractFileExt(FileName) = '.BMP')
then begin
Image1.Picture.LoadFromFile(OpenDialog.FileName);
Memo1.Hide;
Image1.Show;
end;
if ExtractFileExt(FileName) = '.TXT'
then begin
Memo1.Lines.LoadFromFile(OpenDialog.FileName);
Memo1.Show;
Image1.Hide;
end;
end;
procedure TForm20.FormCreate(Sender: TObject);
begin
Memo1.Align := alClient;
Image1.Align := alClient;
end;
end.
и DFM
Код:
object Form20: TForm20
Left = 0
Top = 0
Caption = 'Form20'
ClientHeight = 302
ClientWidth = 635
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object Button1: TButton
Left = 8
Top = 8
Width = 75
Height = 25
Caption = #1054#1090#1082#1088#1099#1090#1100
TabOrder = 0
OnClick = Button1Click
end
object Panel1: TPanel
Left = 8
Top = 39
Width = 619
Height = 255
BevelOuter = bvNone
TabOrder = 1
object Image1: TImage
Left = 151
Top = 0
Width = 242
Height = 241
AutoSize = True
Center = True
Proportional = True
Stretch = True
end
object Memo1: TMemo
Left = 40
Top = 24
Width = 345
Height = 193
TabOrder = 0
end
end
object OpenDialog: TOpenDialog
Filter =
#1058#1077#1082#1089#1090#1086#1074#1099#1077' '#1080' '#1043#1088#1072#1092#1080#1095#1077#1089#1082#1080#1077'|*.txt;*.bmp;*.jpg|'#1058#1077#1082#1089#1090#1086#1074#1099#1077' '#1092#1072#1081#1083#1099' (*.txt' +
')|*.txt|'#1043#1088#1072#1092#1080#1095#1077#1089#1082#1080#1077' '#1092#1072#1081#1083#1099' (*.bmp,*.jpg)|*.bmp;*.jpg|'#1042#1089#1077' '#1060#1072#1081#1083#1099' (*' +
'.*)|*.*'
Left = 88
end
end
__________________
Жизнь такова какова она есть и больше никакова.
Помогаю за спасибо.
|