Recent

Author Topic: Problem with form to be called with ShowModal  (Read 8840 times)

Ever

  • Jr. Member
  • **
  • Posts: 61
Problem with form to be called with ShowModal
« on: February 24, 2016, 03:24:57 am »
Hello friends

    This is my first topic, not fluent in English so I written here is translated by Google Translate.

    I present the following problem. I have two forms called form1 and form2, form2 is called by ShowModal from form1, but for reasons not understood achievement by showing the form2 the first (form1) disappears from the screen. This behavior did not have it with version 1.4.4 but after upgrading to version 1.6.0 began presenting this problem.

    Thanks in advance for any suggestions they can provide.

balazsszekely

  • Guest
Re: Problem with form to be called with ShowModal
« Reply #1 on: February 24, 2016, 05:30:00 am »
Please attach a zipped demo application which demonstrates the problem(source only!).

Ever

  • Jr. Member
  • **
  • Posts: 61
Re: Problem with form to be called with ShowModal
« Reply #2 on: February 24, 2016, 12:52:59 pm »
Thank you, including small project that demonstrates the behavior

balazsszekely

  • Guest
Re: Problem with form to be called with ShowModal
« Reply #3 on: February 24, 2016, 01:13:16 pm »
Tested both under win32/64 and gtk2(Lazarus trunk/fpc 3.0.0,). I cannot reproduce.
https://youtu.be/V4XhZm5vmn4

zeljko

  • Hero Member
  • *****
  • Posts: 1596
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: Problem with form to be called with ShowModal
« Reply #4 on: February 24, 2016, 01:18:15 pm »
@everjdelgadoch, what operating system and widgetset do you use ? Is it virtual or regular machine ?

balazsszekely

  • Guest
Re: Problem with form to be called with ShowModal
« Reply #5 on: February 24, 2016, 01:21:00 pm »
Works under OSX too. It must be raspberry pi. :D

frakno

  • Jr. Member
  • **
  • Posts: 88
Re: Problem with form to be called with ShowModal
« Reply #6 on: February 24, 2016, 01:32:46 pm »
It is obviously a windows problem because I can reproduce it.

I will look around in my files I think I've got a solution. if I find it I'll post it immediately

Lazarus 1.6 FPC 3.0 Windows 10

frakno

  • Jr. Member
  • **
  • Posts: 88
Re: Problem with form to be called with ShowModal
« Reply #7 on: February 24, 2016, 01:46:53 pm »
Put into your Unit2

section uses   ..., LCLType, Windows;

 type
  { TForm2 }
  TForm2 = class(TForm) ...

  protected
      procedure CreateParams(var params: TCreateParams);override;


and in the implementation

procedure TForm2.CreateParams(var Params: TCreateParams);
begin
  inherited CreateParams(params);
  Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
  Params.WndParent := GetDesktopWindow;
end; 


and problem should be solved

Lazarus 1.6 FPC 3.0 Windows 10

Noodly

  • Jr. Member
  • **
  • Posts: 70
Re: Problem with form to be called with ShowModal
« Reply #8 on: February 24, 2016, 02:02:18 pm »
Assign form1 as the popupparent of form2 before you showmodal:

    form2.PopupParent:=Form1;
Windows 10 Home, Lazarus 2.02 (svn 60954), FPC 3.04

balazsszekely

  • Guest
Re: Problem with form to be called with ShowModal
« Reply #9 on: February 24, 2016, 02:11:10 pm »
@frakno, @Noodly
According to the OP Form1 disappears not Form2. Form2 is not the issue here.

rvk

  • Hero Member
  • *****
  • Posts: 6169
Re: Problem with form to be called with ShowModal
« Reply #10 on: February 24, 2016, 02:21:00 pm »
@frakno, @Noodly
According to the OP Form1 disappears not Form2. Form2 is not the issue here.
Maybe not. But it DOES work !! (I can reproduce this bug here too, Lazarus 1.6/win64)

Maybe it's because when Form1 is assigned to Form2.popup or parent, it will not hide.
But the fact it hides when Form2.ShowModal is called seems like a real bug.

frakno

  • Jr. Member
  • **
  • Posts: 88
Re: Problem with form to be called with ShowModal
« Reply #11 on: February 24, 2016, 02:27:00 pm »
GetMem

To my understanding.
If I run his program Form3 appears, then I press button

-> Form1 appears, and if I press Button call Form2 , then Form 2 appears and  !!! Form1 disappears  !!!

If you try my advice and put my code into unit2  you will see ... that it helps
             
Lazarus 1.6 FPC 3.0 Windows 10

balazsszekely

  • Guest
Re: Problem with form to be called with ShowModal
« Reply #12 on: February 24, 2016, 02:29:34 pm »
Quote
@rvk
I can reproduce this bug here too, Lazarus 1.6/win64
Can you please test it with trunk? Because Ondrej worked lately with some similar issues, maybe he fixed already. I only tested with trunk in different OS, the bug is not present.

@frakno
I'm not saying is not true, but I wasn't able to reproduce the bug. Anyway this should not happen. If it does, like @rvk said it's a real nasty bug.

rvk

  • Hero Member
  • *****
  • Posts: 6169
Re: Problem with form to be called with ShowModal
« Reply #13 on: February 24, 2016, 02:35:13 pm »
Can you please test it with trunk? Because Ondrej worked lately with some similar issues, maybe it's fixed already. I only tested with trunk in different OS, the bug is not present.
Trunk works fine.

I also see what's happening now... (Form3 is main, Form1 is second form and Form2 is modal form)
When Form2 is shown modal then Form3 (mainform) is put in front of Form1 (which makes it not visible anymore). If you move the windows (form3) at the start of the program you can see that Form1 stays visible. It has something to do with the SetZOrder() in TControl.BringToFront where Form3 gets put in front of Form1. (see attached image)


balazsszekely

  • Guest
Re: Problem with form to be called with ShowModal
« Reply #14 on: February 24, 2016, 02:43:41 pm »
Quote
@rvk
I also see what's happening now... (Form3 is main, Form1 is second form and Form2 is modal form)
When Form2 is shown modal then Form3 (mainform) is put in front of Form1 (which makes it not visible anymore). If you move the windows (form3) at the start of the program you can see that Form1 stays visible. It has something to do with the SetZOrder() in TControl.BringToFront where Form3 gets put in front of Form1. (see attached image)
Oh,  I see now! I wasn't paying attention which is the main form, because everything worked fine. Since it's already fixed in the trunk, there is nothing we can do.

 

TinyPortal © 2005-2018