FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Monitores Multiples
Posts: 883
Joined: Thu Dec 24, 2009 12:46 AM
Monitores Multiples
Posted: Fri Feb 26, 2010 04:40 PM

Hola Foro,
Existe alguna manera de detectar cuantos monitores tiene instalados un ordenador, y si lo mostrado en esos monitores es lo mismo o se esta usando como Extension del Desktop???

=====>

Bayron Landaverry
xBasePHP.com
(215)2226600 Philadelphia,PA, USA
MayaBuilders@gMail.com
Guatemala

FWH25.06--Harbour 3.0.0--BCC7.7--UEstudio 10.10
Windows 10

FiveWin, One line of code and it's done...

Posts: 883
Joined: Thu Dec 24, 2009 12:46 AM
Re: Monitores Multiples
Posted: Fri Feb 26, 2010 07:17 PM
Hola Foro,
Necesitaba detectar si el ordenador tenia instalados monitores multiples solo para calcular el tamano del desktop, para asignar el tamano de mi ventana principal.

Code (fw): Select all Collapse
   DEFINE WINDOW oVent FROM 0, 0 TO (WndHeight( GetDesktopWindow()) - 30),;
                 (WndWidth( (GetDesktopWindow()) ) - 120)


Este codigo colocaba el tamano de la Ventana extendido en mis dos monitores.

El problema se resuelve al colocar la clausula

PIXEL

=====>

Bayron Landaverry
xBasePHP.com
(215)2226600 Philadelphia,PA, USA
MayaBuilders@gMail.com
Guatemala

FWH25.06--Harbour 3.0.0--BCC7.7--UEstudio 10.10
Windows 10

FiveWin, One line of code and it's done...

Posts: 883
Joined: Thu Dec 24, 2009 12:46 AM
Re: Monitores Multiples
Posted: Fri Feb 26, 2010 07:52 PM

Amigos,

Cuando muevo la ventana principal de la aplicacion a otro monitor que no sea el principal, cuando defino un dialogo,

DEFINE DIALOG oDlg OF oWnd

Este aparece sobre la ventana principal, pero en cualquier lado de la ventana.

Cuando le incluyo la opcion CENTERED, el dialogo se centra en el monitor principal y no sobre la Ventana Principal...

Alguien sabe como hacer para que centre sobre la Ventana Principal?????

=====>

Bayron Landaverry
xBasePHP.com
(215)2226600 Philadelphia,PA, USA
MayaBuilders@gMail.com
Guatemala

FWH25.06--Harbour 3.0.0--BCC7.7--UEstudio 10.10
Windows 10

FiveWin, One line of code and it's done...

Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: Monitores Multiples
Posted: Fri Feb 26, 2010 08:36 PM
Bayron...
Bayron wrote:Cuando le incluyo la opcion CENTERED, el dialogo se centra en el monitor principal y no sobre la Ventana Principal...
Alguien sabe como hacer para que centre sobre la Ventana Principal?????


puedes usar el metodo CENTER que recibe como parametro un control que puedes usar como referencia para centrar un dialogo, window, etc. con respecto al mismo

Code (fw): Select all Collapse
ACTIVATE DIALOG oDlg ON INIT( ::Center( oWndMain ) )
Posts: 883
Joined: Thu Dec 24, 2009 12:46 AM
Re: Monitores Multiples
Posted: Fri Feb 26, 2010 09:56 PM

Daniel,

Gracias Daniel, funciona Perfecto...

=====>

Bayron Landaverry
xBasePHP.com
(215)2226600 Philadelphia,PA, USA
MayaBuilders@gMail.com
Guatemala

FWH25.06--Harbour 3.0.0--BCC7.7--UEstudio 10.10
Windows 10

FiveWin, One line of code and it's done...

Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: Monitores Multiples
Posted: Fri Feb 26, 2010 09:59 PM
Bayron...

Bayron wrote:Cuando muevo la ventana principal de la aplicacion a otro monitor que no sea el principal, cuando defino un dialogo,


te dejo un ejemplo probado en win7 (no se como el resultado en otras versiones)
oprime doble click en el simbolo {...} cuando abras el xbrowse

Code (fw): Select all Collapse
#include "fivewin.ch"

#define SM_CMONITORS            80
#define SM_XVIRTUALSCREEN       76
#define SM_YVIRTUALSCREEN       77
#define SM_CXVIRTUALSCREEN      78
#define SM_CYVIRTUALSCREEN      79

function main
   local oWnd
   local oBar
   local aRect
   
   define window oWnd title "Test multi monitor"
   
   define buttonbar oBar of oWnd size 80, 30
   
   define button prompt "Count" of oBar ;
          action MsgInfo( "Total Visibles Monitors:" + Str( CountMonitors() ) )
          
   define button prompt "Get Coors" of oBar;
          action XBrowse( GetAllMonitorRect() )
   
   define button prompt "Virtual Screen" of oBar;
          action XBrowse( { GetSysMetrics( SM_YVIRTUALSCREEN  ),;
                            GetSysMetrics( SM_YVIRTUALSCREEN  ),;
                            GetSysMetrics( SM_CYVIRTUALSCREEN ),;
                            GetSysMetrics( SM_CXVIRTUALSCREEN ) } )
   
   define button prompt "Move Next" of oBar;
          action ( aRect := GetMonitorRect( 2 ), oWnd:Move( aRect[ 1 ], aRect[ 2 ] ) )
   
   define button prompt "Move Prev" of oBar;
          action ( aRect := GetMonitorRect( 1 ), oWnd:Move( aRect[ 1 ], aRect[ 2 ] ) )

   define button prompt "All Window" of oBar;
          action (oWnd:Move( GetSysMetrics( SM_YVIRTUALSCREEN  ),;
                             GetSysMetrics( SM_YVIRTUALSCREEN  ),;
                             GetSysMetrics( SM_CXVIRTUALSCREEN ),;
                             GetSysMetrics( SM_CYVIRTUALSCREEN ), .T. ) )


   
   activate window oWnd
   
return nil

function  CountMonitors()
return GetSysMetrics( SM_CMONITORS )

function GetAllMonitorRect()

   local nTotalMon
   local n
   local aRect
   local aMonitors := {}

   if ( nTotalMon := CountMonitors() ) > 1 
      aRect = GetWndRect( GetDesktopWindow() )
      AAdd( aMonitors, { 1, aRect } )
      for n = 2 to nTotalMon
         aRect = GetRectNextMonitor( aRect )
         AAdd( aMonitors, { n, aRect } )
      next
   endif
        
return aMonitors 
   
   
function GetMonitorRect( nMon )

   local nTotalMon
   local n
   local aRect
   local aMonitors := {}

   aRect = GetWndRect( GetDesktopWindow() )
   if ( nTotalMon := CountMonitors() ) >= nMon 
      for n = 2 to nMon
         aRect = GetRectNextMonitor( aRect )
      next
   endif
        
return aRect
   



#pragma BEGINDUMP

#include <windows.h>
#include <hbapi.h>


HB_FUNC( GETRECTNEXTMONITOR )
{
    
    POINT pt;
    HMONITOR hMon;
    MONITORINFO pmi;
    
    pmi.cbSize  = sizeof( MONITORINFO );
    
    pt.x = hb_parvnl( 1, 4 ) + 1;
    pt.y = hb_parvnl( 1, 1 );
    
    hMon = MonitorFromPoint( pt, MONITOR_DEFAULTTONULL );
    
    if( hMon != NULL )
    {
    if( GetMonitorInfo( hMon, &pmi ) )
    {
        hb_reta( 4 );
        hb_storvni( pmi.rcMonitor.top, -1, 1 );
        hb_storvni( pmi.rcMonitor.left, -1, 2 );
        hb_storvni( pmi.rcMonitor.bottom, -1, 3 );
        hb_storvni( pmi.rcMonitor.right, -1, 4 );
    }
  }else
     hb_retni( 0 );
    
}
    

#pragma ENDDUMP
Posts: 883
Joined: Thu Dec 24, 2009 12:46 AM
Re: Monitores Multiples
Posted: Sat Feb 27, 2010 01:41 AM
Daniel,

Mil gracias, el programa compilo y funciono muy bien, pero me aparecieron estos errores:



Seran funciones solo de harbour??? o me falta incluir alguna libreria

Yo utilizo xHarbour....

=====>

Bayron Landaverry
xBasePHP.com
(215)2226600 Philadelphia,PA, USA
MayaBuilders@gMail.com
Guatemala

FWH25.06--Harbour 3.0.0--BCC7.7--UEstudio 10.10
Windows 10

FiveWin, One line of code and it's done...

Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: Monitores Multiples
Posted: Sat Feb 27, 2010 01:57 AM
Hola Bayron

incluye esto despues de #include <hbapi.h>

Code (fw): Select all Collapse
#ifdef __XHARBOUR__
long hb_parvnl( int iParam, int iIndex );
void hb_storvni( int iValue, int iParam, int iIndex );
#endif
Posts: 883
Joined: Thu Dec 24, 2009 12:46 AM
Re: Monitores Multiples
Posted: Sat Feb 27, 2010 02:46 AM

Daniel,

Gracias, era justo eso.....

Todo trabaja muy bien.

=====>

Bayron Landaverry
xBasePHP.com
(215)2226600 Philadelphia,PA, USA
MayaBuilders@gMail.com
Guatemala

FWH25.06--Harbour 3.0.0--BCC7.7--UEstudio 10.10
Windows 10

FiveWin, One line of code and it's done...

Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: Monitores Multiples
Posted: Sat Feb 27, 2010 04:09 AM
Dear Mr.Daniel,

This is for you information.

First of all let me thank you for providing a very useful sample which help us in a dual or multi monitor environment. In the sample provided by you, when I click on the buttons "Get Coors" & "Virtual Screen", it opens an xBrowse. If I try to drag the Horizontal scroll bar towards the right hand side, then the xbrowse generates the following error. Is this a xBrowse bug ?. I am using FWH 10.2


    Application
    ===========
    Path and name: D:\FwhExtra\FWH Samples\MultiMonitor\MultiMon.exe (32 bits)
    Size: 1,772,032 bytes
    Time from start: 0 hours 0 mins 38 secs
    Error occurred at: 02/27/10, 09:31:53
    Error description: Error BASE/1132 Bound error: array access
    Args:
    [ 1] = A { ... }
    [ 2] = N 0

    Stack Calls
    ===========
    Called from: .\source\classes\XBROWSE.PRG => (b)TXBROWSE:TXBROWSE(476)
    Called from: => TXBROWSE:COLATPOS(0)
    Called from: .\source\classes\XBROWSE.PRG => (b)TXBROWSE:TXBROWSE(478)
    Called from: => TXBROWSE:SELECTEDCOL(0)
    Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:PAINT(1192)
    Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:DISPLAY(1174)
    Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT(1439)
    Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:HANDLEEVENT(10470)
    Called from: .\source\classes\WINDOW.PRG => _FWH(3378)
    Called from: => DIALOGBOXINDIRECT(0)
    Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE(273)
    Called from: .\source\function\ERRSYSW.PRG => ERRORDIALOG(345)
    Called from: .\source\function\ERRSYSW.PRG => (b)ERRORSYS(27)
    Called from: .\source\classes\XBROWSE.PRG => (b)TXBROWSE:TXBROWSE(476)
    Called from: => TXBROWSE:COLATPOS(0)
    Called from: .\source\classes\XBROWSE.PRG => (b)TXBROWSE:TXBROWSE(478)
    Called from: => TXBROWSE:SELECTEDCOL(0)
    Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:PAINT(1192)
    Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:DISPLAY(1174)
    Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT(1439)
    Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:HANDLEEVENT(10470)
    Called from: .\source\classes\WINDOW.PRG => _FWH(3378)
    Called from: => DIALOGBOXINDIRECT(0)
    Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE(273)
    Called from: .\source\function\XBROWSER.PRG => XBROWSE(136)
    Called from: MultiMon.prg => (b)MAIN(28)
    Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:CLICK(463)
    Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:LBUTTONUP(658)
    Called from: => TWINDOW:HANDLEEVENT(0)
    Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT(1464)
    Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:HANDLEEVENT(1415)
    Called from: .\source\classes\WINDOW.PRG => _FWH(3378)
    Called from: => WINRUN(0)
    Called from: .\source\classes\WINDOW.PRG => TWINDOW:ACTIVATE(971)
    Called from: MultiMon.prg => MAIN(44)
    [/list:u]

    Regards
    Anser
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: Monitores Multiples
Posted: Sat Feb 27, 2010 05:50 AM

Hello anserk

thank for feed back

we will check this error very soon

Continue the discussion