Click here to Skip to main content
15,887,267 members
Home / Discussions / C#
   

C#

 
GeneralRe: NONCLIENTMETRICS marshalling Pin
Matze25-Nov-02 23:07
Matze25-Nov-02 23:07 
GeneralRe: NONCLIENTMETRICS marshalling Pin
Stephane Rodriguez.25-Nov-02 23:48
Stephane Rodriguez.25-Nov-02 23:48 
GeneralRe: NONCLIENTMETRICS marshalling Pin
Matze26-Nov-02 0:16
Matze26-Nov-02 0:16 
GeneralRe: NONCLIENTMETRICS marshalling Pin
Anonymous26-Nov-02 5:19
Anonymous26-Nov-02 5:19 
GeneralRe: NONCLIENTMETRICS marshalling Pin
leppie26-Nov-02 8:23
leppie26-Nov-02 8:23 
GeneralRe: NONCLIENTMETRICS marshalling Pin
Richard Deeming26-Nov-02 6:21
mveRichard Deeming26-Nov-02 6:21 
GeneralRe: NONCLIENTMETRICS marshalling Pin
Matze26-Nov-02 19:27
Matze26-Nov-02 19:27 
GeneralRe: NONCLIENTMETRICS marshalling Pin
Richard Deeming26-Nov-02 22:38
mveRichard Deeming26-Nov-02 22:38 
Here's the code I used, and the output on my XP Pro machine:
C#
using System;
using System.Runtime.InteropServices;
 
class App
{
    [StructLayout(LayoutKind.Sequential)]
    public struct LOGFONT
    {
        public int lfHeight;
        public int lfWidth;
        public int lfEscapement;
        public int lfOrientation;
        public int lfWeight;
        public byte lfItalic;
        public byte lfUnderline;
        public byte lfStrikeOut;
        public byte lfCharSet;
        public byte lfOutPrecision;
        public byte lfClipPrecision;
        public byte lfQuality;
        public byte lfPitchAndFamily;
        
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)]
        public string lfFaceName;
    }
    
    [StructLayout(LayoutKind.Sequential)]
    public struct NONCLIENTMETRICS
    {
        public int cbSize;
        public int iBorderWidth;
        public int iScrollWidth;
        public int iScrollHeight;
        public int iCaptionWidth;
        public int iCaptionHeight;
        public LOGFONT  lfntCaptionFont;
        public int iSMCaptionWidth;
        public int iSMCaptionHeight;
        public LOGFONT lfntSMCaptionFont;
        public int iMenuWidth;
        public int iMenuHeight;
        public LOGFONT lfntMenuFont;
        public LOGFONT lfntStatusFont;
        public LOGFONT lfntMessageFont;
    }
    
    [DllImport("User32.dll")]
    public static extern bool SystemParametersInfo(
        int Action, int uiParam, 
        ref NONCLIENTMETRICS pvParam, int WinIni);
    
    static void Main()
    {
        const int SPI_GETNONCLIENTMETRICS = 41;
        
        try
        {
            NONCLIENTMETRICS ncm = new NONCLIENTMETRICS();
            ncm.cbSize = Marshal.SizeOf(ncm);
            
            bool b = SystemParametersInfo(
                SPI_GETNONCLIENTMETRICS, 
                ncm.cbSize, ref ncm, 0);
            
            if (b)
            {
                Console.WriteLine("Border Width: {0}", 
                    ncm.iBorderWidth);
    
                Console.WriteLine("Scroll Width: {0}", 
                    ncm.iScrollWidth);
    
                Console.WriteLine("Caption Font: {0}", 
                    ncm.lfntCaptionFont.lfFaceName);
            }
            else
                Console.WriteLine("Failed");
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.ToString());
        }
    }
}
Output:
Border Width: 1
Scroll Width: 17
Caption Font: Trebuchet MS



"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
GeneralRe: NONCLIENTMETRICS marshalling Pin
Matze14-Dec-02 0:50
Matze14-Dec-02 0:50 
GeneralNeed help for my IRC Client Pin
Shock The Dark Mage25-Nov-02 16:21
Shock The Dark Mage25-Nov-02 16:21 
GeneralRe: Need help for my IRC Client Pin
leppie25-Nov-02 22:52
leppie25-Nov-02 22:52 
GeneralRe: Need help for my IRC Client Pin
Shaun Wilde26-Nov-02 4:12
Shaun Wilde26-Nov-02 4:12 
GeneralRe: Need help for my IRC Client Pin
Michael Mac26-Nov-02 10:28
Michael Mac26-Nov-02 10:28 
GeneralRe: Need help for my IRC Client Pin
leppie26-Nov-02 11:00
leppie26-Nov-02 11:00 
GeneralRe: Need help for my IRC Client Pin
Shock The Dark Mage26-Nov-02 13:12
Shock The Dark Mage26-Nov-02 13:12 
GeneralRe: Need help for my IRC Client Pin
leppie26-Nov-02 13:28
leppie26-Nov-02 13:28 
GeneralRe: Need help for my IRC Client Pin
Shock The Dark Mage27-Nov-02 15:38
Shock The Dark Mage27-Nov-02 15:38 
GeneralRe: Need help for my IRC Client Pin
leppie28-Nov-02 0:09
leppie28-Nov-02 0:09 
GeneralRe: Need help for my IRC Client Pin
Michael Mac27-Nov-02 3:29
Michael Mac27-Nov-02 3:29 
GeneralRe: Need help for my IRC Client Pin
leppie27-Nov-02 6:58
leppie27-Nov-02 6:58 
Generalmouse hover over MenuItem..it's not working... Pin
lnong25-Nov-02 14:31
lnong25-Nov-02 14:31 
GeneralResX Error Pin
Jassim Rahma25-Nov-02 11:26
Jassim Rahma25-Nov-02 11:26 
GeneralRe: ResX Error Pin
Matze26-Nov-02 0:24
Matze26-Nov-02 0:24 
GeneralCustomized Form Designer Pin
Jassim Rahma24-Nov-02 23:13
Jassim Rahma24-Nov-02 23:13 
GeneralWindows About Box Pin
Jassim Rahma24-Nov-02 23:11
Jassim Rahma24-Nov-02 23:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.