BPL方式是特殊的DLL,Delphi已经处理好VCL组件了,我记得静态引用没问题的,动态加载是否需要更多处理则不太确定。 我有一段代码,工作中用的,似乎还行,你把它赋给Application.OnActivate事件试试: procedure TForm1.AppActivate(Sender: TObject); var fActive: TForm; hActive: THandle; hTopMost: THandle; i: Integer; begin fActive := Screen.ActiveForm; //If the current window is the main window and is disabled, the next visible // window will be obtained, that is, the modal window or the window displaying // the modal dialog box if Assigned(fActive) and not IsWindowEnabled(fActive.Handle) and (Handle = fActive.Handle) and (Screen.FormCount > 1) then begin //get next visible form (may be modal state) for i := 1 to Screen.FormCount -1 do begin if Screen.Forms[i].Visible then begin fActive := Screen.Forms[i]; Break; end; end; end;
hActive := GetActiveWindow; // fsModal in fActive.FormState : For Modal form // not IsWindowEnabled(hActive) : For Dialogs (Modal state) // GetAncestor(Handle, GA_PARENT) = GetDesktopWindow : For "Params.WndParent := GetDesktopWindow" if Assigned(fActive) and ((fsModal in fActive.FormState) or not IsWindowEnabled(hActive)) then begin if (hActive <> fActive.Handle) and (Application.MainFormOnTaskbar or (hActive <> Self.Handle) or (GetAncestor(Handle, GA_PARENT) = GetDesktopWindow)) then begin fActive.BringToFront; if not IsWindowEnabled(fActive.Handle) then begin SetForegroundWindow(FindTopMostWindow(fActive.Handle)); end; end else if (hActive = fActive.Handle) and IsWindowEnabled(hActive) then begin //Handles the case that the child Modal window pops up from the Modal // window and the previous parent window can still be edited after // switching through the taskbar icon (windows aero peek). hTopMost := FindTopMostWindow(fActive.Handle); if (hTopMost <> 0) and (hTopMost <> hActive) and IsWindowEnabled(hTopMost) then SetForegroundWindow(hTopMost); end; end; end;
----------------------------------------------
-广袤璀璨的银河,永无止境的梦想(梦无止境游银河) 博客挂了……