多屏开发的备忘
1. dll里面的form显示位置问题
需要显示在主程序窗口的屏幕上,可以用下面的方法放到 TForm里面的FormActivate事件里面
var
HM: HMonitor;
I: Integer;
LRect: TRect;
Begin
{$IFDEF STATIC_ADDIN}
HM := MonitorFromWindow(FContext.MasterPageHandle, MONITOR_DEFAULTTONEAREST);
if HM > 0 then
begin
for I := 0 to Screen.MonitorCount - 1 do
if Screen.Monitors[I].Handle = HM then
begin
LRect := Screen.Monitors[I].WorkareaRect;
SetBounds(LRect.Left + ((RectWidth(LRect) - Width) div 2),
LRect.Top + ((RectHeight(LRect) - Height) div 2), Width, Height);
Break;
end;
end;
{$ENDIF}
end;
HM: HMonitor;
I: Integer;
LRect: TRect;
Begin
{$IFDEF STATIC_ADDIN}
HM := MonitorFromWindow(FContext.MasterPageHandle, MONITOR_DEFAULTTONEAREST);
if HM > 0 then
begin
for I := 0 to Screen.MonitorCount - 1 do
if Screen.Monitors[I].Handle = HM then
begin
LRect := Screen.Monitors[I].WorkareaRect;
SetBounds(LRect.Left + ((RectWidth(LRect) - Width) div 2),
LRect.Top + ((RectHeight(LRect) - Height) div 2), Width, Height);
Break;
end;
end;
{$ENDIF}
end;
也可以直接跟着主程序的窗体走,直接在Formshow里面加
Left := FContext.MainForm.Left;
Top := FContext.MainForm.Top;
Top := FContext.MainForm.Top;