2011-10-02 6 views
1

나는 나사로에 두 가지 형태가 있습니다. 하나는 frmMain이고 다른 하나는 frmSub1입니다. 둘 다 텍스트 상자가 있습니다.나사로 - 왜 이것이 ShowModal과 호환되지 않습니까?

다음 코드가 작동합니다. 즉, frmMain 수에 값

procedure TfrmMain.cmdShowClick(Sender: TObject); 
begin 
    frmSub1.Show ; 
    frmSub1.txtAns.text := txtMark.Text; 
end; 

을 버튼을 클릭하지만 .ShowModal와 .Show를 교체 할 때, 그것은 양식을 표시하지만 frmSub1.txtAns에가 비어 있습니다.

왜 그렇게 생각하십니까?

답변

2

그 이유는 ShowModal 호출을 차단하기 때문입니다. 즉, frmSub1.txtAns.text := txtMark.Text;은 반환 될 때까지 실행되지 않습니다. 문의 순서를 변경해야하며 다음과 같이 작동해야합니다.

procedure TfrmMain.cmdShowClick(Sender: TObject); 
begin 
    frmSub1.txtAns.text := txtMark.Text; 
    frmSub1.ShowModal; 
end; 
관련 문제