![]() |
Why does SPI_GETWORKAREA come in too large?
This is a question for all of the MVP's out there. I use this code to
get the screen size and adjust my userform to fit. Can anyone explain why I have to multiply the returned screen size by 0.75 in order for things to line up correctly? Thanks, Die_Another_Day Option Explicit Private Const SPI_GETWORKAREA = 48 Private Declare Function SystemParametersInfo Lib "user32" _ Alias "SystemParametersInfoA" (ByVal uAction As Long, _ ByVal uParam As Long, ByRef lpvParam As Any, _ ByVal fuWinIni As Long) As Long Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Sub SizeForm() Dim nRect As RECT SystemParametersInfo SPI_GETWORKAREA, 0, nRect, 0 With UserForm1 .Top = nRect.Top .Left = nRect.Left .Width = (nRect.Right - nRect.Left) * 0.75 .Height = (nRect.Bottom - nRect.Top) * 0.75 End With UserForm1.Show End Sub |
Why does SPI_GETWORKAREA come in too large?
It's discussed in general he
https://www.informit.com/articles/ar...&seqNum=2&rl=1 -- Regards, Tom Ogilvy "Die_Another_Day" wrote: This is a question for all of the MVP's out there. I use this code to get the screen size and adjust my userform to fit. Can anyone explain why I have to multiply the returned screen size by 0.75 in order for things to line up correctly? Thanks, Die_Another_Day Option Explicit Private Const SPI_GETWORKAREA = 48 Private Declare Function SystemParametersInfo Lib "user32" _ Alias "SystemParametersInfoA" (ByVal uAction As Long, _ ByVal uParam As Long, ByRef lpvParam As Any, _ ByVal fuWinIni As Long) As Long Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Sub SizeForm() Dim nRect As RECT SystemParametersInfo SPI_GETWORKAREA, 0, nRect, 0 With UserForm1 .Top = nRect.Top .Left = nRect.Left .Width = (nRect.Right - nRect.Left) * 0.75 .Height = (nRect.Bottom - nRect.Top) * 0.75 End With UserForm1.Show End Sub |
Why does SPI_GETWORKAREA come in too large?
Thanks Tom! Keep smoking that good stuff you got over there!!
Die_Another_Day "Tom Ogilvy" wrote in message ... It's discussed in general he https://www.informit.com/articles/ar...&seqNum=2&rl=1 -- Regards, Tom Ogilvy "Die_Another_Day" wrote: This is a question for all of the MVP's out there. I use this code to get the screen size and adjust my userform to fit. Can anyone explain why I have to multiply the returned screen size by 0.75 in order for things to line up correctly? Thanks, Die_Another_Day Option Explicit Private Const SPI_GETWORKAREA = 48 Private Declare Function SystemParametersInfo Lib "user32" _ Alias "SystemParametersInfoA" (ByVal uAction As Long, _ ByVal uParam As Long, ByRef lpvParam As Any, _ ByVal fuWinIni As Long) As Long Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Sub SizeForm() Dim nRect As RECT SystemParametersInfo SPI_GETWORKAREA, 0, nRect, 0 With UserForm1 .Top = nRect.Top .Left = nRect.Left .Width = (nRect.Right - nRect.Left) * 0.75 .Height = (nRect.Bottom - nRect.Top) * 0.75 End With UserForm1.Show End Sub |
All times are GMT +1. The time now is 03:49 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com