PC Review


Reply
Thread Tools Rate Thread

How to determine the DPI setting for current user

 
 
=?Utf-8?B?SldTMzE1?=
Guest
Posts: n/a
 
      27th Apr 2006
Does anyone know how to check to see what the DPI setting is using VBA in
Access 2003? I want to be able to determine if the font size is "small" 96
dpi or "Large" 120 dpi and issue a message to the user.

Thanks!
Jerry
 
Reply With Quote
 
 
 
 
Brendan Reynolds
Guest
Posts: n/a
 
      28th Apr 2006

You can do it with the following API calls. Note, though, that if you change
the DPI setting, the new value can not be detected until Windows is
re-started.

Option Compare Database
Option Explicit

Private Const LOGPIXELSX As Long = 88

Private Declare Function GetDeviceCaps Lib "gdi32.dll" ( _
ByVal hdc As Long, _
ByVal nIndex As Long) As Long

Private Declare Function GetDC Lib "user32.dll" ( _
ByVal hwnd As Long) As Long

Declare Function ReleaseDC Lib "user32.dll" ( _
ByVal hwnd As Long, _
ByVal hdc As Long) As Long

Public Function GetDpi() As Long

Dim hdcScreen As Long
Dim iDPI As Long

iDPI = -1
hdcScreen = GetDC(0)
If (hdcScreen) Then
iDPI = GetDeviceCaps(hdcScreen, LOGPIXELSX)
ReleaseDC 0, hdcScreen
End If

GetDpi = iDPI

End Function

--
Brendan Reynolds
Access MVP

"JWS315" <(E-Mail Removed)> wrote in message
news:6687F316-9204-441C-9C11-(E-Mail Removed)...
> Does anyone know how to check to see what the DPI setting is using VBA in
> Access 2003? I want to be able to determine if the font size is "small"
> 96
> dpi or "Large" 120 dpi and issue a message to the user.
>
> Thanks!
> Jerry



 
Reply With Quote
 
=?Utf-8?B?SldTMzE1?=
Guest
Posts: n/a
 
      28th Apr 2006
Thanks Brendon - It works great!

Jerry

"Brendan Reynolds" wrote:

>
> You can do it with the following API calls. Note, though, that if you change
> the DPI setting, the new value can not be detected until Windows is
> re-started.
>
> Option Compare Database
> Option Explicit
>
> Private Const LOGPIXELSX As Long = 88
>
> Private Declare Function GetDeviceCaps Lib "gdi32.dll" ( _
> ByVal hdc As Long, _
> ByVal nIndex As Long) As Long
>
> Private Declare Function GetDC Lib "user32.dll" ( _
> ByVal hwnd As Long) As Long
>
> Declare Function ReleaseDC Lib "user32.dll" ( _
> ByVal hwnd As Long, _
> ByVal hdc As Long) As Long
>
> Public Function GetDpi() As Long
>
> Dim hdcScreen As Long
> Dim iDPI As Long
>
> iDPI = -1
> hdcScreen = GetDC(0)
> If (hdcScreen) Then
> iDPI = GetDeviceCaps(hdcScreen, LOGPIXELSX)
> ReleaseDC 0, hdcScreen
> End If
>
> GetDpi = iDPI
>
> End Function
>
> --
> Brendan Reynolds
> Access MVP
>
> "JWS315" <(E-Mail Removed)> wrote in message
> news:6687F316-9204-441C-9C11-(E-Mail Removed)...
> > Does anyone know how to check to see what the DPI setting is using VBA in
> > Access 2003? I want to be able to determine if the font size is "small"
> > 96
> > dpi or "Large" 120 dpi and issue a message to the user.
> >
> > Thanks!
> > Jerry

>
>
>

 
Reply With Quote
 
Brendan Reynolds
Guest
Posts: n/a
 
      28th Apr 2006
Great, I'm glad it works for you.

I'm not actually sure whether the call to ReleaseDC is required in VBA. I
adapted it from an example in C++, and this *might* be one of those
housekeeping tasks that you have to do in C++ but VB/VBA does automatically
for you. I left it in on the principle of 'better safe than sorry'! :-)

--
Brendan Reynolds
Access MVP

"JWS315" <(E-Mail Removed)> wrote in message
news06AF832-02E1-43B5-8843-(E-Mail Removed)...
> Thanks Brendon - It works great!
>
> Jerry
>
> "Brendan Reynolds" wrote:
>
>>
>> You can do it with the following API calls. Note, though, that if you
>> change
>> the DPI setting, the new value can not be detected until Windows is
>> re-started.
>>
>> Option Compare Database
>> Option Explicit
>>
>> Private Const LOGPIXELSX As Long = 88
>>
>> Private Declare Function GetDeviceCaps Lib "gdi32.dll" ( _
>> ByVal hdc As Long, _
>> ByVal nIndex As Long) As Long
>>
>> Private Declare Function GetDC Lib "user32.dll" ( _
>> ByVal hwnd As Long) As Long
>>
>> Declare Function ReleaseDC Lib "user32.dll" ( _
>> ByVal hwnd As Long, _
>> ByVal hdc As Long) As Long
>>
>> Public Function GetDpi() As Long
>>
>> Dim hdcScreen As Long
>> Dim iDPI As Long
>>
>> iDPI = -1
>> hdcScreen = GetDC(0)
>> If (hdcScreen) Then
>> iDPI = GetDeviceCaps(hdcScreen, LOGPIXELSX)
>> ReleaseDC 0, hdcScreen
>> End If
>>
>> GetDpi = iDPI
>>
>> End Function
>>
>> --
>> Brendan Reynolds
>> Access MVP
>>
>> "JWS315" <(E-Mail Removed)> wrote in message
>> news:6687F316-9204-441C-9C11-(E-Mail Removed)...
>> > Does anyone know how to check to see what the DPI setting is using VBA
>> > in
>> > Access 2003? I want to be able to determine if the font size is
>> > "small"
>> > 96
>> > dpi or "Large" 120 dpi and issue a message to the user.
>> >
>> > Thanks!
>> > Jerry

>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Determine/Set Current User Short Date Format theinvisibleGhost Microsoft C# .NET 6 7th Sep 2007 05:25 PM
Determine Effective File Permissions For Current User BDB Microsoft C# .NET 0 13th Mar 2006 05:46 PM
Determine the current cell while inside a User Defined Function pmax Microsoft Excel Programming 2 1st Feb 2006 11:47 PM
How to determine the current user's rights Bob Trabucco Microsoft ADO .NET 1 8th Nov 2004 08:40 PM
Setting HttpWebRequest Credentials to be current user Jamie Microsoft ASP .NET 4 1st Mar 2004 09:51 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:46 PM.