How to Invoke GetSystemMetrics Windows API Function from VB

ID Number: Q77061

1.00

WINDOWS

Summary:

The Windows 3.0 API function call GetSystemMetrics can return useful

information about the Windows system. GetSystemMetrics can be

called directly from Visual Basic or from the custom Control

Development Kit (CDK) to get system metrics for a particular display

adapter, retrieve information about the Windows debug mode, or

retrieve information about a mouse configuration.

The Visual Basic CDK is now shipped as part of Microsoft Professional

Toolkit for Microsoft Visual Basic version 1.0 for Windows.

More Information:

The Windows 3.0 GetSystemMetrics function call retrieves information

about the system metrics. The system metrics are the widths and

heights of various display elements of the particular window display.

The GetSystemMetrics function can also return flags that indicate

whether the current Windows version is a debugging version, whether a

mouse is present, or whether the meaning of the left and right mouse

button has been changed. System metrics depend on the system display,

and may vary from display to display.

The Visual Basic declaration for GetSystemMetrics is:

Declare Function GetSystemMetrics% Lib user (ByVal nIndex%)

The value nIndex% specifies the system measurement to be retrieved.

All measurements are in pixels.

The value returned from the GetSystemMetrics% function specifies the

system metrics.

Below is a sample call to find if the present version of Windows is a

debugging version:

ScaleMode = 3 'select pixel

Print "Debugging version : ; GetSystemMetrics(SM_DEBUG)

The constants and meaning for nIndex% are as follows:

Constant Name(Value) Description

-------------------- -----------

SM_CXSCREEN(0)........Width of screen

SM_CYSCREEN(1)........Height of screen

SM_CXFRAME(32)........Width of window frame that can be sized

SM_CYFRAME(33)........Height of window frame that can be sized

SM_CXVSCROLL(2).......Width of arrow bitmap on vertical scroll bar

SM_CYVSCROL(20).......Height of arrow bitmap on vertical scroll bar

SM_CXHSCROLL(21)......Width of arrow bitmap on horizontal scroll bar

SM_CYHSCROLL(3).......Height of arrow bitmap on horizontal scroll

bar

SM_CYCAPTION(4).......Height of caption

SM_CXBORDER(5)........Width of window frame that cannot be sized

SM_CYBORDER(6)........Height of window frame that cannot be sized

SM_CXDLGFRAME(7)......Width of frame when window has WS_DLGFRAME

style

SM_CYDLGFRAME(8)......Height of frame when window has WS_DLGFRAME

style

SM_CXHTHUMB(10).......Width of thumb on horizontal scroll bar

SM_CYHTHUMB(9)........Height of thumb on horizontal scroll bar

SM_CXICON(11).........Width of icon

SM_CYICON(12).........Height of icon

SM_CXCURSOR(13).......Width of cursor

SM_CYCURSOR(14).......Height of cursor

SM_CYMENU(15).........Height of single-line menu

SM_CXFULLSCREEN(16)...Width of window client area for full-screen

window

SM_CYFULLSCREEN(17)...Height of window client area for full-screen

window (height - caption)

SM_CYKANJIWINDOW(18)..Height of Kanji window

SM_CXMINTRACK(34).....Minimum tracking width of window

SM_CYMINTRACK(35).....Minimum tracking height of window

SM_CXMIN(28)..........Minimum width of window

SM_CYMIN(29)..........Minimum width of window

SM_CXSIZE(30).........Width of bitmaps contained in the title bar

SM_CYSIZE(31).........Height of bitmaps contained in the title bar

SM_MOUSEPRESENT(19)...Mouse present

SM_DEBUG(22)..........Nonzero if Windows debug version

Reference(s):

"Programming Windows: the Microsoft Guide to Writing Applications for

Windows 3," Charles Petzold, Microsoft Press, 1990

"Microsoft Windows Software Development Kit: Reference Volume 1,"

version 3.0

WINSDK.HLP file shipped with Microsoft Windows 3.0 Software

Development Kit

Additional reference words: 1.00 3.00