![]() |
|
#16
|
||||
|
||||
![]() Добавлю от себя по БД. Задача 22.1
Код:
unit Unit19; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Grids, DBGrids, DB, DBClient; type TForm19 = class(TForm) DBGrid: TDBGrid; procedure FormCreate(Sender: TObject); private T: TClientDataset; DS: TDataSource; public { Public declarations } end; var Form19: TForm19; implementation {$R *.dfm} procedure TForm19.FormCreate(Sender: TObject); begin // Создаем таблицу заданой структуры T := TClientDataset.Create(nil); T.FieldDefs.Add('ТабНомер',ftString,20,True); T.FieldDefs.Add('ФИО',ftString,70,True); T.FieldDefs.Add('Должность',ftString,50,False); T.FieldDefs.Add('УчСтепень',ftString,50,False); T.CreateDataSet; // Наполняем данными T.AppendRecord(['123456','Ванина Е.С.','Доцент','К.т.н']); T.AppendRecord(['101010','Лавочкин М.П.','Профессор','Д.ф.-м.н']); T.AppendRecord(['111222','Харин Х.М.','Ассистент','К ф. – м. н']); T.AppendRecord(['451239','Сивый П.Б.','Ассистент','К.т.н']); // Подготавливаем для отображения DS := TDataSource.Create(nil); DS.DataSet := T; // Выводим данные на форму через компонент DBGrid DBGrid.DataSource := DS; end; end. И DFM Код:
object Form19: TForm19 Left = 0 Top = 0 Caption = 'Form19' 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 DBGrid: TDBGrid Left = 8 Top = 8 Width = 619 Height = 169 TabOrder = 0 TitleFont.Charset = DEFAULT_CHARSET TitleFont.Color = clWindowText TitleFont.Height = -11 TitleFont.Name = 'Tahoma' TitleFont.Style = [] end end Жизнь такова какова она есть и больше никакова. Помогаю за спасибо. Последний раз редактировалось Страдалецъ, 05.05.2009 в 19:49. |
#17
|
||||
|
||||
![]() большое СПАСИБО. выручил
|
#18
|
||||
|
||||
![]() Задача 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 Жизнь такова какова она есть и больше никакова. Помогаю за спасибо. |
#19
|
||||
|
||||
![]() И под финал 22.14
Код:
unit Unit21; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls, ComCtrls; type TForm21 = class(TForm) Button1: TButton; TrackBar1: TTrackBar; Label1: TLabel; Image1: TImage; procedure Button1Click(Sender: TObject); procedure Image1Click(Sender: TObject); procedure FormCreate(Sender: TObject); end; var Form21: TForm21; implementation {$R *.dfm} procedure TForm21.Button1Click(Sender: TObject); Var i: Integer; R: TRect; begin Randomize; for i := 1 to TrackBar1.Position do begin R := Rect(Random(Image1.Width),Random(Image1.Height),Random(Image1.Width),Random(Image1.Height)); Image1.Canvas.Pen.Color := Random($FFFF); Image1.Canvas.Brush.Color := Random($FFFF); case Random(4)+1 of 1: begin Image1.Canvas.MoveTo(R.Left,R.Top); Image1.Canvas.LineTo(R.Right,R.Bottom); end; 2: Image1.Canvas.Rectangle(R.Left,R.Top,R.Right,R.Bottom); 3: Image1.Canvas.RoundRect(R,Random(R.Right-R.Left),Random(R.Bottom-R.Top)); 4: Image1.Canvas.FillRect(R); end; end; end; procedure TForm21.FormCreate(Sender: TObject); begin Image1.Canvas.Brush.Color := clWhite; end; procedure TForm21.Image1Click(Sender: TObject); begin Image1.Canvas.Brush.Color := clWhite; Image1.Canvas.FillRect(Image1.ClientRect); end; end. И DFM Код:
object Form21: TForm21 Left = 0 Top = 0 Caption = 'Form21' ClientHeight = 469 ClientWidth = 714 Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'Tahoma' Font.Style = [] OldCreateOrder = False OnCreate = FormCreate DesignSize = ( 714 469) PixelsPerInch = 96 TextHeight = 13 object Label1: TLabel Left = 136 Top = 13 Width = 94 Height = 13 Caption = #1050#1086#1083#1080#1095#1077#1089#1090#1074#1086' '#1092#1080#1075#1091#1088 end object Image1: TImage Left = 8 Top = 63 Width = 698 Height = 398 Anchors = [akLeft, akTop, akRight, akBottom] OnClick = Image1Click end object Button1: TButton Left = 16 Top = 24 Width = 75 Height = 25 Caption = #1057#1086#1079#1076#1072#1090#1100 TabOrder = 0 OnClick = Button1Click end object TrackBar1: TTrackBar Left = 128 Top = 32 Width = 150 Height = 25 Max = 25 Min = 1 Position = 10 TabOrder = 1 end end Жизнь такова какова она есть и больше никакова. Помогаю за спасибо. |