Mongoose
February 28th, 2000, 02:53 PM
is there any way to get the size of the system toolbar ?? and if it's up or not?
i'm trying to position a window in the bottom right hand corner of the screen and i need to make sure i'm including the toolbar information with it.
thankx,
AndyK
February 28th, 2000, 03:10 PM
You mean taskbar (the one that has "Start" button)
to get the width of it you could just get screen's width and height is usually remaining same...28 pixels. If you want more accurate info on the taskbar, you could probably read them from registry (correct me if I'm wrong)
Good Luck!!!
Ravi Kiran
February 28th, 2000, 11:50 PM
There is a GetSystemMetrics api call which can give you a lot of information.
I had some time back wraped a class around it, specially for getting the active screen area ( Total screen area - ( Task bar + Any other app bars like MS-Office ) ).
Most of the unnecessary code is commented. use which ever you want:
option Explicit
' Class : CSystemMetrics : Encapsulates the System Metrics call to OS
'
' Just instanciate this class and read off the system settings from
' Global Functions/variables
private Enum SysMetricsVals
SM_CXSCREEN = 0
SM_CYSCREEN = 1
SM_CXVSCROLL = 2
SM_CYHSCROLL = 3
SM_CYCAPTION = 4
'''' SM_CXBORDER = 5
'''' SM_CYBORDER = 6
SM_CXDLGFRAME = 7
SM_CYDLGFRAME = 8
'''' SM_CYVTHUMB = 9
'''' SM_CXHTHUMB = 10
'''' SM_CXICON = 11
'''' SM_CYICON = 12
'''' SM_CXCURSOR = 13
'''' SM_CYCURSOR = 14
SM_CYMENU = 15 ' Single Line Menubar height
'''' SM_CXFULLSCREEN = 16
'''' SM_CYFULLSCREEN = 17
'''' SM_CYKANJIWINDOW = 18
'''' SM_MOUSEPRESENT = 19
'''' SM_CYVSCROLL = 20
'''' SM_CXHSCROLL = 21
'''' SM_DEBUG = 22
'''' SM_SWAPBUTTON = 23
'''' SM_RESERVED1 = 24
'''' SM_RESERVED2 = 25
'''' SM_RESERVED3 = 26
'''' SM_RESERVED4 = 27
'''' SM_CXMIN = 28
'''' SM_CYMIN = 29
'''' SM_CXSIZE = 30
'''' SM_CYSIZE = 31
SM_CXFRAME = 32
SM_CYFRAME = 33
'''' SM_CXMINTRACK = 34
'''' SM_CYMINTRACK = 35
'''' SM_CXDOUBLECLK = 36
'''' SM_CYDOUBLECLK = 37
'''' SM_CXICONSPACING = 38
'''' SM_CYICONSPACING = 39
'''' SM_MENUDROPALIGNMENT = 40
'''' SM_PENWINDOWS = 41
'''' SM_DBCSENABLED = 42
SM_CMOUSEBUTTONS = 43
''''#if(WINVER >= =&H00400)
SM_CXFIXEDFRAME = SM_CXDLGFRAME '/* ;win40 name change */
SM_CYFIXEDFRAME = SM_CYDLGFRAME '/* ;win40 name change */
SM_CXSIZEFRAME = SM_CXFRAME '/* ;win40 name change */
SM_CYSIZEFRAME = SM_CYFRAME '/* ;win40 name change */
'''' SM_SECURE = 44
'''' SM_CXEDGE = 45
'''' SM_CYEDGE = 46
'''' SM_CXMINSPACING = 47
'''' SM_CYMINSPACING = 48
'''' SM_CXSMICON = 49
'''' SM_CYSMICON = 50
'''' SM_CYSMCAPTION = 51
'''' SM_CXSMSIZE = 52
'''' SM_CYSMSIZE = 53
'''' SM_CXMENUSIZE = 54
'''' SM_CYMENUSIZE = 55
'''' SM_ARRANGE = 56
'''' SM_CXMINIMIZED = 57
'''' SM_CYMINIMIZED = 58
'''' SM_CXMAXTRACK = 59
'''' SM_CYMAXTRACK = 60
'''' SM_CXMAXIMIZED = 61
'''' SM_CYMAXIMIZED = 62
'''' SM_NETWORK = 63
'''' SM_CLEANBOOT = 67
'''' SM_CXDRAG = 68
'''' SM_CYDRAG = 69
'''''#endif /* WINVER >= =&H00400 */
'''' SM_SHOWSOUNDS = 70
'''''#if(WINVER >= =&H00400)
'''' SM_CXMENUCHECK = 71 ' /* Use instead of GetMenuCheckMarkDimensions()! */
'''' SM_CYMENUCHECK = 72
'''' SM_SLOWMACHINE = 73
'''' SM_MIDEASTENABLED = 74
'''''#endif /* WINVER >= =&H00400 */
'''''#if(_WIN32_WINNT >= =&H00400)
'''' SM_MOUSEWHEELPRESENT = 75
'''''#endif /* _WIN32_WINNT >= =&H00400 */
'''''#if (_WIN32_WINNT < =&H00400)
''''' SM_CMETRICS = 75
'''''#else
''''' SM_CMETRICS 76
'''''#End If
End Enum
private Enum SysParamsInfo_Action
SPI_GETWORKAREA = 48
End Enum
private Enum SysParamsInfo_WinINI
SPIF_NOTSetting = &H0&
SPIF_UPDATEINIFILE = &H1&
SPIF_SENDWININICHANGE = &H2&
SPIF_SENDCHANGE = SPIF_SENDWININICHANGE
End Enum
private Declare Function GetSystemMetrics Lib "user32" (byval nIndex as SysMetricsVals) as Long
private Declare Function SystemParametersInfo Lib "user32" Alias _
"SystemParametersInfoA" (byval uAction as SysParamsInfo_Action, _
byval uParam as Long, lpvParam as Any, _
byval fuWinIni as SysParamsInfo_WinINI) as Long
public WindowCaptionHeight as Long
public ResizeFrameXBorder as Long
public ResizeFrameYBorder as Long
public DlgFrameXBorder as Long
public DlgFrameYBorder as Long
public SingleLineMenuHeight as Long
private Type RECT
left as Long
top as Long
Right as Long
Bottom as Long
End Type
private rtWorkArea as RECT
public ScreenWorkArea_Left as Long 'all values in pixels.
public ScreenWorkArea_Top as Long
public ScreenWorkArea_Width as Long
public ScreenWorkArea_Height as Long
public NoofMouseButtons as Integer
private Sub Class_Initialize()
WindowCaptionHeight = GetSystemMetrics(SM_CYCAPTION)
ResizeFrameXBorder = GetSystemMetrics(SM_CXSIZEFRAME)
ResizeFrameYBorder = GetSystemMetrics(SM_CYSIZEFRAME)
DlgFrameXBorder = GetSystemMetrics(SM_CXFIXEDFRAME)
DlgFrameYBorder = GetSystemMetrics(SM_CYFIXEDFRAME)
SingleLineMenuHeight = GetSystemMetrics(SM_CYMENU)
' NoofMouseButtons = GetSystemMetrics(SM_CMOUSEBUTTONS)
SystemParametersInfo SPI_GETWORKAREA, 0, rtWorkArea, SPIF_NOTSetting
With rtWorkArea
ScreenWorkArea_Left = .left
ScreenWorkArea_Top = .top
ScreenWorkArea_Width = .Right - .left
ScreenWorkArea_Height = .Bottom - .top
End With
End Sub
Use it like this:
public Sub CenterForm(lpForm as Form, optional wrtScreenWorkArea as Boolean = true)
If wrtScreenWorkArea then
Dim tmpsysinfo as CSystemMetrics
Dim w1 as Single, h1 as Single
set tmpsysinfo = new CSystemMetrics
w1 = tmpsysinfo.ScreenWorkArea_Width * Screen.TwipsPerPixelX
h1 = tmpsysinfo.ScreenWorkArea_Height * Screen.TwipsPerPixelY
With lpForm
.ScaleMode = vbTwips ' Otherwise the calcs will go for toss!
.Move (w1 - .Width) / 2, (h1 - .Height) / 2
End With
Exit Sub
End If
With lpForm
.Move (Screen.Width - .Width) / 2, (Screen.Height - .Height) / 2
End With
End Sub
RK