Господа помогите с проблемой! Суть ее такова: 1) при выборе объекта в ComboBox, лежащем на фрейме, добавляется объект в AddressList (Имя фрейма,указатель на фрейм). AddressList находится в форме типа TDdeTable | Код | unit NewScalp;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls, Buttons, ComCtrls;
type Stok = record Name: string; // Название бумаги ClassCode: string; // Класс SecCode: string; // Код Ask: Single; // Спрос AskQ: Integer; // Спрос по лучшей цене Bid: Single; // Предложение BidQ: Integer; // Предложение по лучшей цене Last: Single; // Цена посл. сделки Lot: Word; // Размер лота Step: Single; // Шаг цены end;
type TfrNewScalp = class(TFrame) Panel: TPanel; CheckBox: TCheckBox; Bevel: TBevel; ComboBox: TComboBox; Label1: TLabel; SpeedButton: TSpeedButton; ComboBox2: TComboBox; Label2: TLabel; Bevel1: TBevel; Edit1: TEdit; Label3: TLabel; Label4: TLabel; Edit2: TEdit; Label5: TLabel; Edit3: TEdit; ComboBox3: TComboBox; UpDown1: TUpDown; Label6: TLabel; Edit4: TEdit; Label7: TLabel; UpDown2: TUpDown; ComboBox4: TComboBox; Label8: TLabel; procedure FrameResize(Sender: TObject); procedure ComboBoxDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); procedure ComboBoxSelect(Sender: TObject); private { Private declarations } public procedure Calculation(var DataTab: array of Stok); { Public declarations } end;
implementation
uses Main, NewDdeTable;
{$R *.dfm}
procedure TfrNewScalp.Calculation(var DataTab: array of Stok); var i,k: Integer; begin For i:=0 to Length(DataTab)-1 do k:=k+DataTab[i].AskQ; Edit1.Text:=IntToStr(k); end;
. . . . .
procedure TfrNewScalp.ComboBoxSelect(Sender: TObject); var i,j,k: Integer; D: TDdeTable; begin i:=frMain.StokStrings.IndexOf(ComboBox.Items[ComboBox.ItemIndex]); D:=TDdeTable(frMain.StokList.Items[i]); D.AddressList.AddObject(Self.Name,@Self); end;
|
| Код | unit NewDdeTable;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Grids, Buttons, StdCtrls, Math, DdeExlUnt;
type TDdeTable = class(TForm) StringGrid1: TStringGrid; procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormShow(Sender: TObject); private { Private declarations } public ListValue: TStrings; AddressList: TStringList; procedure OnClickButton(Sender: TObject); procedure OnUpdate(Topic: string; NewCells: TVariantTable; NewAddr: TRect); procedure Clear; { Public declarations } end;
var DdeTable: TDdeTable;
implementation
uses Main, NewScalp;
var btn: TSpeedButton; DataTab: array of Stok; k,l,m,n,o,p,q,r,s,t: Integer;
{$R *.dfm}
procedure TDdeTable.OnClickButton(Sender: TObject); var h: Integer; begin h:=TSpeedButton(Sender).Tag; if IsWindowVisible(h) then ShowWindow(h,SW_HIDE) else ShowWindow(h,SW_SHOW); end;
procedure TDdeTable.OnUpdate(Topic: string; NewCells: TVariantTable; NewAddr: TRect); var i, j: integer; begin . . . . . {Здесь формируется массив DataTab} . . . . .
. . . . .
If AddressList.Count > 0 then for i:=0 to AddressList.Count-1 do // перебираются все объекты в AddressList begin TfrNewScalp(AddressList.Objects[i]).Calculation(DataTab); // и в процедуры каждого объекта отправляется переменная DataTab end; end;
|
2) из TDdeTable.OnUpdate массив DataTab передается во все объекты из AddressList. Все работает замечательно. Проблема возникает при попытке вывода в Edit1 на фрейме. Без этой строки ошибки нет. В чем же загвоздка?
|