Page 1 of 1
Preventing modal windows from overlapping
Posted: Mon Jun 07, 2010 10:01 am
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
Re: Preventing modal windows from overlapping
Posted: Mon Jun 07, 2010 10:26 am
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.
Re: Preventing modal windows from overlapping
Posted: Mon Jun 07, 2010 10:29 am
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
Re: Preventing modal windows from overlapping
Posted: Mon Jun 07, 2010 11:44 am
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?
Re: Preventing modal windows from overlapping
Posted: Tue Jun 08, 2010 2:21 pm
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
Re: Preventing modal windows from overlapping
Posted: Wed Jun 09, 2010 1:46 am
by c-tec
Hello Tom,
thank you, works perfect, maybe Roger can make something in DCGETOPTIONS
regards
Rudolf
Re: Preventing modal windows from overlapping
Posted: Wed Jun 09, 2010 7:51 am
by rdonnay
That sound like a good option. I'll add it to build 255.
Thanks, Tom.
Re: Preventing modal windows from overlapping
Posted: Wed Jun 09, 2010 11:38 pm
by c-tec
Hello Roger,
thank you !
regards
Rudolf
Re: Preventing modal windows from overlapping
Posted: Thu Jun 10, 2010 8:12 am
by rdonnay
What should I call this option?
BLABLA
or
MORE BLABLA
Re: Preventing modal windows from overlapping
Posted: Fri Jun 11, 2010 1:40 am
by c-tec
Hello Roger,
maybe MOVELOCK
regards
Rudolf