請問一個問題因為對我來講我太復雜都不知道怎樣定題目,希望可以接受我這個題目 |
尚未結案
|
SamSam1230
中階會員 發表:128 回覆:178 積分:65 註冊:2004-12-23 發送簡訊給我 |
我的問題是
我現在 有2張 form : from1 , form2
再有一張 handler form 是run time create 的 它們的關係是 form1 會 run time create handler form handler form 裡有timer , DB 的VCL
每次form1 call handler form 的時候 , handler 會做一些事情
是用timer 去做的, 會做很多次 , 但每做完一次會post message 那個message 會 trigger form1 的 message handler ,再會叫form2 做事
form2 做完的時候會post message , 這個時候form 1 的message handler 會再處理這個message 整個process 就是這樣
但有一點是 當handler form post message 之後 那些timer 還一樣在動, 所以會再post message , 當第一個post message post 之後, form1 也會被trigger. 當我由 form1 起動 handler form 之後, error 就會出現
問題好像是由handler form post 完第一個message 之後出現的
我試過在handler form 加了一個memo 去看timer 的動作 ,
發現當error 出現之後, timer 一樣的在動 set break point 也不知怎樣做, 因為都找不出那句code 出錯 error message 是 : exception EAccess Violation in module newproject.exe at 000D2103 Access violation at address 004D2103 in module newproject.exe Read of address 50F314F0 那些address 每次都會不一樣. 我表達可能很亂但希望大大可以建議我可以怎樣做 可能不是最好的方法 !!! 我也是初學者 !!! 不要怪我呀..
我最喜歡吃零食啦^.^
|
malanlk
尊榮會員 發表:20 回覆:694 積分:577 註冊:2004-04-19 發送簡訊給我 |
|
SamSam1230
中階會員 發表:128 回覆:178 積分:65 註冊:2004-12-23 發送簡訊給我 |
// Form1 coding var gDeamonSetarray : array of TFrmDeamonHandler; procedure TFrmMain.AppMessage(var Msg: TMsg; var Handled: Boolean); begin case Msg.message of WM_UPDATE : GetMsg(Msg); WM_CLEARS : GetMsg(Msg); WM_DEAMONMSG : FrmStatus.DemonOnline(Msg); WM_DEAMAUTO : FrmStatus.DemonOnline(Msg); end; end; procedure TFrmMain.btnAutoPlayClick(Sender: TObject); var i,max : integer; begin if Not gDeamonOnline then exit; if gDeamonscript.Count <= 0 then exit; gDeamonAutoPlay := True; max := gDeamonscript.Count - 2; if max <= 0 then exit; setlength(gDeamonSetarray,max); if FrmMainVEHTable.Active then FrmMainVEHTable.Close; FrmMainVEHTable.Databasename := _CLIENT_ALIAS; FrmMainVEHTable.TableName := _CLIENTS; FrmMainVEHTable.Open; for i := 0 to Length(gDeamonSetArray)-1 do begin gDeamonSetArray[i] := TFrmDeamonHandler.Create(Self); with gDeamonSetArray[i] do begin DeamonForwardTotal := strtoint(gDeamonscript.Values['F']); DeamonBackwardTotal := strtoint(gDeamonscript.Values['B']); DeamonBusLLI := gDeamonscript.Strings[i 2]; DeamonRouteID := FrmMainVEHTable.Lookup(_HID,DeamonBusLLI,_ROUTE_ID); DeamonBusVID := FrmMainVEHTable.lookup(_HID,DeamonBusLLI,_ID); DeamonID := i; end; end; // for i := 0 to Length(gDeamonSetArray)-1 do gDeamonSetArray[i].show; for i := 0 to Length(gDeamonSetArray)-1 do gDeamonSetArray[i].Deamonenabled := True; FrmMainVEHTable.Close; end; // StatusForm coding procedure TFrmBusStatus.DemonOnline(var Msg: TMsg); var tmpstr : string; i : integer; vehicle_name : string; begin case Msg.message of WM_DEAMONMSG : tmpstr := FrmMain.DeamonMsg; WM_DEAMAUTO : tmpstr := FrmMain.gDeamonSetarray[msg.wParam].DeamonMsg; end; // .... Tmpstr data process after finish will post message// PostMessage(HANDLE,WM_UPDATE,0,0); end; // handler coding unit DeamonHandler; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, DBTables, Db, HeaderUnit, StdCtrls; type TFrmDeamonHandler = class(TForm) DeamonDataTimer: TTimer; DeamonMsgTimer: TTimer; HandlerVEHTable: TTable; Database1: TDatabase; Memo1: TMemo; procedure DeamonDataTimerTimer(Sender: TObject); procedure DeamonMsgTimerTimer(Sender: TObject); procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); private { Private declarations } gDeamonBusVID,gDeamonRouteID,gDeamonBusLLI,gDeamonMsg : string; gDeamonCount,gDeamonForwardTotal,gDeamonBackwardTotal : integer; fenabled: boolean; gDeamonID:integer; procedure CreateTable(TBname : string); procedure Add(TBname,parm1,parm2,parm3:string); procedure SendMsg(Msg:String); procedure SetDeamonEnabled(const Value: Boolean); public { Public declarations } property DeamonBusVID : string read gDeamonBusVID write gDeamonBusVID; property DeamonRouteID : string read gDeamonRouteID write gDeamonRouteID; property DeamonBusLLI : string read gDeamonBusLLI write gDeamonBusLLI; property DeamonID : integer read gDeamonID write gDeamonID; property DeamonForwardTotal : integer read gDeamonForwardTotal write gDeamonForwardTotal; property DeamonBackwardTotal : integer read gDeamonBackwardTotal write gDeamonBackwardTotal; property DeamonMsg : string read gDeamonMsg write gDeamonMsg; property DeamonEnabled: Boolean read fenabled write SetDeamonEnabled; end; var FrmDeamonHandler: TFrmDeamonHandler; implementation uses NVtermMain; {$R *.DFM} procedure TFrmDeamonHandler.SetDeamonEnabled(const Value: Boolean); var tmpvalue : integer; begin case Value of True : begin fenabled := True; Randomize; while not ((tmpvalue > 300) and (tmpvalue < 500)) do tmpvalue := Random(500); DeamonDataTimer.interval := tmpvalue; DeamonMsgTimer.interval := tmpvalue; DeamonDataTimer.Enabled := True; end; False : begin fenabled := False; DeamonDataTimer.Enabled := False; DeamonMsgTimer.Enabled := False; end; end; end; procedure TFrmDeamonHandler.DeamonDataTimerTimer(Sender: TObject); const percentage = '0.5'; var i : integer; begin DeamonDataTimer.Enabled := False; HandlerVEHTable.Tablename := 'v' DeamonBusVID _SCHEDULE formatdatetime('mmddyy',now); if Not HandlerVEHTable.Exists then CreateTable(HandlerVEHTable.Tablename); Add(HandlerVEHTable.Tablename,formatdatetime('yyyy-mm-dd hh:nn:ss',now),gDeamonRouteID 'f' InttoStr(gDeamonCount),percentage); DeamonMsgTimer.Enabled := True; end; procedure TFrmDeamonHandler.DeamonMsgTimerTimer(Sender: TObject); begin DeamonMsgTimer.enabled := False; SendMsg(gDeamonBusLLI); inc(gDeamonCount); if gDeamonCount <= gDeamonForwardTotal then DeamonDataTimer.enabled := True; end; procedure TFrmDeamonHandler.SendMsg(Msg:String); begin DeamonMsg := Msg; PostMessage(HANDLE,WM_DEAMAUTO,DeamonID,0); // DeamonMsg := 'Deamon Message Sent : ' Msg; end; procedure TFrmDeamonHandler.CreateTable(TBname : string); var TmpTable : TQuery; begin DataBase1.Open; try TmpTable:=TQuery.Create(Self); TmpTable.DatabaseName:=_HIST_ALIAS; with TmpTable.SQL do begin Clear; Add('Create table ' TBname); Add(' (' _REPORTDT ' datetime NOT NULL,'); Add(_TARGET ' char(50),'); Add(_PERCENT_DONE ' float(32))'); end; TmpTable.ExecSQL; TmpTable.Free; if not DeamonEnabled then MessageDlg('Table : ' TBname ' is Created',mtInformation,[mbOK],0); except on E: EDBEngineError do MessageDlg(E.Message,mtError,[mbOK],0); end; DataBase1.Close; end; procedure TFrmDeamonHandler.Add(TBname,parm1,parm2,parm3:string); var TmpTable : TQuery; begin Database1.Open; try TmpTable := TQuery.Create(Self); TmpTable.DatabaseName := _HIST_ALIAS; with TmpTable.SQL do begin Clear; Add('insert into ' TBname); Add('(' _REPORTDT ',' _TARGET ',' _PERCENT_DONE ')'); Add('values ("' parm1 '","' parm2 '","' parm3 '")'); end; TmpTable.ExecSQL; TmpTable.Free; if not DeamonEnabled then MessageDlg('New Record Added',mtInformation,[mbOK],0); except on E: EDBEngineError do MessageDlg(E.Message #10#13 'New Record not Added',mtError,[mbOK],0); end; Database1.Close; end; procedure TFrmDeamonHandler.FormCreate(Sender: TObject); begin Database1.Open; HandlerVEHTable.Databasename := _HIST_ALIAS; end;this is piece of code , hope you know what I am talking sorry for use english, my development is english version . can't type chinese thanks a lot 可能不是最好的方法 !!! 我也是初學者 !!! 不要怪我呀.. 我最喜歡吃零食啦^.^ |
malanlk
尊榮會員 發表:20 回覆:694 積分:577 註冊:2004-04-19 發送簡訊給我 |
|
SamSam1230
中階會員 發表:128 回覆:178 積分:65 註冊:2004-12-23 發送簡訊給我 |
引言: 1. 確認ㄧ下 Project-->Options Forms 那頁中 FrmDeamonHandler 應該要放在 Available Forms 那邊 <- 這個已經設定好 2. 將 gDeamonscript.Count 設為 3 先跑ㄧ個就好 <- 現在也是以這個為測試數 3. inc(gDeamonCount); 設中斷點 <- 這個你的意思是run time 的時候設中斷點嗎? 我照你的意思做了一次 也在 DeamonMsgTimer.enabled := False; 設中斷點 當第一次到這兩個中斷點的時候都沒有error 當我再按F9 的時候, 就是說進入第二次 error 就會在中斷點停之前就已經出來了可能不是最好的方法 !!! 我也是初學者 !!! 不要怪我呀.. 我最喜歡吃零食啦^.^ |
malanlk
尊榮會員 發表:20 回覆:694 積分:577 註冊:2004-04-19 發送簡訊給我 |
|
SamSam1230
中階會員 發表:128 回覆:178 積分:65 註冊:2004-12-23 發送簡訊給我 |
|
malanlk
尊榮會員 發表:20 回覆:694 積分:577 註冊:2004-04-19 發送簡訊給我 |
|
SamSam1230
中階會員 發表:128 回覆:178 積分:65 註冊:2004-12-23 發送簡訊給我 |
|
malanlk
尊榮會員 發表:20 回覆:694 積分:577 註冊:2004-04-19 發送簡訊給我 |
|
SamSam1230
中階會員 發表:128 回覆:178 積分:65 註冊:2004-12-23 發送簡訊給我 |
|
malanlk
尊榮會員 發表:20 回覆:694 積分:577 註冊:2004-04-19 發送簡訊給我 |
|
SamSam1230
中階會員 發表:128 回覆:178 積分:65 註冊:2004-12-23 發送簡訊給我 |
procedure getmsg(); const fBusOffset = 30; bBusOffset = 30; var Vehindex,StopIndex,X,Y,TBus,index,i: integer; X1,Y1 : double; status : TBusStatusType; TmpStr : string; DepotRect : TRect; begin if (gmode = mtnull) then exit; Vehindex := FrmBusStatus.VehicleSelected; gVeh := FrmBusStatus.VehicleList; ReloadCMap; gNumOfVehicleLoaded := FrmBusStatus.NumOfVehicleLoaded; for i := 0 to gNumOfVehicleLoaded -1 do begin With gVeh[i] do begin With Schedule do begin index := Pos('_',target_stop); TmpStr := UpperCase(Copy(target_stop,index 1,Length(target_stop)-1)); if (Alarm and $1000) <> $1000 then status:=bstOutOfService else if Pos('F',uppercase(TmpStr)) <> 0 then status := bstForward else if Pos('B',uppercase(TmpStr)) <> 0 then status := bstBackward else status:=bstOutOfService; case status of bstForward : TmpStr := Copy(target_stop,1,Pos('F',TmpStr) index-1); bstBackward : TmpStr := Copy(target_stop,1,Pos('B',TmpStr) index-1); end; if (UpperCase(TmpStr) <> UpperCase(gRouteNo)) and not (status=bstOutOfService)then exit; TmpStr := UpperCase(Copy(target_stop,Pos('_',target_stop) 1,Length(target_stop)-1)); case status of bstForward : TBus := StrToInt(Copy(TmpStr,Pos('F',TmpStr) 1,Length(TmpStr)-1)); bstBackward : TBus := StrToInt(Copy(TmpStr,Pos('B',TmpStr) 1,Length(TmpStr)-1)); end; end; case status of bstForward : begin StopIndex := FindBusStopIndex(gfBusStops,TBus); case gmode of mtRouteEditorMode : begin X1 := gfBusStops[StopIndex].Longdeg; Y1 := gfBusStops[StopIndex].Latdeg; gConceptMap.PlotBusOnRoute(X1,Y1,status,Notes); end; mtStopEditorMode : exit; mtAudioEditorMode : begin X := gfBusStops[StopIndex].CmapX; Y := gfBusStops[StopIndex].CmapY - fBusOffset; gConceptMap.PlotBusOnCMap(X,Y,status,Notes); end; end; end; bstBackward : begin StopIndex := FindBusStopIndex(gbBusStops,TBus); case gmode of mtRouteEditorMode : begin X1 := gbBusStops[StopIndex].Longdeg; Y1 := gbBusStops[StopIndex].Latdeg; gConceptMap.PlotBusOnRoute(X1,Y1,status,Notes); end; mtStopEditorMode : exit; mtAudioEditorMode : begin X := gbBusStops[StopIndex].CmapX; Y := gbBusStops[StopIndex].CmapY bBusOffset; gConceptMap.PlotBusOnCMap(X,Y,status,Notes); end; end; end; bstOutOfService : begin DepotRect := gConceptMap.DepotRect; case gmode of mtRouteEditorMode : ; mtStopEditorMode : exit; mtAudioEditorMode : begin X := DepotRect.Left 20; Y := DepotRect.Top 20; gConceptMap.PlotBusOnCMap(X,Y,status,Notes); end; end; end; end; end; end; sleep(1); end;in the first red mark i set a breakpoint then stop there where i := 6 will go to the first red mark then after that should be goto second red mark which i put the sleep for test but after the program run to first red mark,if i press F9 in first red mark error will occur it haven't goto second red mark, if i press F8 it will from first red mark jump to second red mark it haven't run two yellow line. then will jump to second red mark then F8 will jump to stdwndProc. 可能不是最好的方法 !!! 我也是初學者 !!! 不要怪我呀.. 我最喜歡吃零食啦^.^ |
malanlk
尊榮會員 發表:20 回覆:694 積分:577 註冊:2004-04-19 發送簡訊給我 |
|
SamSam1230
中階會員 發表:128 回覆:178 積分:65 註冊:2004-12-23 發送簡訊給我 |
|
malanlk
尊榮會員 發表:20 回覆:694 積分:577 註冊:2004-04-19 發送簡訊給我 |
http://www.delphi32.com/info_facts/faq/faq_88.asp Q:I receive error: "DAX Error - Name not unique in this context". How do I resolve this?
A:Set the HandleShared property on your TDatabase component to True. http://bdn.borland.com/article/0,1410,25645,00.html Problem:
My app was working fine, when I went to add some fields into one of my
tables. When I try to add the fields using the field editor, I get an error
message stating 'Name is not unique in this context'. What happened? Solution:
The information in this document is relevant to all versions of C Builder and Delphi. The error, 'Name is not unique in this context' means there's already a component
(field or otherwise) on the form with the same name. One instance where this error can occur is if you have a form that is descended from another form.
If you create the field on the parent form, then try to explicitly add the field to the child
form as well, rather than inheriting it, this error can occur. http://delphi.ktop.com.tw/quicksearch.exe/quicksearch?SearchStr=Name is not unique in this context http://delphi.ktop.com.tw/topic.php?TOPIC_ID=21064
http://delphi.ktop.com.tw/topic.php?TOPIC_ID=23604
http://delphi.ktop.com.tw/topic.php?topic_id=28655
|
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |