Dual Monitor issue

Please discuss general Delphi programming topics here.

Dual Monitor issue

Postby kishor » February 2nd, 2017, 7:04 am

I have a Windows application in Delphi 5.

I have two monitors. When my application runs, the parent is displayed on the first monitor. When I move the parent window to the second monitor and click a button, this child window stays on the first monitor. Is there a way to make the child window stay with the parent window no matter where the parent window is located? I searched related to this but solution is in C# not in Delphi, I am very new in Delphi. Child forms are creating at run time.


My code:

procedure TSmForm.AfterCreateForm(Session:ISmSession; SmHelpContext:TDM_Int32; IsDLL: boolean);
begin

if SmSession<>Session then
SmSession:= Session;
if SmHelpContext > 0 then
HelpContext:=SmHelpContext;

if (IsDLL) then
begin
if (Icon.Empty) and (ParentHWND <> 0) then
SendMessage(Handle, WM_SETICON, 1, SendMessage(ParentHWND, WM_GETICON, 1, 0));
end;
end { of TSmForm.AfterCreateForm } ;


constructor TSmForm.Create(AOwner: TComponent;Session:ISmSession;SmHelpContext:TDM_Int32);
var
IsDLL: Boolean;
begin
ParentHWND:=BeforeCreateForm(Session, IsDLL);
HelpContext := 0;
SmSession:= Session;
inherited Create(AOwner);
AfterCreateForm(Session,SmHelpContext, IsDLL);
end;



procedure TSmForm.CreateParams(var Params: TCreateParams);

var
SmGuiServices: ISmGuiServices;
MDIChild : TIMDIChildForm;
MultiTabType :TDM_Int16;
I:Integer;

begin
inherited CreateParams(Params);
if ParentHWND <> 0 then
begin
Params.WndParent:=ParentHWND;

SmGUIServices := (SmSession.Services.Item[TDM_SmarTeamServices[srvSmGUIService]] as ISmGUIServices);
for I := SmGUIServices.SmViewWindows.Count - 1 downto 0 do
begin
if(SmGUIServices.SmViewWindows.item[I].SmView<>nil) then
if(SmGUIServices.SmViewWindows.item[I].SmView.ViewType <> vwtBomView) then
begin
MDIChild := TIMDIChildForm((SmGUIServices.SmViewWindows.item[I] as ISmRawViewWindow).SmViewWindowHandle);

MultiTabType:=GetMultiTabType( MDIChild.tabSmView, MDIChild.tabSmView.ActivePage.PageIndex);

if UpperCase(SmSession.ApplicationName) = 'MYAPP' then
(MDIChild.MDIViewer.ViewerType = 10))) then

begin

// Params.ExStyle := Params.ExStyle or WS_EX_TOPMOST;
Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
Params.WndParent := GetDesktopWindow;


exit;
end

else
begin
if (MultiTabType = MT_Viewer) then
begin
Params.ExStyle := Params.ExStyle or WS_EX_TOPMOST;
exit;
end;
end;

end;
end;
end;
end;
kishor
Member
Member
 
Posts: 1
Joined: February 2nd, 2017, 6:53 am

Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 2 guests

cron