Preventing modal windows from overlapping

This forum is for eXpress++ general support.
Post Reply
Message
Author
c-tec
Posts: 379
Joined: Tue Apr 20, 2010 1:36 am
Location: SALZBURG/AUSTRIA
Contact:

Preventing modal windows from overlapping

#1 Post by c-tec »

Hello,
have a customer with a special request. He want's to get a main window and a modal window, where it is impossible to move the modal window out of the border of the calling window. Better would be that the modal window can be moved over the border and is invisible out of the border of the main window. The same behaviour is in for example in EXCEL. Is this possible with eXPress++ ?
regards
Rudolf
Rudolf Reinthaler
digital pen & paper systems
http://www.formcommander.net

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Preventing modal windows from overlapping

#2 Post by rdonnay »

It is possible to anchor a modal window to a SetAppWindow(), but I wouldn't know how to make it start disappearing when moved to an area of the screen. What happens when it completely disappears? It seems that you would lockup the application if a modal window was not visible.
The eXpress train is coming - and it has more cars.

c-tec
Posts: 379
Joined: Tue Apr 20, 2010 1:36 am
Location: SALZBURG/AUSTRIA
Contact:

Re: Preventing modal windows from overlapping

#3 Post by c-tec »

Hello Roger,
I will try it later with EXCEL what happens if the window is completley out of the parent window. But it would be enough when the window cannot be moved over the owner window. Is this possible ? I
regards
Rudolf
Rudolf Reinthaler
digital pen & paper systems
http://www.formcommander.net

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Preventing modal windows from overlapping

#4 Post by rdonnay »

Yes, this is possible, but I have some questions.

What is the exact behavior you are looking for?

Do you want the modal windows to automatically center itself over the owner and then not allow it to be moved at all?

If you want to allow some movement, how do you want it restricted?
The eXpress train is coming - and it has more cars.

User avatar
Tom
Posts: 1171
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: Preventing modal windows from overlapping

#5 Post by Tom »

This does the job. The modal window can't be moved outside the parent dialog:

Code: Select all

#include "dcdialog.ch"
#pragma library("dclipx.lib")

PROCEDURE appsys() ; RETURN

PROCEDURE MAIN()
LOCAL GetList := {}, GetOptions := {}, oDialog

@ 1,1 DCSAY 'Blabla' SIZE 100,28

@ 29,1 DCPUSHBUTTON CAPTION 'New Window' SIZE 15,1 ACTION {||NewWindow(oDialog)}


DCREAD GUI FIT PARENT @oDialog ADDBUTTONS OPTIONS GetOptions EVAL {|o|SetAppWindow(o)}
RETURN

PROCEDURE NewWindow(oOwner)
LOCAL GetList := {}, GetOptions := {}, oDialog,oBlaBla, oBlaBla2

@ 1,1 DCSAY 'More blabla' SIZE 70,15 OBJECT oBlaBla
@ 2,1 DCSAY 'Lots of blabla' SIZE 70,15 OBJECT oBlaBla2

DCREAD GUI FIT MODAL ;
EVAL {|o|o:Move := {|aOld,aNew,oWindow|DontMoveOutSide(aOld,aNew,oWindow,oOwner,oBlaBla,oBlaBla2)}} ;
PARENT @oDialog OWNER oOwner

RETURN

FUNCTION DontMoveOutSide(aOld,aNew,oWindow,oOwner,oBlaBla,oBlaBla2)
LOCAL lResetPos := .F.
oBlaBla:SetCaption('Old: '+Trim(str(aOld[1]))+"/"+Trim(str(aOld[2]))+' New: '+;
                           Trim(str(aNew[1]))+"/"+Trim(str(aNew[2]))+' Size: '+;
                           Trim(str(oWindow:CurrentSize()[1]))+"/"+Trim(str(oWindow:CurrentSize()[2])))

oBlaBla2:SetCaption(' Size Parent: '+Trim(str(oOwner:CurrentSize()[1]))+"/"+Trim(str(oOwner:CurrentSize()[2]))+;
                    ' Pos Parent: '+Trim(str(oOwner:CurrentPos()[1]))+"/"+Trim(str(oOwner:CurrentPos()[2])))

IF aNew[1] < oOwner:CurrentPos()[1]
  aNew[1] := oOwner:CurrentPos()[1]
  lResetPos := .T.
ENDIf
IF aNew[2] < oOwner:CurrentPos()[2]
  aNew[2] := oOwner:CurrentPos()[2]
  lResetPos := .T.
ENDIf
IF aNew[1]+oWindow:CurrentSize()[1] > oOwner:CurrentPos()[1]+oOwner:CurrentSize()[1]
  aNew[1] := (oOwner:CurrentPos()[1]+oOwner:CurrentSize()[1])-oWindow:CurrentSize()[1]
  lResetPos := .T.
ENDIf
IF aNew[2]+oWindow:CurrentSize()[2] > oOwner:CurrentPos()[2]+oOwner:CurrentSize()[2]
  aNew[2] := (oOwner:CurrentPos()[2]+oOwner:CurrentSize()[2])-oWindow:CurrentSize()[2]
  lResetPos := .T.
ENDIf

IF lResetPos
  oWindow:SetPos(aNew)
ENDIF
RETURN NIL
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

c-tec
Posts: 379
Joined: Tue Apr 20, 2010 1:36 am
Location: SALZBURG/AUSTRIA
Contact:

Re: Preventing modal windows from overlapping

#6 Post by c-tec »

Hello Tom,
thank you, works perfect, maybe Roger can make something in DCGETOPTIONS
regards
Rudolf
Rudolf Reinthaler
digital pen & paper systems
http://www.formcommander.net

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Preventing modal windows from overlapping

#7 Post by rdonnay »

That sound like a good option. I'll add it to build 255.

Thanks, Tom.
The eXpress train is coming - and it has more cars.

c-tec
Posts: 379
Joined: Tue Apr 20, 2010 1:36 am
Location: SALZBURG/AUSTRIA
Contact:

Re: Preventing modal windows from overlapping

#8 Post by c-tec »

Hello Roger,
thank you !
regards
Rudolf
Rudolf Reinthaler
digital pen & paper systems
http://www.formcommander.net

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Preventing modal windows from overlapping

#9 Post by rdonnay »

What should I call this option?

BLABLA

or

MORE BLABLA
The eXpress train is coming - and it has more cars.

c-tec
Posts: 379
Joined: Tue Apr 20, 2010 1:36 am
Location: SALZBURG/AUSTRIA
Contact:

Re: Preventing modal windows from overlapping

#10 Post by c-tec »

Hello Roger,
maybe MOVELOCK
regards
Rudolf
Rudolf Reinthaler
digital pen & paper systems
http://www.formcommander.net

Post Reply