这个是ShowModal的源代码,如果激活的时候能够让后面的主窗体有效,就好了<br>你改改了。代替你的SHOW;<br>function TCustomForm.ShowModal: Integer;<br>var<br> WindowList: Pointer;<br> SaveFocusCount: Integer;<br> SaveCursor: TCursor;<br> SaveCount: Integer;<br> ActiveWindow: HWnd;<br>begin<br> CancelDrag;<br> if Visible or not Enabled or (fsModal in FFormState) or<br> (FormStyle = fsMDIChild) then<br> raise EInvalidOperation.Create(SCannotShowModal);<br> if GetCapture <> 0 then SendMessage(GetCapture, WM_CANCELMODE, 0, 0);<br> ReleaseCapture;<br> Include(FFormState, fsModal);<br> ActiveWindow := GetActiveWindow;<br> SaveFocusCount := FocusCount;<br> Screen.FSaveFocusedList.Insert(0, Screen.FFocusedForm);<br> Screen.FFocusedForm := Self;<br> SaveCursor := Screen.Cursor;<br> Screen.Cursor := crDefault;<br> SaveCount := Screen.FCursorCount;<br> WindowList := DisableTaskWindows(0);<br> try<br> Show;<br> try<br> SendMessage(Handle, CM_ACTIVATE, 0, 0);<br> ModalResult := 0;<br> repeat<br> Application.HandleMessage;<br> if Application.FTerminate then ModalResult := mrCancel else<br> if ModalResult <> 0 then CloseModal;<br> until ModalResult <> 0;<br> Result := ModalResult;<br> SendMessage(Handle, CM_DEACTIVATE, 0, 0);<br> if GetActiveWindow <> Handle then ActiveWindow := 0;<br> finally<br> Hide;<br> end;<br> finally<br> if Screen.FCursorCount = SaveCount then<br> Screen.Cursor := SaveCursor<br> else Screen.Cursor := crDefault;<br> EnableTaskWindows(WindowList);<br> if Screen.FSaveFocusedList.Count > 0 then<br> begin<br> Screen.FFocusedForm := Screen.FSaveFocusedList.First;<br> Screen.FSaveFocusedList.Remove(Screen.FFocusedForm);<br> end else Screen.FFocusedForm := nil;<br> if ActiveWindow <> 0 then SetActiveWindow(ActiveWindow);//更换激活窗体<br> FocusCount := SaveFocusCount;<br> Exclude(FFormState, fsModal);<br> end;<br>end;