在MDI主窗口中放入TPanel控件,当打开子窗口时,Panel为什么总是浮动在最前面

解决方案 »

  1.   

    嘿嘿,正好我今天看到,贴给你。unit SysFocus;interfaceusesWindows,Messages,SysUtils,Classes,Graphics,Controls,Forms,Dialogs;typeTSysFocus=class(TComponent)publicfunction GetSysFocus:integer;function SetSysFocus(hwnd:integer):integer;end;implementationfunction TSysFoucs.GetSysFocus;//取当前活动窗口varhOtherWin,OtherThreadID,hFocusWin:integer;beginhOtherWin:=GetForegroundWindow;OtherThreadID:=GetWindowThreadProcessID(hOtherWin,nil);if AttachThreadInput(GetcurrentThreadID,OtherThreadID,True) thenbeginhFocusWin:=GetFocus;result:=GetFocus;if HFocusWin<>0 thentry//SendMessage(GetFocus,WM_COPY,0,0);//书上是这么写的finallyAttachThreadInput(GetcurrentThreadID,OtherThreadID,False);end;endelse result:=GetFocus;end;function TSysFocus.SetSysFocus(hwnd:integer):integer;//设置某窗口为活动窗口varhOtherWin,OtherTHreadID,hFocusWin:integer;beginhOtherWin:=GetForegroundWindow;OtherThreadID:=GetWindowThreadProcessID(hOtherWin,nil);if AttachThreadInput(GetcurrentThreadID,OtherThreadID,True) thenbeginhFocusWin:=GetFocus;SetFocus(hwnd);//SendMessage(hwnd,WM_COPY,0,0);if hFocusWin<>0 thentry//SendMessage(GetFocus,WM_COPY,0,0);finallyAttachThreadInput(GetCurrentTHreadID,OtherTHreadID,False);end;endelse result:=SetFocus(hwnd);end;end.
      

  2.   

    在打开子窗口前把 Panel 隐藏掉
      

  3.   

    ywhbn(天涯)的做法比较简单,管用, 高手
      

  4.   

    Delphi开发指南中有下关于设置一个窗体的Parent为Panel的。
      

  5.   

    隐藏的办法并不好,因为子窗口未必总是处于最大化状态,当用户移动子窗口时,却看不到那个PANEL了,这让人觉得很是莫名其妙。不过很抱歉,我也想不出一个真正的解决办法,我现在用的也是让它隐藏。
      

  6.   

    好像说过这个问题啦吧?!?!?!
    MDI主窗体的子窗体区域内是不能放别的控件的你想干吗呢???
    不了解你的目的, 很难找到好的答案……
      

  7.   

    谁说MDI主窗体中子窗体区域不能放别的控件?
    我的程序就在主窗体中放了一个Timage来美化界面,并且打开子窗体没有显示问题
      

  8.   

    //try
    procedure TForm1.FormCreate(Sender: TObject);
    begin
      Panel1.Anchors := [akLeft..akBottom];
      Panel1.Enabled := False;
      Panel1.BorderStyle := bsNone;
      Windows.SetParent(Panel1.Handle, ClientHandle);
      Panel1.Left := 0;
      Panel1.Top := 0;
      Panel1.Width := ClientWidth - 4;
      Panel1.Height := ClientHeight - 4;
    end;
      

  9.   

    你可以将pannel隐藏,在子窗体移动事件里写代码让pannel触发,不就行了。
      

  10.   

    zswangII(伴水清清)(职业清洁工)是对的,万分感谢!
    其他思路都太偏了。