* * *

Author Topic: a form always in background and a form on the top... [solved]  (Read 2553 times)

Blue1987

  • Full Member
  • ***
  • Posts: 165
a form always in background and a form on the top... [solved]
« on: August 12, 2012, 12:52:01 pm »
Hi :)

I would like to keep one form as the background of my application, and other forms on the top... is it possible?

i tried with
Code: [Select]
form_background.sendtoback;
form1.bringtofront;
form2.bringtofront;
but it did not worked!!

any suggestion? thank you!!
« Last Edit: August 17, 2012, 01:01:43 am by Blue1987 »

taazz

  • Hero Member
  • *****
  • Posts: 818
Re: a form always in background and a form on the top...
« Reply #1 on: August 12, 2012, 01:44:12 pm »
all forms have 2 properties popupmode & popupparent which you can use for that reason. eg
Code: [Select]
form_background.PopupMode := pmNone;
....
Form1.PopupMode := pmExplicit;
Form1.PopupParent := Form_background;
....
Form2.PopupMode := pmExplicit;
Form2.PopupParent := Form_background;
if form_Background is your application's main form you can just set the poopupMode to pmAuto on all your stay on top forms and this will auto select the main form as popupParent, although I'm not to sure about this your should test it it will make things a bit easier to set up.
OS : Windows 7 32 bit or Windows XP 32 bits
Laz: Lazarus 1.0.6 r40119 FPC 2.6.2 i386-win32-win32/win64
INDY:10.5.8.0...
VTV : 4.8.6 with Extras.

Blue1987

  • Full Member
  • ***
  • Posts: 165
Re: a form always in background and a form on the top...
« Reply #2 on: August 12, 2012, 02:45:19 pm »
ehr...

Code: [Select]
unit main;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
  unit_system, interface_start_menu, interface_bottom_bar, interface_top_bar, interface_licence;

type

  { Tform_main }

  Tform_main = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure show_form(called_form: TForm);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  form_main: Tform_main;
  previous_form, current_form: TForm;

implementation

{$R *.lfm}

{ Tform_main }

procedure Tform_main.show_form(called_form: TForm);
begin
   // update current and previous form.
   previous_form := current_form;
   current_form := called_form;

   // show current form, hide previous;
   previous_form.hide;
   current_form.show;
   current_form.popupparent:=form_main;
   current_form.popupmode:=pmExplicit;

   // show additional forms

end;

procedure Tform_main.FormCreate(Sender: TObject);
begin
  previous_form := form_start_menu;
  current_form := form_licence;
  show_form(form_start_menu);
  form_main.width := screen.width;
  form_main.height := screen.height;



end;



end.
     


this is my code... but it still shows form_main on top, and other forms in the back...


what am I doing wrong??
thank you!

taazz

  • Hero Member
  • *****
  • Posts: 818
Re: a form always in background and a form on the top...
« Reply #3 on: August 12, 2012, 03:05:36 pm »
Well there are a few problems that I can see although I'm not very well versed on the flow of things in lazarus so I'm gonna just point your attention.

1) is Show_form linked to the onformShow event of your form? if yes please unlink it otherwise its called twice.

2) popupMode and popupParent require a window recreation (on windows at least) so it is better to set it once when the form is created and leave it at that, there is not need to change every time the form is shown, better yet set it at design time and forget about it during run time.
 
3) Stop calling show/hide from inside the creator set the visible property if you want just avoid calling those methods, they interrupt the normal flow raising various problems.

regards
OS : Windows 7 32 bit or Windows XP 32 bits
Laz: Lazarus 1.0.6 r40119 FPC 2.6.2 i386-win32-win32/win64
INDY:10.5.8.0...
VTV : 4.8.6 with Extras.

Blue1987

  • Full Member
  • ***
  • Posts: 165
Re: a form always in background and a form on the top...
« Reply #4 on: August 12, 2012, 03:25:02 pm »
Well there are a few problems that I can see although I'm not very well versed on the flow of things in lazarus so I'm gonna just point your attention.

1) is Show_form linked to the onformShow event of your form? if yes please unlink it otherwise its called twice.
no, it is not... I only call it where you see it in the code

