@msdn=http://search.microsoft.com/search/results.aspx?qu=$$$ @pinvoke=http://pinvoke.net/$$$.htm Summary: Retrieves various system metrics of display elements and system configuration settings. !!!!C# Signature: [DllImport("user32.dll")] static extern int GetSystemMetrics(SystemMetric smIndex); !!!!VB.NET Signature: Public Declare Auto Function GetSystemMetrics Lib "user32.dll" (ByVal smIndex As Integer) As Integer !!!!Parameters: || SystemMetric '''smIndex''' || || System metric or configuration setting to retrieve. This parameter can be one of the following values. Note that all SM_CX* values are widths and all SM_CY* values are heights. Also note that all settings designed to return Boolean data represent TRUE as any nonzero value, and FALSE as a zero value. || !!!!User-Defined Types: The C# and VB Definition of the [SystemMetric] enum can be found here: || SystemMetric || http://pinvoke.net/default.aspx/Enums.SystemMetric || !!!!Remarks: * System metrics may vary from display to display. Most values are returned in number of pixels, all others are flag or boolean values. * GetSystemMetrics(SM_CMONITORS) counts only display monitors. This is different from EnumDisplayMonitors, which enumerates display monitors and also non-display pseudo-monitors. The '''SM_ARRANGE''' setting specifies how the system arranges minimized windows, and consists of a starting position and a direction. The starting position can be one of the following values. ||Value || Meaning || || ARW_BOTTOMLEFT || Start at the lower-left corner of the screen (default position). || || ARW_BOTTOMRIGHT || Start at the lower-right corner of the screen. Equivalent to ARW_STARTRIGHT. || || ARW_HIDE || Hide minimized windows by moving them off the visible area of the screen. || || ARW_TOPLEFT || Start at the upper-left corner of the screen. Equivalent to ARV_STARTTOP. || || ARW_TOPRIGHT || Start at the upper-right corner of the screen. Equivalent to ARW_STARTTOP | SRW_STARTRIGHT. || The direction in which to arrange can be one of the following values. ||Value || Meaning || ||ARW_DOWN || Arrange vertically, top to bottom. || ||ARW_LEFT || Arrange horizontally, left to right. || ||ARW_RIGHT || Arrange horizontally, right to left. || ||ARW_UP || Arrange vertically, bottom to top. || !!!!Tips & Tricks: Use the Form.ClientSize method to get the size of the working area of the window, which is much easier than calculating the system metrics yourself to get the same result (something that you could do if you had to, and had to do back in the day): !!!!Sample Code C#: The following example creates a new ListView control, and displays each member of the enumerator and it's return value. To use this example, paste it into the code (not the deigner code) file of a blank form. (ie, Form1.cs), if you have AIPCC installed you wont need to use the WindowsAPI class, instead it will be imported fron the AIP class library. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace CodeCoreUI_Diagnostics { public partial class Form1:Form { public partial class WindowsAPI { // *** PASTE SYSTEMMETRIC ENUM HERE *** [DllImport("user32.dll")] public static extern int GetSystemMetrics(SystemMetric smIndex); } public Form1() { InitializeComponent(); } private void Form1_Load(object sender,EventArgs e) { ListView lvMain = new ListView(); this.Controls.Add(lvMain); lvMain.Visible=true; lvMain.Location=new Point(0,0); lvMain.Dock = DockStyle.Fill; lvMain.Columns.Add("Name",200); lvMain.Columns.Add("Value",200) ; lvMain.Columns.Add("Returned",200); lvMain.View=View.Details; ListViewItem lvi; string x; int u; foreach (int i in Enum.GetValues(typeof(WindowsAPI.SystemMetric))) { x = Enum.GetName(typeof(WindowsAPI.SystemMetric),i); u=WindowsAPI.GetSystemMetrics(( WindowsAPI.SystemMetric)i); lvi = lvMain.Items.Add(x); lvi.SubItems.Add(i.ToString()); lvi.SubItems.Add(u.ToString()); } } } } !!!!Alternative Managed API: System.Windows.Forms.SystemInformation class AIPCC.NET Windows API Library is available for free use (still in development) The extensions are semi-managed via the GC and Exception Handling. !!!!Site Resources: Documentation tested on Microsoft Visual Studio 2005 Information Supplied or Quoted from Microsoft Developer News (MSDN) 2006 Feb. Documentation: GetSystemMetrics@msdn on MSDN
Edit user32.getsystemm...
You do not have permission to change this page. If you feel this is in error, please send feedback with the contact link on the main page.