Starting monitor

Starting monitor

Postby Natter » Fri Dec 03, 2021 6:32 am

If there are several monitors, is it possible to specify the starting monitor for the application ?
Natter
 
Posts: 1120
Joined: Mon May 14, 2007 9:49 am

Re: Starting monitor

Postby Horizon » Fri Dec 03, 2021 7:39 am

Hi,

http://forums.fivetechsupport.com/viewtopic.php?f=16&t=36546&hilit=fw+getmonitor&sid=5408cb8de17b12ed5065f9731c82ea6a
Code: Select all  Expand view
* Multiple Monitors support functions:
fwh\source\function\getsysin.prg

- FW_ActiveMonitors() --> nMonitors
Number of extended monitors currently active.

- FW_VirtualScreen() --> oRect
TRect object representing the area of virtual screen covered by all the
extended monitors. (Note: The object has datas nTop, nLeft, nBottom,
nRight, nWidth, nHeight)
The total width of the rectangle is the sum of horizontal resolutions of
all the monitors and height is the maximum of the vertical resolutions
of all the monitors.
Recommended reading for better understanding
https://docs.microsoft.com/en-us/window ... ual-screen
https://docs.microsoft.com/en-us/window ... y-monitors

- FW_GetMonitor(params) --> oMonitor (TMonitor object)
params:
FW_GetMonitor() --> oPrimaryMonitor
FW_GetMonitor( n ) --> nth Monitor object. Defaults to primary monitor
if there is only one active monitor.
FW_GetMonitor( oWnd/hWnd ) --> oMonitor containing max area of the window
FW_GetMonitor( nRow, nCol ) --> oMonitor containing the coordinates

- TMonitor class datas and methods
DATAS:
lPrimary // Is primary monitor
nTop, nLeft, nBottom, nRight, nWidth, nHeight
CenterPt --> { nRow, nCol }

METHODS:
Row( nMonitorRow ) --> nRow on Virtual Screen
Col( nMonitorCol ) --> nCol on Virtual Screen
Center( oWnd/hWnd ) --> Centers the window inside the monitor
Move( oWnd/hWnd ) --> Sets the window in the monitor with the same
relative coordinates

Example Usage:
ACTIVATE WINDOW oWnd ON INIT FW_GetMonitor( 2 ):Center( oWnd )
ACTIVATE WINDOW oWnd ON INIT FW_GetMonitor( 2 ):Move( oWnd )
If the program is run on a single monitor the display defaults to the
primary monitor
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1289
Joined: Fri May 23, 2008 1:33 pm

Re: Starting monitor

Postby Natter » Fri Dec 03, 2021 8:33 am

Thank you, Horizon! I've read it all. But I was hoping for a concrete example. And so you'll have to figure it out yourself. :(
Natter
 
Posts: 1120
Joined: Mon May 14, 2007 9:49 am

Re: Starting monitor

Postby driessen » Mon Dec 06, 2021 9:46 am

I'm also interested in an example of multimonitor.
Thanks.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.02 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc77
User avatar
driessen
 
Posts: 1399
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: Starting monitor

Postby Natter » Tue Dec 07, 2021 12:58 pm

To get the DC of the monitor, it is suggested to use the EnumDisplayMonitors function. Where can I find this function?
Natter
 
Posts: 1120
Joined: Mon May 14, 2007 9:49 am

Re: Starting monitor

Postby Antonio Linares » Wed Dec 08, 2021 5:21 am

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41365
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Starting monitor

Postby Natter » Wed Dec 08, 2021 6:41 am

I tried:

DLL32 FUNCTION EnumDisplayMonitors( hdc AS LONG, lprcClip AS LONG, ;
lpfnEnum AS Mnt_Lg, dwData AS LONG) AS BOOL PASCAL LIB "user32.dll"

But, apparently, I am wrong in the description of the call function :(
Natter
 
Posts: 1120
Joined: Mon May 14, 2007 9:49 am

Re: Starting monitor

Postby Jimmy » Wed Dec 08, 2021 7:02 am

hi,

as i understand ENUMDISPLAYMONITORS need a Callback to build a Array

from MiniGUI Extended Version
Code: Select all  Expand view
HB_FUNC( ENUMDISPLAYMONITORS )
{
   PHB_ITEM pMonitorEnum = hb_itemArrayNew( 0 );

   EnumDisplayMonitors( NULL, NULL, _MonitorEnumProc0, ( LPARAM ) pMonitorEnum );

   hb_itemReturnRelease( pMonitorEnum );
}

BOOL CALLBACK _MonitorEnumProc0( HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData )
 
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1590
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Starting monitor

Postby Natter » Wed Dec 08, 2021 7:16 am

And how does it adapt this to xHarbour ?
Natter
 
Posts: 1120
Joined: Mon May 14, 2007 9:49 am

Re: Starting monitor

Postby Jimmy » Wed Dec 08, 2021 7:29 am

hi,

And how does it adapt this to xHarbour

i´m nur sure but as i know MiniGUI can be used with xHarbour and BCC
Code: Select all  Expand view
#ifndef __XHARBOUR__
HB_FUNC( ENUMDISPLAYMONITORS )
BOOL CALLBACK _MonitorEnumProc0( HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData )
HB_FUNC( GETMONITORINFO )
#endif

#ifndef __XHARBOUR__
HB_EXPORT PHB_ITEM Rect2Hash( RECT * rc )
#endif
 

IMHO it seems me xharbour do HAVE that API Function already

---

you can also use WMI

Code: Select all  Expand view
  colItems       := objWMIServices:ExecQuery("select * from Win32_DesktopMonitor",,48)


it does have this Property

Code: Select all  Expand view
LOCAL aProp := {;
"Availability",;
"Bandwidth",;
"Caption",;
"ConfigManagerErrorCode",;
"ConfigManagerUserConfig",;
"CreationClassName",;
"Description",;
"DeviceID",;
"DisplayType",;
"ErrorCleared",;
"ErrorDescription",;
"InstallDate",;
"IsLocked",;
"LastErrorCode",;
"MonitorManufacturer",;
"MonitorType",;
"Name",;
"PixelsPerXLogicalInch",;
"PixelsPerYLogicalInch",;
"PNPDeviceID",;
"PowerManagementCapabilities",;
"PowerManagementSupported",;
"ScreenHeight",;
"ScreenWidth",;
"Status",;
"StatusInfo",;
"SystemCreationClassName",;
"SystemName" }
 
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1590
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Starting monitor

Postby Natter » Wed Dec 08, 2021 7:44 am

Thanks, Jimmy !

I don't know, I've never used MiniGui

Through WMI I will try. If it doesn't work, I'll try using PowerShell
Natter
 
Posts: 1120
Joined: Mon May 14, 2007 9:49 am

Re: Starting monitor

Postby nageswaragunupudi » Fri Dec 10, 2021 10:59 am

Natter wrote:If there are several monitors, is it possible to specify the starting monitor for the application ?


If you want to start the application in the 2nd monitor, then use
Code: Select all  Expand view
ACTIVATE WINDOW oWnd ON INIT FW_GetMonitor( 2 ):Center( oWnd )
 


I think we can do most anything required with the provided multi-monitor functions given above.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10294
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Starting monitor

Postby Marc Venken » Mon Sep 12, 2022 7:13 pm

I don't get it working.

I was trying to show a xbrowse on screen 1 and on screen 2 a dialog with some data from that browse, INCLUDING a picture (ximage) that is located in the browse as a file name (data files on drive)

moving in the browse changes the data in screen 2

Anyone has this running like this ?
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1355
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Starting monitor

Postby Marc Venken » Mon Sep 12, 2022 7:46 pm

The 2 screens are not the same (desktop large monitor and a laptop monitor. The virtual screen wil not look nice this way.
Should I look into a MDI dialog ? (also nerver used)
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1355
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Starting monitor

Postby nageswaragunupudi » Tue Sep 13, 2022 6:28 pm

Marc Venken wrote:I don't get it working.

I was trying to show a xbrowse on screen 1 and on screen 2 a dialog with some data from that browse, INCLUDING a picture (ximage) that is located in the browse as a file name (data files on drive)

moving in the browse changes the data in screen 2

Anyone has this running like this ?


Can be done in different ways.
Here is one sample I quickly made. (Tested and working)
Code: Select all  Expand view
#include "fivewin.ch"

REQUEST DBFCDX

function Main()

   local oDlg

   USE WWONDERS ALIAS WW VIA "DBFCDX"

   DEFINE DIALOG oDlg SIZE 400,400 PIXEL TRUEPIXEL

   @ 20,20 SAY WW->NAME SIZE 360,30 PIXEL OF oDlg CENTER

   oDlg:bPainted := {|hDC| oDlg:DrawImage( WW->IMAGE, { 60,30,380,280 } ) }

   ACTIVATE DIALOG oDlg NOMODAL ON INIT FW_GetMonitor( 2 ):Center( oDlg )

   XBROWSER "WW" SETUP ( oBrw:bChange := { || oDlg:Refresh() } ) ;
      VALID ( oDlg:End(), .t. )

return nil
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10294
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 28 guests