Re: [Lazarus] MDI - working implementation !?

2014-10-26 Thread Herwig Niemeyer

I provided a patch now. Hope all is ok because this is my first time to work in the community.

Now that I have built a testing-program (depending on built-in MDI methods or using a patched customform.inc) to check all the possibilities i can think of, it shows that inside the main/MDI form there are problems to get the correct zOrder. Therefore the function activeMDIChild does not work correctly. ( In my old Delphi-program i used MDIForm outside the main Form)


Link to my testprogram: https://dl.dropboxusercontent.com/u/24228536/projectMDITest.zip



Herwig




Gesendet:Sonntag, 26. Oktober 2014 um 08:18 Uhr
Von:zeljko zel...@holobit.net
An:Lazarus mailing list lazarus@lists.lazarus.freepascal.org
Betreff:Re: [Lazarus] MDI - working implementation !?

On 10/26/2014 02:57 AM, Kostas Michalopoulos wrote:
 Very interesting, i was actually looking into implementing MDI (for
 Windows... AFAIK the Qt backend already has MDI support).

 Although from a quick look at the code, it doesnt seem to do that, does
 it? It looks like it only checks the form type, but still the forms are
 top level, not under an MDI client window inside the main/MDI form.

Thats why I said to Herwig to provide patch. Let we see what it does.
But IMO, win32 need ws implementation, part where mdiarea must be
created and also mdichild handle.

zeljko


 On Sat, Oct 25, 2014 at 10:25 AM, zeljko zel...@holobit.net
 mailto:zel...@holobit.net wrote:

 On 10/24/2014 02:03 PM, Herwig Niemeyer wrote:

 On transcribing an old Delphi-Program to a Lazarus-program i was
 in need
 do have working MDI-functions.
 I tried to implement them in customform.inc and they work fine
 with my
 program and in my environment.
 There are still some problematic spots in the code and i would
 appreciate comments/solutions for them.
 regards


 Please, learn howto make patch, open an issue about it at lazarus
 bug tracker and attach patch.
 Ill commit it after review. btw. what is your environment ?
 widgetset ? OS ?

 zeljko


 --
 _
 Lazarus mailing list
 Lazarus@lists.lazarus.__freepascal.org
 mailto:Lazarus@lists.lazarus.freepascal.org
 http://lists.lazarus.__freepascal.org/mailman/__listinfo/lazarus
 http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus




 --
 ___
 Lazarus mailing list
 Lazarus@lists.lazarus.freepascal.org
 http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus



--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus




--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] MDI - working implementation !?

2014-10-26 Thread Herwig Niemeyer

I hope, i found a workaround to the problems with MDIChildren in a MainForm/MDIForm. In my testprogram it looks all okay to me.

But before i load up another patch perhaps someone does his/her own tests to make sure all is working fine.



https://dl.dropboxusercontent.com/u/24228536/projectMDIText.zip



Herwig





--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] MDI - working implementation !?

2014-10-24 Thread Herwig Niemeyer
On transcribing an old Delphi-Program to a Lazarus-program i was in need do have working MDI-functions.
I tried to implement them in customform.inc and they work fine with my program and in my environment.
There are still some problematic spots in the code and i would appreciate comments/solutions for them.



regards

H. Niemeyer{--
  Method:  TCustomForm.ActiveMDIChild
  Params:  None
  Returns: Nothing

  Returns currently active MDI child form of self.
  Valid result is returned only when Self FormStyle = fsMDIForm or fsMDIChild,
  otherwise Result is nil.
 --}
function TCustomForm.ActiveMDIChild: TCustomForm;
var actMdiChild : TCustomForm;
k   : integer;
begin
  Result := nil;
(*  if not (FormStyle in [fsMDIForm, fsMDIChild]) then
exit;
  if HandleAllocated and not (csDesigning in ComponentState) then
Result := TWSCustomFormClass(WidgetSetClass).ActiveMDIChild(Self);   *)

  if (csDesigning in ComponentState) or not(FormStyle in [fsMDIForm, fsMDIChild]) then
exit;
  if HandleAllocated then
Result := TWSCustomFormClass(WidgetSetClass).ActiveMDIChild(Self);

  if Result=nil then
begin
  k := 0;
  while (kScreen.CustomFormZOrderCount) and (result=nil) do
begin
  actMdiChild:=Screen.CustomFormsZOrdered[k];
  if (actMdiChild.Owner=self) and  actMdiChild.Visible
 and (actMdiChild.FormStyle in [fsMDIForm, fsMDIChild])
then result:=actMdiChild
else k:=k+1
end;
end;
end;

{--
  Method:  TCustomForm.MDIChildCount
  Params:  None
  Returns: Nothing

  Returns count of MDIChild forms.
  Result is returned only when Self FormStyle = fsMDIForm or fsMDIChild (can
  be 0 ... number of mdichild forms).
  If Result is -1 then caller isn't mdi or handle is not allocated.
 --}
function TCustomForm.MDIChildCount: Integer;
var k : integer;
begin
  Result := -1;
(*  if not (FormStyle in [fsMDIForm, fsMDIChild]) then
exit;
  if HandleAllocated and not (csDesigning in ComponentState) then
Result := TWSCustomFormClass(WidgetSetClass).MDIChildCount(Self); *)

  if (csDesigning in ComponentState) or not(FormStyle in [fsMDIForm, fsMDIChild]) then
exit;
  if HandleAllocated then
Result := TWSCustomFormClass(WidgetSetClass).MDIChildCount(Self)
else Result:=0;
  if Result = 0 then
begin
  for k := 0 to ComponentCount-1 do
if (Components[k] is TCustomForm) and (TCustomForm(Components[k]).FormStyle in [fsMDIForm, fsMDIChild])
   then result:=result+1;
end;
end;


{--
  Method:  TCustomForm.GetMDIChildren
  Params:  AIndex: Integer;
  Returns: TCustomForm with FormStyle = fsMDIChild

  Returns MDI child (fsMDIChild) of parent mdi form (fsMDIForm) at index
  AIndex in list of mdi children.
  Result can be nil if caller isn't an mdi type or handle isn't allocated.
 --}
function TCustomForm.GetMDIChildren(AIndex: Integer): TCustomForm;
var k, index : integer;
begin
  Result := nil;
(*  if not (FormStyle in [fsMDIForm, fsMDIChild]) then
exit;
  if HandleAllocated and not (csDesigning in ComponentState) then
Result := TWSCustomFormClass(WidgetSetClass).GetMDIChildren(Self, AIndex); *)

  if (csDesigning in ComponentState) or not(FormStyle in [fsMDIForm, fsMDIChild]) then
exit;
  if HandleAllocated then
Result := TWSCustomFormClass(WidgetSetClass).GetMDIChildren(Self, AIndex);
  if Result = nil then
begin
  k := -1;  index := -1;
  While (kComponentCount-1) and (indexAIndex) do
   begin
 k := k+1;
 if (Components[k] is TCustomForm) and (TCustomForm(Components[k]).FormStyle in [fsMDIForm, fsMDIChild]) then index:=index+1;
   end;
  if (kComponentCount) and (index = AIndex) then result := TCustomForm(Components[k]);
end;
end;


// Boundsrect gives values for inner size. Setting Boundsrect produces a form with bigger size because of frame size.
// Is there a function returning those sizes?
// Following values are experimental. Don't know if they are correct for other monitors or OSs

const defaultFormBorderSize = 8;
  defaultFormCaptionSize = 22;


{--
  Method: TForm.Cascade
  Params:  None
  Returns: Nothing

  Arranges MDI child forms so they overlap.
  Use Cascade to arrange MDI child forms so they overlap.
  Cascade works only if the form is an MDI parent form (FormStyle=fsMDIForm).
 --}
procedure TForm.Cascade;
const