请教:有关模式窗体的问题(50分)

  • 主题发起人 主题发起人 base7
  • 开始时间 开始时间
B

base7

Unregistered / Unconfirmed
GUEST, unregistred user!
众所周知,显示模式窗体的函数:showmodal是一个带返回参数的函数,
程序执行到这一步后暂停,窗体返回的结果将影响下面的过程
请教,如何写一个函数,让它具有模式窗体的特性,但是在窗体显示的时候
代码将接着往下执行(有点像form.show,然后让窗体的style:=fsAlwaysOnTop的味道)
附上ShowModal的代码供参考:
代码:
function TCustomForm.ShowModal: Integer;
var
  WindowList: Pointer;
  SaveFocusCount: Integer;
  SaveCursor: TCursor;
  SaveCount: Integer;
  ActiveWindow: HWnd;
begin
  CancelDrag;
  if Visible or not Enabled or (fsModal in FFormState) or
    (FormStyle = fsMDIChild) then
    raise EInvalidOperation.Create(SCannotShowModal);
  if GetCapture <> 0 then
    SendMessage(GetCapture, WM_CANCELMODE, 0, 0);
  ReleaseCapture;
  Include(FFormState, fsModal);
  ActiveWindow := GetActiveWindow;
  SaveFocusCount := FocusCount;
  Screen.FSaveFocusedList.Insert(0, Screen.FFocusedForm);
  Screen.FFocusedForm := Self;
  SaveCursor := Screen.Cursor;
  Screen.Cursor := crDefault;
  SaveCount := Screen.FCursorCount;
  WindowList := DisableTaskWindows(0);
  try
    Show;
    try
      SendMessage(Handle, CM_ACTIVATE, 0, 0);
      ModalResult := 0;
      repeat
        Application.HandleMessage;
        if Application.FTerminate then
          ModalResult := mrCancel
        else if ModalResult <> 0 then
          CloseModal;
      until ModalResult <> 0;
      Result := ModalResult;
      SendMessage(Handle, CM_DEACTIVATE, 0, 0);
      if GetActiveWindow <> Handle then
        ActiveWindow := 0;
    finally
      Hide;
    end;
  finally
    if Screen.FCursorCount = SaveCount then
      Screen.Cursor := SaveCursor
    else
      Screen.Cursor := crDefault;
    EnableTaskWindows(WindowList);
    if Screen.FSaveFocusedList.Count > 0 then
    begin
      Screen.FFocusedForm := Screen.FSaveFocusedList.First;
      Screen.FSaveFocusedList.Remove(Screen.FFocusedForm);
    end
    else
      Screen.FFocusedForm := nil;
    if ActiveWindow <> 0 then
      SetActiveWindow(ActiveWindow);
    FocusCount := SaveFocusCount;
    Exclude(FFormState, fsModal);
  end;
end;

 
不是吧,怎么又没人理我[:(]
 
如果你有问题,DisableTaskWindows不就可以解决了吗?
 
要想实现你的功能,恐怕有点难度
 
如果这样那你干嘛不直接用SHOW,设置BORDERSTYLE属性为BSDIALOG啊?
 
http://www.delphibbs.com/delphibbs/dispq.asp?lid=971527
 
接受答案了.
 
后退
顶部