We we did it
okay.
To get it to work
okay, we had to make many changes to the Forms unit - in particular
TApplication & TScreen.
eg
Stuff
like
procedure
TSDIForm.CreateParams(var Params: TCreateParams);
begin
inherited;
if Application.SDIApplication then begin
with Params do begin
ExStyle := ExStyle or WS_EX_APPWINDOW;
WndParent := GetDesktopWindow; //not certain we need this now have a similar change in TCustomForm.CreateParam
end;
end;
end;
begin
inherited;
if Application.SDIApplication then begin
with Params do begin
ExStyle := ExStyle or WS_EX_APPWINDOW;
WndParent := GetDesktopWindow; //not certain we need this now have a similar change in TCustomForm.CreateParam
end;
end;
end;
procedure
TApplication.SetSDIApplication(const Value: Boolean);
//Declare a var to retrieve current window information
var
ExtendedStyle : Integer;
begin
if (FSDIApplication <> Value) then begin;
FSDIApplication := Value;
//Get the Extended Styles of the Application, by passing its
//handle to GetWindowLong
ExtendedStyle := GetWindowLong(Application.Handle, GWL_EXSTYLE);
if Value then begin
//Declare a var to retrieve current window information
var
ExtendedStyle : Integer;
begin
if (FSDIApplication <> Value) then begin;
FSDIApplication := Value;
//Get the Extended Styles of the Application, by passing its
//handle to GetWindowLong
ExtendedStyle := GetWindowLong(Application.Handle, GWL_EXSTYLE);
if Value then begin
//Now, set the Extended
Style by doing a bit masking operation.
//OR in the WS_EX_TOOLWINDOW bit, and AND out the WS_EXAPPWINDOW bit
//This effectively converts the application from an App Windows to a
//Tool Window. It also means that this window handle cannot be used as the parent of
//any windows, else Alt-Tab will not work correctly.
SetWindowLong( Handle, GWL_EXSTYLE, ExtendedStyle OR WS_EX_TOOLWINDOW AND NOT WS_EX_APPWINDOW);
end else begin
SetWindowLong( Handle, GWL_EXSTYLE, ExtendedStyle AND NOT WS_EX_TOOLWINDOW OR WS_EX_APPWINDOW);
end;
end;
end;
//OR in the WS_EX_TOOLWINDOW bit, and AND out the WS_EXAPPWINDOW bit
//This effectively converts the application from an App Windows to a
//Tool Window. It also means that this window handle cannot be used as the parent of
//any windows, else Alt-Tab will not work correctly.
SetWindowLong( Handle, GWL_EXSTYLE, ExtendedStyle OR WS_EX_TOOLWINDOW AND NOT WS_EX_APPWINDOW);
end else begin
SetWindowLong( Handle, GWL_EXSTYLE, ExtendedStyle AND NOT WS_EX_TOOLWINDOW OR WS_EX_APPWINDOW);
end;
end;
end;
In the process I
found this piece of code, which I think is responsible for the issue with modal
windows going into the background. The line of intrest is the assignment of the
Application.Handle to the WndParent, when no parent has been defined for a
control ie Typical modal window issue. I suspect if this was
application.mainform.handle, then the issue might go away. In our case we had to
change this to be the Screen.ActiveSDIForm.handle (one of our new properties
etc).
procedure TCustomForm.CreateParams(var Params:
TCreateParams);
var
Icons: TBorderIcons;
CreateStyle: TFormBorderStyle;
begin
inherited CreateParams(Params);
InitAlphaBlending(Params);
with Params do
begin
if (Parent = nil) and (ParentWindow = 0) then
begin
WndParent := Application.Handle;
end;
Style := Style and not (WS_CHILD or WS_GROUP or WS_TABSTOP);
var
Icons: TBorderIcons;
CreateStyle: TFormBorderStyle;
begin
inherited CreateParams(Params);
InitAlphaBlending(Params);
with Params do
begin
if (Parent = nil) and (ParentWindow = 0) then
begin
WndParent := Application.Handle;
end;
Style := Style and not (WS_CHILD or WS_GROUP or WS_TABSTOP);
Other issues
center around that TApplication.Mainform has to change - as the original main
form can be closed. Also you cannot have any design time references to your main
forms eg ImageLists etc. We had to move these onto their own form that is
created once and never destroyed. Similar issues with actions - we now have our
own action classes for everthing on the main form.
Myles
_______________________________________________ Delphi mailing list [EMAIL PROTECTED] http://ns3.123.co.nz/mailman/listinfo/delphi
