Mobile SDK for Windows Apps2.0
Transforming Windows apps into Mobile apps
Display Settings

WinForm Display Settings sample program

This sample illustrates how to retrieve the display settings of the connected device, and how to subscribe to the DisplaySettingsChanged event.



The cmp referenced in the code snippets below is an instance of the CitrixMobile class.

Event subscription

The CitrixMobile class exposes an event called DisplaySettingsChanged.

The following is an example of how to subscribe to the DisplaySettingsChanged event.

            // Register for display settings changed events.
            cmp.DisplaySettingsChanged += new CMPApp.DisplaySettingsChangedEventHandler(DisplaySettingsChanged);

Event handler

The following is an implementation of the DisplaySettingsChanged event handler.

        // <summary>
        // Display Settings event handler.
        // </summary>
        // <param name="metricsFlags">Metrix flags.</param>
        // <param name="pixelWidth">Pixel width.</param>
        // <param name="pixelHeight">Pixel height.</param>
        // <param name="colorDepth">Colour depth.</param>
        // <param name="XPixelsPerInch">X-axis pixels per inch.</param>
        // <param name="YPixelsPerInch">Y-axis pixels per inch.</param>
        // <param name="DeviceOrientation">Device Orientation</param>
        // <param name="WidthMilliInches">Width milli-inches</param>
        // <param name="HeightMilliInches">Heigth milli-inches</param>
        // <param name="normalizedDPI">Normalised dots per inch</param>
        private void cmp_DisplaySettingsChanged(
            Int16 metricsFlags,
            Int32 pixelWidth,
            Int32 pixelHeight,
            Int16 colorDepth,
            Int32 XPixelsPerInch,
            Int32 YPixelsPerInch,
            CMP_ORIENTATION_POSITION DeviceOrientation,
            Int32 WidthMilliInches,
            Int32 HeightMilliInches,
            Int32 normalizedDPI)

            settings.Length = (short)Marshal.SizeOf(settings);
            settings.PixelHeight = pixelHeight;
            settings.PixelWidth = pixelWidth;
            settings.MetricsFlags = metricsFlags;
            settings.ColorDepth = colorDepth;
            settings.HorizontalPixelsPerInch = XPixelsPerInch;
            settings.VerticalPixelsPerInch = YPixelsPerInch;
            settings.DeviceOrientation = (short)DeviceOrientation;
            settings.WidthMilliInches = WidthMilliInches;
            settings.HeightMilliInches = HeightMilliInches;
            settings.PixelsPerInch = normalizedDPI;

            // call the registered delegates

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Events Defines