Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Open a pop up form maximized  on detected 2nd monitor

Posted on 2011-09-21
13
544 Views
Last Modified: 2012-05-12
Ok this is a doozy.  I have a microsoft access application that needs to

1) detect a 2nd monitor if one is attatched
2) If there is a 2nd monitor attatched when they click the button to open the popup form i need the form to be opened on that 2nd monitor in maximized state.

Maximizing a form is easy detecting a 2nd monitor in VBA and opening the pop up form there not so much.  I have looked at several vb6 classes but not quite sure how to proceed, this is one case that vb.net is much easier than vba :(  Can anyone help?
0
Comment
Question by:ShinZan
  • 4
  • 4
  • 2
  • +2
13 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 36577930
Even if this were possible, dual monitors have been known to wreak havoc with Access.

The position/location of forms (or other objects) on another monitor are sometimes saved, meaning when a person with a single monitor opens the app, they may not be able to access the objects.

So on top of what you already requested, you will have to know when a single monitor is being used and decide what to do then.

Finally you may also have to figure out what to do if this is a multi-user app with a combination of single and dual monitors.

JeffCoachman
0
 

Author Comment

by:ShinZan
ID: 36577995
As far as wreaking havoc I have not issues.  I have had this application running this way manually for a couple of years, i have seen competitor software do this via the vb.net monitors collection.

I would have thought this simple.  I don't care which monitor access starts on i just want thie particular form to automatically open on the 2nd one whether its up down left right or wherever.

Competitor software in JAVA also has this feature so i can't believe in VBA it can't be done.
0
 

Author Comment

by:ShinZan
ID: 36578013
when a single monitor is available the form should just opne as in docmd.openform "BLAH" and wherever it goes is fine.  As it stands now the dual monitor system is the way i've used it for a good while, the form is a popup so when it opens on monitor 1 I just manually drag it over to monitor 2 and maximize it.  So the manual process works fine but users are not the sharpest tools in the shed.  If they have the 2nd monitor up and windows is in extend desktop mode then this is a very useful feature. basically the 2nd form is a monitor dashboard for the 1st.
0
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
LVL 75
ID: 36578014
"Even if this were possible, dual monitors have been known to wreak havoc with Access."

Can't say I've ever had an issue, and I've been using dual monitors since 1998 - about the time it all started ...

mx
0
 
LVL 75
ID: 36578026
On the other hand, I'm totally against maximizing forms.  Windows is plural for a reason.  Imagine if Quickbooks Pro forced all windows to max ... yikes.  Only in the Access world is this done, I guess because you 'can'.

mx
0
 

Author Comment

by:ShinZan
ID: 36580152
I've requested that this question be deleted for the following reason:

no help
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 36578330
<Can't say I've ever had an issue, and I've been using dual monitors since 1998 - about the time it all started ...>
Yeah, I seem to remember at least two posts here where it was an issue.

Can't say what the ultimate issue was, only that the OP would state that the issue only appeared on dual monitor setups
So it could have been anything.
0
 
LVL 11

Expert Comment

by:kbirecki
ID: 36579855
@shinzan, if an answer can be demonstrated, are you still interested?  Our do you just want to delete the question at this point?
0
 
LVL 14

Expert Comment

by:Brook Braswell
ID: 36580007
0
 
LVL 14

Expert Comment

by:Brook Braswell
ID: 36580097
Modify the code at the bottom of the above link in this way...
' in a module...
Public gMonCount as integer

Public Type WindowsRect
lngLeft As Long
lngTop As Long
lngRight As Long
lngBottom As Long
End Type

Public Declare Function EnumDisplayMonitors Lib "user32.dll" ( _
ByVal lngHDC As Long, _
ByVal lngPointer As Long, _
ByVal lngProcAddress As Long, _
ByVal lngParam As Long) As Boolean

Public Function EnumAllMonitorsProc( _
ByVal lngHMon As Long, _
ByVal lngHDC As Long, _
ByRef objRect As WindowsRect, _
ByVal lngParam As Long) As Boolean

Dim strMessage As String

gMonCount = gMonCount + 1

strMessage = ""
strMessage = strMessage & Str(lngHMon) & vbNewLine
strMessage = strMessage & Str(lngHDC) & vbNewLine
strMessage = strMessage & Str(objRect.lngLeft) & ", " & Str(objRect.lngTop) & ", " & Str(objRect.lngRight) & ", " & Str(objRect.lngBottom) & vbNewLine
strMessage = strMessage & Str(lngParam)

EnumAllMonitorsProc = True

End Function

' in your form
' perhaps in a button click to determine
Private Sub cmbMonitorSearch()
        Dim blnRetVal As Boolean
        gMonCount = 0
        blnRetVal = EnumDisplayMonitors(0, 0, AddressOf EnumAllMonitorsProc, 0)
        MsgBox "There are " & gMonCount & " Monitors"
        If Not blnRetVal Then
           MsgBox (Str(ERR.LastDllError))
        End If

End Sub

Open in new window

0
 
LVL 14

Accepted Solution

by:
Brook Braswell earned 500 total points
ID: 36580135
You can then know in EnumAllMonitors what the starting left position is of each monitor..

Create additional Public vars - you could make these an array if you wish:
Public gMon1Left as single
Public gMon2Left as single
Public gMon3Left as single
Public gMon4Left as single

in the EnumAllMonitors:

gMonCount = gMonCount + 1
SELECT CASE gMonCount
CASE 1
  gMon1Left = objRect.lngLeft * 15 ' i use a multiplier to get the pixels
CASE 2
  gMon2Left = objRect.lngLeft * 15 ' i use a multiplier to get the pixels
CASE 3
  gMon3Left = objRect.lngLeft * 15 ' i use a multiplier to get the pixels
CASE 4
  gMon4Left = objRect.lngLeft * 15 ' i use a multiplier to get the pixels
END SELECT

' in your calling sub...

        Dim blnRetVal As Boolean
        gMonCount = 0
        blnRetVal = EnumDisplayMonitors(0, 0, AddressOf EnumAllMonitorsProc, 0)
        MsgBox "There are " & gMonCount & " Monitors"
        If Not blnRetVal Then
           MsgBox (Str(ERR.LastDllError))
        End If
        Me.Left = gMon2Left + 0 ' set your offset here unless you want to set it at the left most side...
        me.top = 0 ' just to put yourself in a corner


0
 
LVL 14

Expert Comment

by:Brook Braswell
ID: 36580153
I have tested this and it works -
0
 

Author Closing Comment

by:ShinZan
ID: 36583024
Thanks
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question