一个Form,在右上角的关闭按钮被按下时,执行的代码是什么??需要实现一个“退出”按钮的功能。                        
还有,现有一个Form,里面一个menu,还有一个frame,如何在menu的onclick中把frame加入到form中??这是为了实现一般的那些菜单的“新建”、“打印”等的功能,在按下这些按钮时把所有东西清除,然后把一个frame拖到form当中。不知有无其它更好的办法。                                      
我是delphi盲,现被迫要使用。-_-

解决方案 »

  1.   

    1.  OnCloseQuery    OnClose
    2. InsertControl(yourframe);
      

  2.   

    1.  OnCloseQuery    OnClose
    2. InsertControl(yourframe);
      

  3.   

    OnCloseQuery事件
    CanClose := true;
      

  4.   

    重新捕获Wm_SysCommand消息,并判断参数SC_CLOSE来定义关闭按钮的单击动作。procedure TForm1.WmSysCommand(var Msg:TMessage);message WM_SYSCOMMAND;
    begin
      if wParam=SC_CLOSE then
        if MessageDlg('是否要退出?',mtConfirmation,[mbYes,mbNo],0)=mrYes then
          Inherited;
    end;
      

  5.   

    procedure TForm1.FormCloseQuery(Sender: TObject;
      var CanClose: Boolean);
    begin
      if MessageBox(Application.Handle, '确定要退出吗?', '提示', MB_YESNO or MB_ICONQUESTION) = IDYES then
        CanClose := True
      else
        CanClose := False;
    end;
      

  6.   

    RemoveControl(Frame1);移除
    InsertControl(Frame1);加入
      

  7.   

    FrameSniper 的方法很好 第二个问题 不太明白你的意思 
    再说得详细一点