Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dual monitors 1

Status
Not open for further replies.

arielap

Technical User
Aug 2, 2003
71
0
0
GB
I've been asked to add a 'view PDF' option to our Tissue Typing app. .

The user has two monitors, with the main application running on one. What is wanted is - double-click on a record in a grid and have a linked PDF displayed on the other monitor.

Is this do-able ? If so, how please



 
There is an answer on this question by Greg Green in thread #1281255 in UT:

====================
To move one form from one monitor to another, the form must be top-level. Also, if you save a form position and then restore and the user is on a laptop at work with a second monitor and then on road with one, the form will appear off screen. You can detect if second monitor is present with the following:

DECLARE INTEGER GetSystemMetrics IN user32 INTEGER nIndex
#DEFINE SM_CMONITORS 80 && Number of monitors
...
...
IF GetSystemMetrics(SM_CMONITORS) = 1
&& Only one monitor
ELSE
&& Two monitors
ENDIF

Also, if you have forms popup "Centered" they will appear centered on the first monitor which may not be expected if the user is focused on the second monitor. So you have to determine where to place the form each time in the Init() event before displaying.
 
Makros,

nice use of GetSystemMetrics. VFP's built in Sysmetric() only shows the first 34 metrics.

Once you know there are two mointors check the metric of the screen width, that can be bone with Sysmetric(1).

With the width of the main form you can now determine the width of the resolution of the second monitor.

So you know the .Left needed for a form or application screen to go on the second, it's really just that.

If you use ShellExecute to start whatever program associated with the PDF file extension, you don't have control over the position of the PDF application in the first place. But graphics drivers typically remember where which application is started. So if the user once put's the PDF application (eg Acrobat Reader or Foxit Reader) on the second monitor it will always start there, unless it's moved elsewhere.

That's even true for your own application without needing to program anything. IF the first time the PDF does start in the same monitor, what the user needs to know about windows is that the second "max button" on the upper right side of a window toggles from maximizing to nonmaximized state and only in the nonmaximized state you can move a window. I think astonishingly many users are not aware of such a simple thing and therefore ask for help, while they can solve that "arrangement problem" themselves. And they only need to do this once.

Bye, Olaf.
 
You can of course pamper you customer and use FindWindow API to get a hwnd window handle to the PDF window and then move it to the second monitor and maximize it there. You 'only' need to know the caption of the window, which is not always "Acrobat Reader" though.

A little simpler: Start a InternetExplorer.Application, as you have full control over it. Position it and then use it's navigate method with a file URL to the PDF and maximize it:

Code:
#DEFINE SM_CMONITORS  80   && Number of monitors
#DEFINE SM_CXMAXIMIZED 61  && width of primary monitor
#DEFINE SW_SHOWMAXIMIZED 3 && for ShowWindow function

Local llTwoMonitors, lnScreenWidth, lnLeft,loIE

DECLARE INTEGER GetSystemMetrics IN user32;
    INTEGER nIndex

DECLARE INTEGER ShowWindow IN user32; 
    INTEGER hwnd,; 
    INTEGER nCmdShow

llTwoMonitors = (GetSystemMetrics(SM_CMONITORS) = 2)
loIE = CreateObject("InternetExplorer.Application")
loIE.Left = IIF(llTwomonitors,GetSystemMetrics(SM_CXMAXIMIZED),0) 
loIE.Top = 0
loIE.navigate("file://"+"path to the PDF")
ShowWindow(loIE.HWnd,SW_SHOWMAXIMIZED)

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top