FindComponent Problem |
尚未結案
|
BorlandUser
中階會員 ![]() ![]() ![]() 發表:148 回覆:217 積分:73 註冊:2004-02-19 發送簡訊給我 |
小弟想寫一個common的function去處理每張form都可能存在的control,如每張form會有一個"newbutton" 我的寫法是... Procedure SetForm(MainForm: TForm);
Begin
With MainForm Do
Begin
TBitBtn(FindComponent('NewButton')).Visible := True;
TBitBtn(FindComponent('SearchButton')).Visible := True;
TBitBtn(FindComponent('AmendButton')).Visible := True;
TBitBtn(FindComponent('DeleteButton')).Visible := True;
TBitBtn(FindComponent('PrintButton')).Visible := True;
TBitBtn(FindComponent('ExportButton')).Visible := True;
End;
End; 大約如是,但當我run到findcomponent時,就出現error,好像是memory access 問題,但為什麼呢?我pass的parameter是form,理應可以指到的...why? 還有,如果在某一張form沒有這樣的元件,那會否出現錯誤呢?
|
hagar
版主 ![]() ![]() ![]() ![]() ![]() ![]() 發表:143 回覆:4056 積分:4445 註冊:2002-04-14 發送簡訊給我 |
Procedure SetForm(MainForm: TForm); Begin With MainForm Do Begin if FindComponent('NewButton') <> nil then TBitBtn(FindComponent('NewButton')).Visible := True; if FindComponent('SearchButton') <> nil then TBitBtn(FindComponent('SearchButton')).Visible := True; if FindComponent('AmendButton') <> nil then TBitBtn(FindComponent('AmendButton')).Visible := True; if FindComponent('DeleteButton') <> nil then TBitBtn(FindComponent('DeleteButton')).Visible := True; if FindComponent('PrintButton') <> nil then TBitBtn(FindComponent('PrintButton')).Visible := True; if FindComponent('ExportButton') <> nil then TBitBtn(FindComponent('ExportButton')).Visible := True; End; End; |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |