Multiple monitor behavior

This forum is for eXpress++ general support.
Post Reply
Message
Author
reganc
Posts: 259
Joined: Thu Jan 28, 2010 3:08 am
Location: Hersham, Surrey, UK
Contact:

Multiple monitor behavior

#1 Post by reganc »

Is there any way to set eXpress++ so that if you have a multiple monitor setup and you move your applications main window to the 2nd monitor and then open a new dialog from it, it would put it on the 2nd monitor rather than the 1st?

I'm sure there is some sort of logic that will allow that sort of behavior. But I don't know if it's already there in some hidden function...

When developing and testing applications I often have two open and it would be nice to get them to keep to one monitor or the other.
Regan Cawkwell
Real Business Applications Ltd
http://www.rbauk.com

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

Re: Multiple monitor behavior

#2 Post by rdonnay »

You can use DC_AutoRestoreWindow() to do this. Look at the sample below.
The window will be restored to the position in which it was last closed.

However, I just fixed a bug in which the window column is not positioned correctly if the window was closed on a monitor other than the primary monitor.
You will need to make the following change to _DCGETBX.PRG (approx line 3630 depending on build).

Code: Select all

WAS:
      IF ::parentDlg:currentPos()[1] > ::parentDlg:setParent():currentSize()[1]
        ::parentDlg:setPos({::parentDlg:setParent():currentSize()[1]-100, ;
                            ::parentDlg:currentPos()[2]})
      ENDIF

IS:
    #DEFINE SM_CMONITORS 80
    IF GetSystemMetrics(SM_CMONITORS) = 1
      IF ::parentDlg:currentPos()[1] > ::parentDlg:setParent():currentSize()[1]
        ::parentDlg:setPos({::parentDlg:setParent():currentSize()[1]-100, ;
                            ::parentDlg:currentPos()[2]})
      ENDIF
    ENDIF

Code: Select all

/*
This sample program shows how to use a code block
with DC_AutoRestoreWindow() to save window coordinates
to a file.
*/

#INCLUDE "dcdialog.CH"

FUNCTION Main()

LOCAL GetList[0], GetOptions

DC_AutoRestoreWindow( { {|cTitle,aArray|RestoreWindow(cTitle,aArray)} } )

@ 0,0 DCSAY 'This is my window' SAYSIZE 0 ;
      RESIZE DCGUI_RESIZE_CENTER ;
      FONT '16.Arial Bold'

DCGETOPTIONS RESIZE

DCREAD GUI  ;
  FIT ;
  TITLE 'My Window' OPTIONS GetOptions

RETURN nil

PROC appsys ; return

* ------------

STATIC FUNCTION RestoreWindow( cTitle, aArray )

cTitle := Strtran(cTitle,':','__')

IF aArray == nil
  aArray := DC_ARestore( cTitle + '.Window')
ELSE
  DC_ASave( aArray, cTitle + '.Window' )
ENDIF

RETURN aArray
The eXpress train is coming - and it has more cars.

reganc
Posts: 259
Joined: Thu Jan 28, 2010 3:08 am
Location: Hersham, Surrey, UK
Contact:

Re: Multiple monitor behavior

#3 Post by reganc »

I don't want to save the coordinates of the dialogs. Sorry, maybe I didn't explain myself very well.

I just want any new dialog created (spawned?) from our main menu dialog to be displayed on same monitor that the main menu dialog is currently on.

If I move my applications main menu dialog to the 2nd monitor and then use it's menu to open a new dialog/task, the new dialog gets displayed on the 1st monitor.

It makes more sense to me that any new dialog created from any other dialog, like an alert box for example, should be displayed on the same monitor that triggered it to be displayed.

For me, it's more of a practical thing because I only have full sight in my right eye. I have 2 monitors which is great for developing but what I mentioned above means that I would have to keep shifting my vision from monitor 2 to monitor 1 every time I open a new dialog and more often than not I'd then have to move any new dialog from monitor 1 to monitor 2.
Regan Cawkwell
Real Business Applications Ltd
http://www.rbauk.com

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

Re: Multiple monitor behavior

#4 Post by rdonnay »

This can be done with the OWNER clause.

Ex. DCREAD GUI OWNER SetAppWindow().
The eXpress train is coming - and it has more cars.

reganc
Posts: 259
Joined: Thu Jan 28, 2010 3:08 am
Location: Hersham, Surrey, UK
Contact:

Re: Multiple monitor behavior

#5 Post by reganc »

rdonnay wrote:This can be done with the OWNER clause.

Ex. DCREAD GUI OWNER SetAppWindow().
Ah, is that the only 'effect' of specifying the OWNER clause?

I had in my mind that it was something to do with MDI / SDI app behaviour.
Regan Cawkwell
Real Business Applications Ltd
http://www.rbauk.com

skiman
Posts: 1199
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Multiple monitor behavior

#6 Post by skiman »

Hi,

Today I tried this, but I don't get the expected result.

This is the problem, and as I understood Regan had the same problem.

1. I start my application on Monitor 1.
2. I move the application to monitor two. I maximize it on monitor 2.
3. A dialog whiwh is openen on the oMain:drawingarea is opened on monito 2 as expected.
4. A MODAL dialog is opened on Monitor 1. I wnat this opened on Monitor 2.

A msgbox() is opened on Monitor 2. This is how I want it with my MODAL dialogs.

I tried to add OWNER setappwindow() to the DCREAD of the MODAL dialog, but this isn't working. I also tried with OWNER oMain:drawingarea but this also doesn't change anything. My modal dialogs remains being opened on Monitor 1.
Best regards,

Chris.
www.aboservice.be

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

Re: Multiple monitor behavior

#7 Post by rdonnay »

The below sample works for me:

Code: Select all

#INCLUDE "dcdialog.CH"

FUNCTION Main()

LOCAL GetList[0], oMenuBar, oSubMenu, oDlg

DCMENUBAR oMenuBar

DCSUBMENU oSubMenu PARENT oMenuBar PROMPT 'Window'

DCMENUITEM 'Open modal window' PARENT oSubMenu ACTION {||ModalWindow(oDlg)}

DCREAD GUI TITLE 'Monitor test' EVAL {|o|oDlg := o} SETAPPWINDOW

RETURN nil

* -----------

PROC appsys ; RETURN

* -----------

FUNCTION ModalWindow( oDlg )

LOCAL GetList[0]

@ 0,0 DCSAY 'This is a MODAL window' SAYSIZE 0 ;
      FONT '16.Arial Bold'

DCREAD GUI FIT ADDBUTTONS TITLE 'Modal Window' MODAL SETAPPWINDOW ;
   OWNER oDlg

RETURN nil
The eXpress train is coming - and it has more cars.

Post Reply