PC Review


Reply
Thread Tools Rate Thread

API basics and getdevicecaps

 
 
Jay
Guest
Posts: n/a
 
      24th Nov 2008
Hi -

WinXPProSP2/Office 2003: I'm programming in MS Access VBA and need to call a
WinAPI function. I'm new to coding API calls, so I don't yet understand the
conventions very well.

My specific goal is to determine the number of pixels per physical inch of
screen -both horizontally and vertically - for use elsewhere in my
application. From what I can tell, the 'getdevicecaps' function provides
pixels-per-inch (PPI), but I don't know how to implement it in VBA. So far,
I have the following code in a VBA module and would appreciate any advice on
how to code the function arguments (and anything else necessary to get this
to work properly):

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

Public Function GetHPixelsPerInch() As Long
'Get horizontal pixels per inch
pixH = GetDeviceCaps(<I don't know what goes here>)
GetHPixelsPerInch = pixH
End Function

Public Function GetVPixelsPerInch() As Long
'Get vertical pixels per inch
pixV = GetDeviceCaps(<I don't know what goes here>)
GetVPixelsPerInch = pixV
End Function

Sub screenPixPerInch()
MsgBox "X PPI = " & GetHPixelsPerInch & Chr(13) & _
"Y PPI = " & GetVPixelsPerInch
End Sub
-----------
Thanks,
Jay

 
Reply With Quote
 
 
 
 
Jay
Guest
Posts: n/a
 
      24th Nov 2008
Please disregard this post; I have re-posted in Discussions in Windows API.

"Jay" wrote:

> Hi -
>
> WinXPProSP2/Office 2003: I'm programming in MS Access VBA and need to call a
> WinAPI function. I'm new to coding API calls, so I don't yet understand the
> conventions very well.
>
> My specific goal is to determine the number of pixels per physical inch of
> screen -both horizontally and vertically - for use elsewhere in my
> application. From what I can tell, the 'getdevicecaps' function provides
> pixels-per-inch (PPI), but I don't know how to implement it in VBA. So far,
> I have the following code in a VBA module and would appreciate any advice on
> how to code the function arguments (and anything else necessary to get this
> to work properly):
>
> Declare Function GetDeviceCaps Lib "gdi32" _
> (ByVal hdc As Long, ByVal nIndex As Long) As Long
>
> Public Function GetHPixelsPerInch() As Long
> 'Get horizontal pixels per inch
> pixH = GetDeviceCaps(<I don't know what goes here>)
> GetHPixelsPerInch = pixH
> End Function
>
> Public Function GetVPixelsPerInch() As Long
> 'Get vertical pixels per inch
> pixV = GetDeviceCaps(<I don't know what goes here>)
> GetVPixelsPerInch = pixV
> End Function
>
> Sub screenPixPerInch()
> MsgBox "X PPI = " & GetHPixelsPerInch & Chr(13) & _
> "Y PPI = " & GetVPixelsPerInch
> End Sub
> -----------
> Thanks,
> Jay
>

 
Reply With Quote
 
Kelly
Guest
Posts: n/a
 
      27th Nov 2008
Start here, Jay.
http://www.microsoft.com/technet/scr...r/default.mspx

--

All the Best and Happy Turkey Day,
Kelly (MS-MVP/DTS&XP)

Taskbar Repair Tool Plus!
http://www.kellys-korner-xp.com/taskbarplus!.htm


"Jay" <(E-Mail Removed)> wrote in message
news:4F194023-3B1A-4367-BC45-(E-Mail Removed)...
> Hi -
>
> WinXPProSP2/Office 2003: I'm programming in MS Access VBA and need to call
> a
> WinAPI function. I'm new to coding API calls, so I don't yet understand
> the
> conventions very well.
>
> My specific goal is to determine the number of pixels per physical inch of
> screen -both horizontally and vertically - for use elsewhere in my
> application. From what I can tell, the 'getdevicecaps' function provides
> pixels-per-inch (PPI), but I don't know how to implement it in VBA. So
> far,
> I have the following code in a VBA module and would appreciate any advice
> on
> how to code the function arguments (and anything else necessary to get
> this
> to work properly):
>
> Declare Function GetDeviceCaps Lib "gdi32" _
> (ByVal hdc As Long, ByVal nIndex As Long) As Long
>
> Public Function GetHPixelsPerInch() As Long
> 'Get horizontal pixels per inch
> pixH = GetDeviceCaps(<I don't know what goes here>)
> GetHPixelsPerInch = pixH
> End Function
>
> Public Function GetVPixelsPerInch() As Long
> 'Get vertical pixels per inch
> pixV = GetDeviceCaps(<I don't know what goes here>)
> GetVPixelsPerInch = pixV
> End Function
>
> Sub screenPixPerInch()
> MsgBox "X PPI = " & GetHPixelsPerInch & Chr(13) & _
> "Y PPI = " & GetVPixelsPerInch
> End Sub
> -----------
> Thanks,
> Jay
>


 
Reply With Quote
 
Jay
Guest
Posts: n/a
 
      17th Dec 2008
Hi Kelly -

Sorry for the slow reply. Thank you for the scriptcenter resource.

Jay

"Kelly" wrote:

> Start here, Jay.
> http://www.microsoft.com/technet/scr...r/default.mspx
>
> --
>
> All the Best and Happy Turkey Day,
> Kelly (MS-MVP/DTS&XP)
>
> Taskbar Repair Tool Plus!
> http://www.kellys-korner-xp.com/taskbarplus!.htm
>
>
> "Jay" <(E-Mail Removed)> wrote in message
> news:4F194023-3B1A-4367-BC45-(E-Mail Removed)...
> > Hi -
> >
> > WinXPProSP2/Office 2003: I'm programming in MS Access VBA and need to call
> > a
> > WinAPI function. I'm new to coding API calls, so I don't yet understand
> > the
> > conventions very well.
> >
> > My specific goal is to determine the number of pixels per physical inch of
> > screen -both horizontally and vertically - for use elsewhere in my
> > application. From what I can tell, the 'getdevicecaps' function provides
> > pixels-per-inch (PPI), but I don't know how to implement it in VBA. So
> > far,
> > I have the following code in a VBA module and would appreciate any advice
> > on
> > how to code the function arguments (and anything else necessary to get
> > this
> > to work properly):
> >
> > Declare Function GetDeviceCaps Lib "gdi32" _
> > (ByVal hdc As Long, ByVal nIndex As Long) As Long
> >
> > Public Function GetHPixelsPerInch() As Long
> > 'Get horizontal pixels per inch
> > pixH = GetDeviceCaps(<I don't know what goes here>)
> > GetHPixelsPerInch = pixH
> > End Function
> >
> > Public Function GetVPixelsPerInch() As Long
> > 'Get vertical pixels per inch
> > pixV = GetDeviceCaps(<I don't know what goes here>)
> > GetVPixelsPerInch = pixV
> > End Function
> >
> > Sub screenPixPerInch()
> > MsgBox "X PPI = " & GetHPixelsPerInch & Chr(13) & _
> > "Y PPI = " & GetVPixelsPerInch
> > End Sub
> > -----------
> > Thanks,
> > Jay
> >

>
>

 
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
Re: GetDeviceCAPS Duplex Printers Andrew Kennard Microsoft Windows 2000 Printing 0 4th Feb 2008 11:39 AM
What to do when GetDeviceCaps doesn't? Phill W. Microsoft VB .NET 2 18th Aug 2006 03:41 PM
GetDeviceCaps slow with xp sp2 relay73 Windows XP Print / Fax 0 3rd Feb 2005 04:05 PM
get same value for GetDeviceCaps parameters Nancy Microsoft VB .NET 3 3rd Jun 2004 10:50 PM
GetDeviceCaps function de Massas Windows XP General 0 3rd Dec 2003 07:01 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:09 PM.