GetSystemMetrics

Syntax

int GetSystemMetrics(nIndex)

This function retrieves the system metrics. The system metrics are the widths and heights of various display elements of the Windows display. The GetSystemMetrics function can also return flags that indicate whether the current version is a debugging version, whether a mouse is present, or whether the meaning of the left and right mouse buttons have been exchanged.

Parameter Type/Description  

nIndex int Specifies the system measurement to be retrieved. All measurements are given in pixels. The system measurement must be one of the values listed in Table R.10, “System Metric Indexes.”  

Return Value

The return value specifies the requested system metric.

Comments

System metrics depend on the system display and may vary from display to display. Table R.10 lists the system-metric values for the nIndex parameter:

Table R.10 System Metric Indexes

Index Meaning

SM_CXSCREEN Width of screen.
SM_CYSCREEN Height of screen.
SM_CXFRAME Width of window frame that can be sized.
SM_CYFRAME Height of window frame that can be sized.
SM_CXVSCROLL Width of arrow bitmap on vertical scroll bar.
SM_CYVSCROLL Height of arrow bitmap on vertical scroll bar.
SM_CXHSCROLL Width of arrow bitmap on horizontal scroll bar.
SM_CYHSCROLL Height of arrow bitmap on horizontal scroll bar.
SM_CYCAPTION Height of caption.
SM_CXBORDER Width of window frame that cannot be sized.
SM_CYBORDER Height of window frame that cannot be sized.
SM_CXDLGFRAME Width of frame when window has WS_DLGFRAME style.
SM_CYDLGFRAME Height of frame when window has WS_DLGFRAME style.
SM_CXHTHUMB Width of thumb box on horizontal scroll bar.
SM_CYVTHUMB Height of thumb box on vertical scroll bar.
SM_CXICON Width of icon.
SM_CYICON Height of icon.
SM_CXCURSOR Width of cursor.
SM_CYCURSOR Height of cursor.
SM_CYMENU Height of single-line menu bar.
SM_CXFULLSCREEN Width of window client area for full-screen window.
SM_CYFULLSCREEN Height of window client area for full-screen window (equivalent to the height of the screen minus the height of the window caption).
SM_CYKANJIWINDOW Height of Kanji window.

Table R.10 System Metric Indexes (continued)

Index Meaning

SM_CXMINTRACK Minimum tracking width of window.
SM_CYMINTRACK Minimum tracking height of window.
SM_CXMIN Minimum width of window.
SM_CYMIN Minimum height of window.
SM_CXSIZE Width of bitmaps contained in the title bar.
SM_CYSIZE Height of bitmaps contained in the title bar.
SM_MOUSEPRESENT Nonzero if mouse hardware installed.
SM_DEBUG Nonzero if Windows debugging version.
SM_SWAPBUTTON Nonzero if left and right mouse buttons swapped.