請問該如何撰寫動態產生 多個相同元件的 觸發事件 ?? |
答題得分者是:chris_shieh
|
seedbcc
高階會員 發表:232 回覆:272 積分:105 註冊:2003-12-10 發送簡訊給我 |
我的元件是tChart
想要寫它的 mousemove事件
procedure TFrm_PhVarScatter.FormShow(Sender: TObject); var i,j,k,Int_cht,test:integer; ifvalid:String; TS_Tmp: TcxTabSheet; Lyc_Tmp: TdxLayoutControl; AList: TStringList; CalX,CalY:Array of Double; Tmp_R:Double; m,n,Int_Scale:integer; Cht_Scatter :Array of Tchart; begin Int_ChartNum:=2; SetLength(Cht_Scatter,Int_ChartNum 1); for i:=1 to Int_ChartNum do begin //動態產生頁數 TS_Tmp := TcxTabSheet.Create(self); TS_Tmp.PageControl := Pgc_Scatter; TS_Tmp.Caption:='第' IntToStr(i) '張圖'; Lyc_Tmp:=TdxLayoutControl.Create(self); Lyc_Tmp.Parent:=TS_Tmp; Lyc_Tmp.AutoContentSizes:=[acsWidth,acsHeight]; Lyc_Tmp.Align:=alClient; Lyc_Tmp.LookAndFeel:=LayoutOfficeLookAndFeel; Cht_Scatter[i]:= TChart.Create(self); Cht_Scatter[i].Parent:=Lyc_Tmp; Cht_Scatter[i].Align:=alClient; Lyc_Tmp.Items[0].AlignHorz:=ahClient; Lyc_Tmp.Items[0].alignVert:=avClient; Cht_Scatter[i].Name:='Cht_' IntToStr(i); Cht_Scatter[i].Title.Text.Add(IntToStr(i)); end; |
chris_shieh
高階會員 發表:46 回覆:308 積分:240 註冊:2004-04-26 發送簡訊給我 |
procedure TFrm_PhVarScatter.ChartMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); begin ... ... end; procedure TFrm_PhVarScatter.FormShow(Sender: TObject); var i,j,k,Int_cht,test:integer; ifvalid:String; TS_Tmp: TcxTabSheet; Lyc_Tmp: TdxLayoutControl; AList: TStringList; CalX,CalY:Array of Double; Tmp_R:Double; m,n,Int_Scale:integer; Cht_Scatter :Array of Tchart; begin Int_ChartNum:=2; SetLength(Cht_Scatter,Int_ChartNum 1); for i:=1 to Int_ChartNum do begin //動態產生頁數 TS_Tmp := TcxTabSheet.Create(self); TS_Tmp.PageControl := Pgc_Scatter; TS_Tmp.Caption:='第' IntToStr(i) '張圖'; Lyc_Tmp:=TdxLayoutControl.Create(self); Lyc_Tmp.Parent:=TS_Tmp; Lyc_Tmp.AutoContentSizes:=[acsWidth,acsHeight]; Lyc_Tmp.Align:=alClient; Lyc_Tmp.LookAndFeel:=LayoutOfficeLookAndFeel; Cht_Scatter[i]:= TChart.Create(self); Cht_Scatter[i].Parent:=Lyc_Tmp; Cht_Scatter[i].Align:=alClient; Lyc_Tmp.Items[0].AlignHorz:=ahClient; Lyc_Tmp.Items[0].alignVert:=avClient; Cht_Scatter[i].Name:='Cht_' IntToStr(i); Cht_Scatter[i].Title.Text.Add(IntToStr(i)); Cht_Scatter[i].OnMouseMove:=ChartMouseMove; end;發表人 - chris_shieh 於 2005/01/26 11:45:14 |
seedbcc
高階會員 發表:232 回覆:272 積分:105 註冊:2003-12-10 發送簡訊給我 |
|
seedbcc
高階會員 發表:232 回覆:272 積分:105 註冊:2003-12-10 發送簡訊給我 |
若每個chart內有point series及label
我要如何更改下面的事件 ?? QcSes_St-->point series
lbl_StPointValue -> label
procedure TFrm_PhVarScatter.Cht_ScatterMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); var AValueIndex,ValX,ValY :Integer; begin AValueIndex:=QcSes_St.GetCursorValueIndex; if AValueIndex>-1 then begin ValX := QcSes_St.CalcXPosValue(QcSes_St.XValue[AValueIndex]); ValY := QcSes_St.CalcYPosValue(QcSes_St.YValue[AValueIndex]); If (Abs(ValX - X) <= QcSes_St.Pointer.HorizSize) and (Abs(ValY - Y) <= QcSes_St.Pointer.VertSize) then begin lbl_StPointValue.Visible:=True; lbl_StPointValue.Top:=Y 20; lbl_StPointValue.Left:=X; lbl_StPointValue.Caption:=FloatToStr(QcSes_St.YValue[AValueIndex]); end else lbl_StPointValue.Visible:=False; end else begin lbl_StPointValue.Visible:=False; end; end; |
seedbcc
高階會員 發表:232 回覆:272 積分:105 註冊:2003-12-10 發送簡訊給我 |
若每個chart內有point series及label
我要如何更改下面的事件 ?? QcSes_St-->point series
lbl_StPointValue -> label
procedure TFrm_PhVarScatter.Cht_ScatterMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); var AValueIndex,ValX,ValY :Integer; begin AValueIndex:=QcSes_St.GetCursorValueIndex; if AValueIndex>-1 then begin ValX := QcSes_St.CalcXPosValue(QcSes_St.XValue[AValueIndex]); ValY := QcSes_St.CalcYPosValue(QcSes_St.YValue[AValueIndex]); If (Abs(ValX - X) <= QcSes_St.Pointer.HorizSize) and (Abs(ValY - Y) <= QcSes_St.Pointer.VertSize) then begin lbl_StPointValue.Visible:=True; lbl_StPointValue.Top:=Y 20; lbl_StPointValue.Left:=X; lbl_StPointValue.Caption:=FloatToStr(QcSes_St.YValue[AValueIndex]); end else lbl_StPointValue.Visible:=False; end else begin lbl_StPointValue.Visible:=False; end; end; |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |