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?
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?
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
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
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.
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
You say "my" but do you mean "any"?I want to position a form against the extreme right of my monitor
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.
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"?
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.
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.
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.
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.
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
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....
For my monitor I get these results: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
Divide the twips values by 1440 to get screen size in inches (or 567 to get values in cm)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
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
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