Easy to Create, Easy to Change - Easy to use!


Active Doc - several forms open at same time


Started by afonso santos
Search
You will need to Sign In to be able to add or comment on the forum!

Active Doc - several forms open at same time

Hi all,

I'm trying to have a main form ( v_MAIN ) which has several buttons in order to open other forms, to enter/delete or modify table's data.

Each button , has a OML Clicked event a structure as follows :

define "act" text .

act := setVar("XPOSQ",(getcurrent("XPOS","bt_calendario")))+ setVar("YPOSQ",(getcurrent("YPOS","bt_calendario")+35)) .

if GetCurrent("IsDocOpen", "v_form1" ) = "yes" then

act := wait (0.1) + setcurrent ("ActiveDoc", "v_form1" ) .

else

act := documentopen ("v_form1") .

end

Only the form name change for each button.

This main form ( V_MAIN) is opened in Modal mode.

Sequence of operations desired :

Pressing a button a new form ( v_Form1) is displayed and I can enter/ delete, etc .

Pressing a 2nd button, I want keep the 1st form v_form1 open, but it's sent to Back of main form, becaming invisible. ( I want it visible ) .

A new form ( v_Form2 ) is opened

Pressing a 3rd button the 2nd form ( v_Form2 ) is again sendtoBack and the third form ( v_form3 ) is opened.

I would like to open several forms at same time, and as the mouse enter a form ( always visible) , it must became active, in order I can operate it.

The main form has a manip field as follows:

setstate("manip", 0 )+MoveObject ("bt_sair" ,XSIZE-getcurrent("width","bt_sair") -5 , "0")+SetCurrent("Statusbar","Off")+Setcurrent("Toolbar","OFF")+SetCurrent("Tabbar","Off")+SetCurrent("FileMenu","Off") +SetCurrent("WIndowBorder","NoEdge")+SetCurrent("WindowClass","modal")+SetCurrent("WindowType","NorMaxMax")+ SetCurrent("WindowPos","0","0")

The others forms ( v_Form1,v_Form2 and v_Form3 ) have each one a manip virtual field as follows :

setstate("manip1", 0 ) +SetCurrent("WIndowBorder","NoEdge")+SetCurrent("WindowClass","normal")+ SetCurrent("WindowPos",getvar("XPOSQ"),getvar("YPOSQ"))

The setsate (manip1) has a different name for each form

Can anybody explain how to do it ?

Thanks in advance

Afonso

Written by afonso santos 18/08/20 at 18:38:19 Dataease [{8}]FIVE

Re:Active Doc - several forms open at same time

Hi.

Not completely sure what you try to accomplish here but the problem is that you mix up windows concepts.

Modal is a very strict window class and only another modal form can be on top of a modal form. This is Windows and not DataEase.

SO if you have a form open that is open as a normalized form and want that to come on top of a Modal form it is impossible.

I have a feeling that you now focus on trying to get things working the way you thought was the best way rather than re-visit what you try to do and go for the shortest way to your goal.

If you open a form in Modal and then simply open a document from that Form the new form will also be Modal and all the children will be modal. You cannot use Switching or tabs to go between them as it is a strict hierarchy.

If you want to use Modal you have to use DocumentOpen.

Written by DataEase 19/08/20 at 13:03:52 Dataease [{8}]FIVE

Re:Re:Active Doc - several forms open at same time

Download Sample


The biggest problem with getting a request like this is that there is a sensible answer and then there is the interesting answer ;-)

First we do the sensible answer and then it nag in the back of your head...can it be done in an "elegant" way?

What we think you try to do here is to control the user so they don't open things all over and jump around like a lunatic. That is at least the assumption we base this sample on.

So what we do is to open a "MainForm" that immediately switch to Modal.

When a form is in Modal is the entire "world". Nothing outside that form can impact the processing, so everything you want DataEase to do you need to do from a button etc. on this form. So if you switch to Modal without having a close button you have to "kill" dataease and start over.

So save, Delete, etc. need to be buttons or otherwise properties of each document you want to be modal.

We then have two forms Form1 and Form2 that will be opened on first "open" and then simply switched to when they are already open.

The problem is that we can't switch to a normal form from a Modal form so we do a hack.

SetCurrent("WindowClass","Normal")+if (GetCurrent("IsDocOpen","Form")="yes",SetCurrent("ActiveDoc","Form"), DocumentOpen("Form"))+wait(0.1)+SetCurrent("WIndowClass","Modal")

Magic is not real but it appear to be real and this is programming magic. As the goal is to stop the user and not the programmer from getting it "his" way, we simply switch off Modal, do our open form magic and then wait a moment before we switch back to Modal. This means that our Form1 is now the top modal form.

WHen we har done what we wanted in Form1 we simply do the same trick in reverse.

SetCurrent("WindowClass","Normal")+SetCurrent("ActiveDoc","MainForm")+wait(0.1)+SetCurrent("WindowClass","Modal")

Simples!

You can basically just remove Toolbars, Tabbar and filemenu etc as the user will simply be confused by them being there.

Written by DataEase 19/08/20 at 13:56:57 Dataease [{8}]FIVE

Re:Re:Re:Re:Active Doc - several forms open at same time

Dear All,

Thanks for the explanation.

I'm trying to make a screen like the one you have in dataease , with several forms opened at same time ( as objects , classes, properties, etc ) , and a memo field ( written code ) gattering the values selected when clicking an option on each form.

Is exactly what I'm tryng to do but no sucess so far.

thanks

A

Written by afonso santos 21/08/20 at 12:10:34 Dataease [{8}]FIVE

Re:Re:Re:Re:Re:Active Doc - several forms open at same time

Download Sample

Hi Afonso.

You have to get your head around Modal or the Windows MDI window model in general.

1. A modal form can only have modal children. So if you have a form already open that is not Modal you cannot switch to it. You can open a form from a modal form but that form will then also be modal.

2. WIndow Class is for ALL windows. So if you switch to Modal all FORMS is Modal or Normal.

With this in mind  - If you open FormA, Then FormB Then FormC and Switch Form C to Modal you in reality switch all of them to Modal with FormC as the last and dominant Window (Only one Window can have control in Modal). So You can't push Form A on top of  Form C without changing the pecking order. 

So what I did was to switch the Modal form (and all other forms back to Normal) then switched the order by Activating the form I wanted to be dominant and then switched back to Modal. 

Just try to play with my sample a little and you get it.

Click on SetNormal in My sample and then click on Form 1 or Form 2. The moment you click on them they will be activated and go on top, and when you click on MainForm that go on top. Then click SetModal and try to do the same. You will see that you can't activate Form1 or Form2. 

SetCurrent("ActiveDoc" etc) do the same so it can't succeed if the windows model is not Normal. 

The OML that do the same as by Action Code.

define "act" text .

act :=SetCurrent("WindowClass","Normal") .

if GetCurrent("IsDocOpen","Form")="yes" then

act :=SetCurrent("ActiveDoc","Form") .

else

act := DocumentOpen("Form") .

end .

act := wait(0.1) .

act :=SetCurrent("WIndowClass","Modal") .

act := SetCurrent("WindowBorder","Thin") .

In OML the wait is actually not necessary as when you call it as above it is done Sequential like in DQL (ODQL this is).

the wait is just necessary in Actions where you call them with +.

define "act" text .

act :=SetCurrent("WindowClass","Normal") .

if GetCurrent("IsDocOpen","Form")="yes" then

act :=SetCurrent("ActiveDoc","Form") .

else

act := DocumentOpen("Form")+SetCurrent("WIndowClass","Modal")+SetCurrent("WindowBorder","Thin") .

end .

if you replace the code om Form 1 OML with the one just above you will see what I mean.

Then the signals will not reach the new window but be sent to the old window and hence you don't switch the order.

Add a wait(0.1) between DocumentOpen and SetCurrent("WindowClass etc and you will get the same effect as the new window becomes activated before the message is sent.

Written by DataEase 21/08/20 at 13:30:52 Dataease [{8}]FIVE

Re:Re:Re:Re:Re:Re:Active Doc - several forms open at same time

Hi,

Thanks for the quick answer.

I canĀ“t download the sample.

have a nice wkend

AS

Written by afonso santos 21/08/20 at 17:21:54 Dataease [{8}]FIVE

Re:Re:Re:Re:Re:Re:Re:Active Doc - several forms open at same time

Sorry, fixed.

Written by DataEase 21/08/20 at 17:34:05 Dataease [{8}]FIVE