2) popupMode and popupParent require a window recreation (on windows at least) so it is better to set it once when the form is created and leave it at that, there is not need to change every time the form is shown, better yet set it at design time and forget about it during run time.
now I am working on linux... in any case, i first tried to set it in the object inspector, but it did not worked... so I tried to do it runtime
 
3) Stop calling show/hide from inside the creator set the visible property if you want just avoid calling those methods, they interrupt the normal flow raising various problems.
I tried changing to form.visible:=true and form.visible:=false but it does not work all the same

regards


I do not understand what is wrong :D
really dunno :)

taazz

  • Hero Member
  • *****
  • Posts: 818
Re: a form always in background and a form on the top...
« Reply #5 on: August 12, 2012, 03:51:37 pm »
now I am working on linux

I'm sorry I have no experience with linux at all I can't help you any farther I'll leave the rest to linux  experts.
OS : Windows 7 32 bit or Windows XP 32 bits
Laz: Lazarus 1.0.6 r40119 FPC 2.6.2 i386-win32-win32/win64
INDY:10.5.8.0...
VTV : 4.8.6 with Extras.

Blue1987

  • Full Member
  • ***
  • Posts: 165
Re: a form always in background and a form on the top...
« Reply #6 on: August 15, 2012, 09:57:46 pm »
up  :-[

mas steindorff

  • Sr. Member
  • ****
  • Posts: 328
Re: a form always in background and a form on the top...
« Reply #7 on: August 16, 2012, 12:56:35 am »
I think what your after is a MDI like interface where frames live on top of a master from.  I have not done this myself but look up MDI and/or perhaps docking to get started.
windows - laz v0.9.30.2RC1 fpc 2.4.4

gulyone

  • Guest
Re: a form always in background and a form on the top...
« Reply #8 on: August 16, 2012, 12:58:51 am »
use form.fromstyle=fsStayonTop and then back to formstyle=fsNormal , it is VERY simple

Blue1987

  • Full Member
  • ***
  • Posts: 165
Re: a form always in background and a form on the top...
« Reply #9 on: August 16, 2012, 01:57:17 am »
use form.fromstyle=fsStayonTop and then back to formstyle=fsNormal , it is VERY simple

this is a very rough solution I am already using... but this is not what I am looking for...
for instance, a third application could be visualized among my form_background and my form1!

I am trying to create something visualized like a single from even if it consists of more different forms...
I will have a look at MDI and docking...

any other suggestion is appreciated!



btw, is it possible that there is no way to simply regulate the z-order of forms?? grrr :D

gulyone

  • Guest
Re: a form always in background and a form on the top...
« Reply #10 on: August 16, 2012, 02:17:59 am »
i saw these procs and funcs :

    function CustomFormIndex(AForm: TCustomForm): integer;
    function FormIndex(AForm: TForm): integer;
    function CustomFormZIndex(AForm: TCustomForm): integer;
    procedure MoveFormToFocusFront(ACustomForm: TCustomForm);
    procedure MoveFormToZFront(ACustomForm: TCustomForm);

in the unit Form , at the TScreen declaration

might help !

Blue1987

  • Full Member
  • ***
  • Posts: 165
Re: a form always in background and a form on the top...
« Reply #11 on: August 16, 2012, 07:02:30 pm »
ehr, what is a TCustomForm??
because I did not see such a procedure for TForm...

gulyone

  • Guest
Re: a form always in background and a form on the top...
« Reply #12 on: August 16, 2012, 09:28:35 pm »
ehr, what is a TCustomForm??
because I did not see such a procedure for TForm...

CustomForm is the ancestor of Form , meaning you can give a Form as argument to these functions with no problem. if you have no clue of what is an ancestor and objects inheritance in pascal , i cant help lmao

Blue1987

  • Full Member
  • ***
  • Posts: 165
Re: a form always in background and a form on the top...
« Reply #13 on: August 16, 2012, 09:41:43 pm »
I have a clue  :D . simply did not know that TForm came out from TCustomForm.
however, these procedures and functions are not available for TForm... how can I use them all the same??


thank you much for your support,
Paolo

Blue1987

  • Full Member
  • ***
  • Posts: 165
Re: a form always in background and a form on the top...
« Reply #14 on: August 16, 2012, 09:43:40 pm »
(meanwhile I also tried
"with form1 do with current_form do setzorder(true);" but it did not work all the same!!"

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads