GetSystemMetrics retrieves various system metrics and system configuration settings.System metrics are the dimensions (widths and heights) of Windows display elements. All dimensions retrieved by GetSystemMetrics are in pixels.
Code:Private Declare Function apiGetSystemMetrics Lib "user32" Alias "GetSystemMetrics" (ByVal nIndex As Int32) As Int32 Const SM_CXSCREEN As Int32 = 0 'X Size of screen Const SM_CYSCREEN As Int32 = 1 'Y Size of Screen Const SM_CXVSCROLL As Int32 = 2 'X Size of arrow in vertical scroll bar. Const SM_CYHSCROLL As Int32 = 3 'Y Size of arrow in horizontal scroll bar Const SM_CYCAPTION As Int32 = 4 'Height of windows caption Const SM_CXBORDER As Int32 = 5 'Width of no-sizable borders Const SM_CYBORDER As Int32 = 6 'Height of non-sizable borders Const SM_CXDLGFRAME As Int32 = 7 'Width of dialog box borders Const SM_CYDLGFRAME As Int32 = 8 'Height of dialog box borders Const SM_CYVTHUMB As Int32 = 9 'Height of scroll box on horizontal scroll bar Const SM_CXHTHUMB As Int32 = 10 ' Width of scroll box on horizontal scroll bar Const SM_CXICON As Int32 = 11 'Width of standard icon Const SM_CYICON As Int32 = 12 'Height of standard icon Const SM_CXCURSOR As Int32 = 13 'Width of standard cursor Const SM_CYCURSOR As Int32 = 14 'Height of standard cursor Const SM_CYMENU As Int32 = 15 'Height of menu Const SM_CXFULLSCREEN As Int32 = 16 'Width of client area of maximized window Const SM_CYFULLSCREEN As Int32 = 17 'Height of client area of maximized window Const SM_CYKANJIWINDOW As Int32 = 18 'Height of Kanji window Const SM_MOUSEPRESENT As Int32 = 19 'True is a mouse is present Const SM_CYVSCROLL As Int32 = 20 'Height of arrow in vertical scroll bar Const SM_CXHSCROLL As Int32 = 21 'Width of arrow in vertical scroll bar Const SM_DEBUG As Int32 = 22 'True if deugging version of windows is running Const SM_SWAPBUTTON As Int32 = 23 'True if left and right buttons are swapped. Const SM_CXMIN As Int32 = 28 'Minimum width of window Const SM_CYMIN As Int32 = 29 'Minimum height of window Const SM_CXSIZE As Int32 = 30 'Width of title bar bitmaps Const SM_CYSIZE As Int32 = 31 'height of title bar bitmaps Const SM_CXMINTRACK As Int32 = 34 'Minimum tracking width of window Const SM_CYMINTRACK As Int32 = 35 'Minimum tracking height of window Const SM_CXDOUBLECLK As Int32 = 36 'double click width Const SM_CYDOUBLECLK As Int32 = 37 'double click height Const SM_CXICONSPACING As Int32 = 38 'width between desktop icons Const SM_CYICONSPACING As Int32 = 39 'height between desktop icons Const SM_MENUDROPALIGNMENT As Int32 = 40 'Zero if popup menus are aligned to the left of the memu bar item. True if it is aligned to the right. Const SM_PENWINDOWS As Int32 = 41 'The handle of the pen windows DLL if loaded. Const SM_DBCSENABLED As Int32 = 42 'True if double byte characteds are enabled Const SM_CMOUSEBUTTONS As Int32 = 43 'Number of mouse buttons. Const SM_CMETRICS As Int32 = 44 'Number of system metrics Const SM_CLEANBOOT As Int32 = 67 'Windows 95 boot mode. 0 = normal, 1 = safe, 2 = safe with network Const SM_CXMAXIMIZED As Int32 = 61 'default width of win95 maximised window Const SM_CXMAXTRACK As Int32 = 59 'maximum width when resizing win95 windows Const SM_CXMENUCHECK As Int32 = 71 'width of menu checkmark bitmap Const SM_CXMENUSIZE As Int32 = 54 'width of button on menu bar Const SM_CXMINIMIZED As Int32 = 57 'width of rectangle into which minimised windows must fit. Const SM_CYMAXIMIZED As Int32 = 62 'default height of win95 maximised window Const SM_CYMAXTRACK As Int32 = 60 'maximum width when resizing win95 windows Const SM_CYMENUCHECK As Int32 = 72 'height of menu checkmark bitmap Const SM_CYMENUSIZE As Int32 = 55 'height of button on menu bar Const SM_CYMINIMIZED As Int32 = 58 'height of rectangle into which minimised windows must fit. Const SM_CYSMCAPTION As Int32 = 51 'height of windows 95 small caption Const SM_MIDEASTENABLED As Int32 = 74 'Hebrw and Arabic enabled for windows 95 Const SM_NETWORK As Int32 = 63 'bit o is set if a network is present. Const SM_SECURE As Int32 = 44 'True if security is present on windows 95 system Const SM_SLOWMACHINE As Int32 = 73 'true if machine is too slow to run win95. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click MessageBox.Show("Number of mouse buttons:" & apiGetSystemMetrics(SM_CMOUSEBUTTONS)) 'MessageBox.Show("Screen X:" & apiGetSystemMetrics(SM_CXSCREEN)) 'MessageBox.Show("Screen Y:" & apiGetSystemMetrics(SM_CYSCREEN)) 'MessageBox.Show("Height of windows caption:" & apiGetSystemMetrics(SM_CYCAPTION)) 'MessageBox.Show("Width of menu button " & apiGetSystemMetrics(SM_CXMENUSIZE)) 'MessageBox.Show("Width of standard icon " & apiGetSystemMetrics(SM_CXICON)) 'MessageBox.Show("Width titlebar bitmap " & apiGetSystemMetrics(SM_CXSIZE)) 'MessageBox.Show("Width between desktop icons:" & apiGetSystemMetrics(SM_CXICONSPACING)) 'MessageBox.Show("Maximum width when resizing a window:" & apiGetSystemMetrics(SM_CYMAXTRACK)) 'MessageBox.Show("Is machine is too slow to run windows? " & CBool(apiGetSystemMetrics(SM_SLOWMACHINE))) 'MessageBox.Show("Is computer in safe mode? " & CBool(apiGetSystemMetrics(SM_CLEANBOOT))) End Sub


Reply With Quote
Bookmarks