Results 1 to 14 of 14
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919

    Screen width in twips


    How do I get the screen width of the current display monitor in twips........... or inches for that matter. There seems to be a metrics function for this, but I'm not having any success in finding it. Something I'm missing from References?

  2. #2
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Don't know...but why, exactly, do you need this? If we know your underlying purpose, we may be able to better help.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    According to the documentation for the function GetSystemMetrics, the code below ought to return the width of my monitor in pixels. What it does return is 1920, a value I believe to relate to the resolution of the monitor, not its physical width measured in pixels. I know from some empirical experimenting that my monitor is about 24,700 pixels wide, using 1440 pixels per inch in my calculations AND reporting X screen coordinates from the code sheet of an active form. Like Me.Left + Me.Width from a form shoved against the right side of my screen.

    (I found the function declaration via a google search)

    Code:
    Option Compare Database
    Option Explicit
    
    Private Declare Function GetSystemMetrics Lib "user32" _
     (ByVal nIndex As Long) As Long
    
    Public Const SM_CXFULLSCREEN = 16
    
    Public scrX As Variant
    
    Public Function eRepStartup()
    '*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*==
    ' We need to know how wide the current monitor screen is in TWIPS SM_CXMAXTRACK
    '*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*==
    
    MsgBox GetSystemMetrics(SM_CXFULLSCREEN)
    End Function

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    IIRC the value returned is a unit of TWIPS, which I think is 1440 pixels per. Maybe look up TWIPS.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    I want to position a form against the extreme right of my monitor. If I can determine the maximum X value, I can then calculate the left position with knowing the width of the form. I.e., Left = Max - width

  6. #6
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    I want to position a form against the extreme right of my monitor
    You say "my" but do you mean "any"?
    If "my", just use MoveSize to move the form over. You can even prevent the form from resizing (at least on open). That assumes you won't be altering your resolution.
    And what if the application window is resized? The form stays where it is? I ask because some methods are relative to the application window and not the screen.

  7. #7
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    I don't know what the question is? I have a form. When I Open that form, I want the form positioned at the top and extreme right of the screen NOT relative to the Access window, with regard to the current monitor.
    You say "my" but do you mean "any"?

  8. #8
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    In the world of Access, there are 1440 twips per inch. When speaking of resolution of a monitor the actual size of a twip is different, i.e., like my monitor is 1920 twips/inch. At least that's always been my understanding.

  9. #9
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Quote Originally Posted by GraeagleBill View Post
    I don't know what the question is? I have a form. When I Open that form, I want the form positioned at the top and extreme right of the screen NOT relative to the Access window, with regard to the current monitor.
    You said "my" monitor. If it's not "any" monitor, then I was simply going to imply that your method might be overkill. In addition, to make it relative to the window, I'm pretty sure it has to be a popup form, which I don't think you've revealed.

  10. #10
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Sorry Micron, I didn't mean to be so vague. The form(s) I want to "popup" need to appear at the far right of "any" monitor the app is installed. The form(s) are basically tall and narrow popup forms offering HELP text and images that the user can have displayed simultaneously with the app while they are learning to perform complex tasks. At this point, I've been successful in positioning the forms with the simple use of the DoCmd.MoveSize. However, for the time being, I abandoned any reliability on the use of GetSystemMetrics as a means of capturing the current value of a form's "X" displacement on the monitor. In the screenshot below, you can observe the discrepancy I encountered that left my head spinning, so in order to move on I created a variable in the app's settings offering the user the opportunity to put the HELP popups wherever desired.

    GetSystemMetrics reports 18360 twips while Me.Left reports 21350 twips. Based on the physical measurement of the monitor in use, 21,350 twips given 1440 twips/inch is correct The screen resolution of the monitor in use is 1920. This discrepancy was driving me Cuckoo yesterday so I "through in the towel" in order to move on with the user setting approach at least for now.

    Click image for larger version. 

Name:	000.jpg 
Views:	15 
Size:	14.5 KB 
ID:	33503

  11. #11
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    So bubble help is a bit wonky at times, sometimes activating right away, sometimes not (see property sheet if you're not aware). That might be an option for short messages.
    Then there is the status bar at the bottom, which users can be trained to look for, but it's not intuitive to most people or something they look at naturally.
    There's other ways to provide guidance too
    - popup form because there was a question mark icon associated with some control. 1 form, different sizes and messages determined before opening might be good enough.
    - custom context menus for controls where a right click brings up an option to get more info
    - probably many others that my tired old brain never learned or forgot.

  12. #12
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Micron. Sorry, I've already laid claim to "tired old brain". I thought "Old Geezer" would have made that clear!

    With the current app, and more importantly its primary user, the HELP popups have way too much content to use otherwise short blasts of hints. While the discrepancy noted in post #10 still bugs me, I really need to move on so I'll mark this thread complete so subscribed folks will not be bothered by it.

    Thanks for your thoughts,
    Bill

  13. #13
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    I know you've put this aside but in case you or anyone else is interested here are some functions based on the Metrics code....

    Code:
    Public Function MetricsScreenHeight _        (Optional ConvertToTwips As Boolean = True)
    MetricsScreenHeight = System(SM_CYSCREEN, ConvertToTwips)
    End Function
    
    
    Public Function MetricsScreenWidth _
            (Optional ConvertToTwips As Boolean = True)
    MetricsScreenWidth = System(SM_CXSCREEN, ConvertToTwips)
    End Function
    For my monitor I get these results:
    Code:
    ?MetricsScreenWidth = 25200 'screen width in twips  
    
    ?MetricsScreenWidth (False) = 1680 'screen width in pixels i.e. resolution
    
    ?MetricsScreenHeight = 15750 'screen height in twips 
    ?MetricsScreenHeight (False) = 1050 'screen height in pixels i.e. resolution
    Divide the twips values by 1440 to get screen size in inches (or 567 to get values in cm)
    Width = 25200/1440 = 17.5 inches or 44.4 cm
    Height= 15750/1440 =10.94 inches or 27.8 cm

    HTH

    I can supply the full metrics module code if anyone would find it useful
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  14. #14
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Thanks a bunch! I'll save the link to this thread and pursue some study of your post in a day or so............... busy busy!
    Bill

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Find Users screen resolution in twips
    By jsunnb in forum Programming
    Replies: 10
    Last Post: 03-20-2024, 05:44 PM
  2. Divide Access to half a screen width
    By jaryszek in forum Modules
    Replies: 6
    Last Post: 10-05-2017, 11:40 PM
  3. Replies: 3
    Last Post: 04-10-2015, 02:35 PM
  4. Section Width is greater than page width
    By snowboarder234 in forum Reports
    Replies: 3
    Last Post: 07-31-2013, 09:06 PM
  5. Forms Mouse Position in Twips
    By Bjg1986 in forum Programming
    Replies: 2
    Last Post: 04-10-2013, 11:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums