我在一个用ShowModal打开一个Form,在Form中我把ModalResult赋值1,可是当我关闭From后,ShowModal返回的老是2,这是为什么啊!帮助上说An application can use any integer value as a modal result value. 可是返回的怎么和赋值的不一样呢?Note: This property is modified automatically by some components such as the TButton object. 这句话怎么理解。怎么TButton 控件可以修改ModalResult属性呢?明白的高人帮我说说ModalResult的用法吧!!!

解决方案 »

  1.   

    一般将返回用的作为OK和cancel的button的modelresult属性设为mrOK和mrCancel,这样当点击这些按钮时,窗体会自动返回model值,或者在某个button的click事件中用ModelResult:=mrOK;强行赋值,如果是按窗体右上角的叉退出的,则返回时mrCancel,
    在外部程序中判断modelresult为mrCancel或mrOK,或其它值就可以了。
      

  2.   

    2 = mrCancel .你在什么地方赋值 为1,又是如何退出的呢
      

  3.   

    Self.modalResult := mrOk / mrCancel;