Example #1
0
 public static NativeBrush FromColor(COLORREF colorRef)
 {
     return(new NativeBrush
     {
         _hBrush = NativeMethods.CreateSolidBrush(colorRef.Value)
     });
 }
Example #2
0
		// ------------------------------------------------------------------
		#endregion

		#region High-level routines.
		// ------------------------------------------------------------------

		/// <summary>
		/// Get a certain theme color.
		/// See http://windowssdk.msdn.microsoft.com/en-us/library/ms649930.aspx
		/// </summary>
		/// <param name="part">The part.</param>
		/// <param name="state">One of the UxThemeXXXState enums.</param>
		/// <param name="prop">The prop.</param>
		/// <returns></returns>
		public Color GetThemeColor(
			UxThemeWindowParts part,
			int state,
			UxThemeProp prop )
		{
			Debug.Assert( WantTheming );

			Control c = new Control();
			IntPtr hTheme = OpenThemeData(
				c.Handle,
				@"button" );
			Debug.Assert(
				hTheme != IntPtr.Zero,
				@"OpenThemeData() returned NULL pointer." );
			try
			{
				COLORREF cr = new COLORREF();
				int result = GetThemeColor(
					hTheme,
					(int)part,
					(int)state,
					(int)prop,
					ref cr );

				Debug.Assert( result == 0 );
				return cr.Color;
			}
			finally
			{
				CloseThemeData( hTheme );
			}
		}
Example #3
0
        private static Dictionary <COLORREF, List <User32.COLOR> > CreateColorDictionary()
        {
            var dictionary = new Dictionary <COLORREF, List <User32.COLOR> >();

            for (int i = 0; i <= (int)User32.COLOR.MENUBAR; i++)
            {
                if (i == 25)
                {
                    // Only undefined value
                    continue;
                }

                COLORREF colorRef = User32.GetSysColor((User32.COLOR)i);

                if (dictionary.TryGetValue(colorRef, out List <User32.COLOR> colors))
                {
                    colors.Add((User32.COLOR)i);
                }
                else
                {
                    var colorList = new List <User32.COLOR>
                    {
                        (User32.COLOR)i
                    };
                    dictionary.Add(colorRef, colorList);
                }
            }

            return(dictionary);
        }
Example #4
0
        /// <summary>
        /// Sets the color of the text within the preview handler.
        /// </summary>
        /// <param name="color">A value of type COLORREF to use for the preview handler text color.</param>
        /// <returns>
        /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error cod
        /// </returns>
        int IPreviewHandlerVisuals.SetTextColor(COLORREF color)
        {
            //  Log key events.
            Log("IPreviewHandlerVisuals.SetTextColor called.");

            //  Call the virtual function.
            try
            {
                OnPreviewHostThread(
                    () =>
                {
                    //  Call the abstract function.
                    if (previewHandlerControl != null)
                    {
                        previewHandlerControl.SetVisualsTextColor(color.Color);
                    }
                });
            }
            catch (Exception exception)
            {
                //  Log the error.
                LogError("An exception occured when setting the text color.", exception);
                throw;
            }

            //  Return success.
            return(WinError.S_OK);
        }
Example #5
0
        // MSDN:
        // COLORREF: 0x00bbggrr
        // Color.ToArgb: 0xAARRGGBB
        public static COLORREF RGB(byte r, byte g, byte b)
        {
            COLORREF rgb = r;

            rgb |= (UInt16)(g << 8);
            rgb |= (UInt32)(b << 16);
            return(rgb); // WinGDI.h:1595
        }
Example #6
0
        public static Color SetPixel(this Graphics g, int x, int y, Color color)
        {
            var      hdc = g.GetHdc();
            COLORREF rgb = Gdi32Helper.SetPixel(hdc, x, y, color.ToCOLORREF());

            g.ReleaseHdc(hdc);
            return(ColorExtension.FromCOLORREF(rgb));
        }
Example #7
0
            public static COLORREF Create(Color color)
            {
                var colorref = new COLORREF();

                colorref.R = (byte)(color.r * 255);
                colorref.G = (byte)(color.g * 255);
                colorref.B = (byte)(color.b * 255);
                return(colorref);
            }
Example #8
0
        public static void SetTextColorChecked(HDC hdc, COLORREF color)
        {
            COLORREF oldColor = SetTextColor(hdc, color);

            // todo: is it worth checking?
            if (oldColor == CLR_INVALID)
            {
                throw new InvalidOperationException($"{nameof(SetTextColor)} failed. Color: {color:X8}.");
            }
        }
Example #9
0
        private void DrawNCArea(IntPtr hRgn)
        {
            Region clipRegion = null;

            if (hRgn != TRUE)
            {
                clipRegion = Region.FromHrgn(hRgn);
            }

            RECT windowRect  = new RECT();
            RECT nclientRect = new RECT();
            RECT clientRect  = new RECT();


            User32.GetWindowRect(parentWindowHWnd, ref windowRect);
            User32.OffsetRect(ref windowRect, -windowRect.left, -windowRect.top);

            var height = windowRect.bottom;
            var width  = windowRect.right;


            User32.GetClientRect(parentWindowHWnd, ref clientRect);
            User32.OffsetRect(ref clientRect, -clientRect.left, -clientRect.top);

            User32.GetClientRect(parentWindowHWnd, ref nclientRect);

            User32.OffsetRect(ref nclientRect, -clientRect.left, -clientRect.top);
            User32.OffsetRect(ref nclientRect, borderSize, borderSize);


            IntPtr hDC = User32.GetWindowDC(parentWindowHWnd);

            var windowRectangle = new Rectangle(windowRect.left, windowRect.top, (int)windowRect.Width, (int)windowRect.Height);
            var clientRectangle = new Rectangle(nclientRect.left, nclientRect.top, (int)clientRect.Height, (int)clientRect.Width);



            try
            {
                COLORREF color  = new COLORREF(borderColor);
                IntPtr   hBrush = Gdi32.CreateSolidBrush(color.ColorDWORD);
                Gdi32.ExcludeClipRect(hDC, nclientRect.left, nclientRect.top, nclientRect.right, nclientRect.bottom);
                User32.FillRect(hDC, ref windowRect, hBrush);
                Gdi32.DeleteObject(hBrush);
            }
            catch (Exception ex)
            {
            }
            finally
            {
                User32.ReleaseDC(parentWindowHWnd, hDC);
            }
        }
Example #10
0
        static void DrawHands(DeviceContext dc, SYSTEMTIME pst, bool fChange)
        {
            int[] iAngle =
            {
                (pst.wHour * 30) % 360 + pst.wMinute / 2,
                pst.wMinute * 6,
                pst.wSecond * 6
            };

            POINT[][] pt =
            {
                new POINT[] { new POINT(0, -150), new POINT(100, 0), new POINT(0, 600), new POINT(-100, 0), new POINT(0, -150) },
                new POINT[] { new POINT(0, -200), new POINT(50, 0), new POINT(0, 800), new POINT(-50, 0), new POINT(0, -200), },
                new POINT[] { new POINT(0, 0), new POINT(0, 0), new POINT(0, 0), new POINT(0, 0), new POINT(0, 800) }
            };

            COLORREF color = GdiMethods.GetPenColor(dc.GetCurrentPen());
            bool erase = (color != new COLORREF());

#if GDIPLUS
            using (var graphics = GdiPlusMethods.CreateGraphics(dc))
            {
                if (erase)
                {
                    using (var brush = GdiPlusMethods.CreateSolidBrush(color))
                    {
                        GdiPlusMethods.FillEllipse(graphics, brush, -830, -830, 1660, 1660);
                    }
                    return;
                }

                using (var pen = GdiPlusMethods.CreatePen(color))
                {
                    GdiPlusMethods.SetSmoothingMode(graphics, SmoothingMode.HighQuality);

#endif

                    for (int i = fChange ? 0 : 2; i < 3; i++)
                    {
                        RotatePoint(pt[i], 5, iAngle[i]);

#if GDIPLUS
                        GdiPlusMethods.DrawLines(graphics, pen, pt[i]);
#else
                        dc.Polyline(pt[i]);
#endif
                    }
#if GDIPLUS
                }
            }
#endif
        }
Example #11
0
        public LayeredWindowInfo(IntPtr hWnd, int x, int y, int width, int height)
        {
            this.hWnd = hWnd;

            crKey                     = new COLORREF(0, 0, 0, 0);
            blend.BlendOp             = 0; // AC_SRC_OVER
            blend.BlendFlags          = 0;
            blend.SourceConstantAlpha = 255;
            blend.AlphaFormat         = 1; // AC_SRC_ALPHA
            ptDst                     = new POINT(x, y);
            ptSrc                     = new POINT(0, 0);
            size = new SIZE(width, height);
        }
Example #12
0
        public static PenHandle CreatePen(PenStyleExtended style, uint width, COLORREF color, PenEndCap endCap = PenEndCap.Round, PenJoin join = PenJoin.Round)
        {
            LOGBRUSH brush = new LOGBRUSH
            {
                lbColor = color,
                lpStyle = BrushStyle.Solid
            };

            return(Imports.ExtCreatePen(
                       (uint)style | (uint)PenType.Geometric | (uint)endCap | (uint)join,
                       width,
                       ref brush,
                       0,
                       null));
        }
        internal void UpdateListView()
        {
            Debug.Assert(listView.IsHandleCreated, "ApplySavedState Precondition: List-view handle must be created");
            NativeMethods.LVINSERTMARK lvInsertMark = new NativeMethods.LVINSERTMARK
            {
                dwFlags = appearsAfterItem ? NativeMethods.LVIM_AFTER : 0,
                iItem   = index
            };
            UnsafeNativeMethods.SendMessage(new HandleRef(listView, listView.Handle), (int)LVM.SETINSERTMARK, 0, lvInsertMark);

            if (!color.IsEmpty)
            {
                listView.SendMessage((int)LVM.SETINSERTMARKCOLOR, 0, COLORREF.ColorToCOLORREF(color));
            }
        }
        public void PreviewHandlerBase_ShouldCallPreviewControlSetTextColor_WhenSetTextColorCalled()
        {
            // Arrange
            var mockPreviewControl = new Mock <IPreviewHandlerControl>();

            previewHandlerControl = mockPreviewControl.Object;
            var testPreviewHandler = new TestPreviewHandler();
            var color = new COLORREF();

            // Act
            testPreviewHandler.SetTextColor(color);

            // Assert
            mockPreviewControl.Verify(_ => _.SetTextColor(It.Is <Color>(c => (c == color.Color))), Times.Once);
        }
Example #15
0
        private IntPtr OnEraseBackground(IntPtr wparam)
        {
            var hdc   = wparam;
            var color = new COLORREF(0xff, 0x00, 0xff);
            var brush = NativeMethods.CreateSolidBrush(color.Value);

            var rect = WindowRect;

            rect.Top  = 0;
            rect.Left = 0;
            NativeMethods.FillRect(hdc, ref rect, brush);

            NativeMethods.DeleteObject(brush);

            return(new IntPtr(1));
        }
Example #16
0
        protected void UpdateColors()
        {
            if (Created && _rebar != null)
            {
                COLORSCHEME CSInfo = new COLORSCHEME();
                CSInfo.dwSize          = (uint)Marshal.SizeOf(CSInfo);
                CSInfo.clrBtnHighlight = new COLORREF(_embossHighlight);
                CSInfo.clrBtnShadow    = new COLORREF(_embossShadow);
                win32.SendMessage(_rebar.Handle, (int)win32.RB_SETCOLORSCHEME, 0, ref CSInfo);

                COLORREF color = new COLORREF(this.ForeColor);
                win32.SendMessage(_rebar.Handle, (int)win32.RB_SETTEXTCOLOR, 0, color);
                color = new COLORREF(this.BackColor);
                win32.SendMessage(_rebar.Handle, (int)win32.RB_SETBKCOLOR, 0, color);
            }
        }
Example #17
0
 //********************************************************************************
 /// <summary>
 ///
 /// </summary>
 /// <param name="name"></param>
 /// <param name="value"></param>
 /// <param name="def"></param>
 /// <returns></returns>
 /// <created>UPh,25.04.2013</created>
 /// <changed>UPh,25.04.2013</changed>
 //********************************************************************************
 bool SerializeColorAttribute(string name, COLORREF *value, COLORREF def /*= false*/)
 {
     if (IsReading())
     {
         if (!GetColorAttribute(name, value))
         {
             *value = def;
         }
         return(true);
     }
     else if (IsWriting())
     {
         WriteColorAttribute(name, *value);
         return(true);
     }
     return(false);
 }
Example #18
0
        private void OnPaint()
        {
            var hdc = NativeMethods.GetDC(_hwnd);

            var rect = NativeMethodsSafe.GetWindowRect(_hwnd);

            rect.Left = 0;
            rect.Top  = 0;

            var color = new COLORREF(0xff, 0xff, 0xff);
            var brush = NativeMethods.CreateSolidBrush(color.Value);

            NativeMethods.FillRect(hdc, ref rect, brush);

            NativeMethods.DeleteObject(brush);

            NativeMethods.ReleaseDC(_hwnd, hdc);
        }
Example #19
0
        public unsafe static void ShowPopup(Control parent, string caption, Point location)
        {
            Debug.WriteLineIf(WindowsFormsHelpTrace.TraceVerbose, "Help:: ShowPopup");

            var pop = new HH_POPUPW
            {
                cbStruct      = sizeof(HH_POPUPW),
                pt            = location,
                rcMargins     = new RECT(-1, -1, -1, -1), // Ignore
                clrForeground = -1,                       // Ignore
                clrBackground = COLORREF.ColorToCOLORREF(SystemColors.Window)
            };

            fixed(char *pszText = caption)
            {
                pop.pszText = pszText;
                ShowHTML10Help(parent, null, HelpNavigator.Topic, pop);
            }
        }
Example #20
0
        public WindowClassEx(string className, WndProc wndProc)
        {
            var color = new COLORREF(0xff, 0xff, 0xff);
            var brush = NativeMethods.CreateSolidBrush(color.Value);

            _wndClassEx               = WNDCLASSEX.Default;
            _wndClassEx.hInstance     = Process.GetCurrentProcess().Handle;
            _wndClassEx.style         = CS.HREDRAW | CS.VREDRAW;
            _wndClassEx.lpfnWndProc   = wndProc;
            _wndClassEx.cbClsExtra    = 0;
            _wndClassEx.cbWndExtra    = 0;
            _wndClassEx.hIcon         = IntPtr.Zero;
            _wndClassEx.hCursor       = IntPtr.Zero;
            _wndClassEx.hbrBackground = brush;
            _wndClassEx.lpszMenuName  = null;
            _wndClassEx.lpszClassName = className;

            NativeMethods.RegisterClassEx(ref _wndClassEx);
        }
Example #21
0
        public static string ToSystemColorString(COLORREF colorRef)
        {
            if (TryGetSystemColor(colorRef, out List <User32.COLOR> colors))
            {
                string colorString = string.Empty;
                for (int i = 0; i < colors.Count; i++)
                {
                    colorString += s_names[colors[i]];
                    if (i < colors.Count - 1)
                    {
                        colorString += ", ";
                    }
                }

                return($"{colorRef} ({colorString})");
            }
            else
            {
                return(colorRef.ToString());
            }
        }
        void BackgroundColor()
        {
            var colorref = new COLORREF {
                R = 200
            };

            Console.WriteLine(colorref.R);

            var nativeWindow = new NativeWindow(new IntPtr(MainWindow.Get <TextBox>("TextBox").AutomationElement.Current.NativeWindowHandle));

            Console.WriteLine(nativeWindow.BackgroundColor);
            Console.WriteLine(nativeWindow.TextColor);

            //nativeWindow = new NativeWindow(MainWindow.Get<Image>("image").Bounds.Center());
            //Console.WriteLine(nativeWindow.BackgroundColor);
            //Console.WriteLine(nativeWindow.TextColor);

            nativeWindow = new NativeWindow(MainWindow.Get <Button>("ButtonWithTooltip").Bounds.ImmediateInteriorEast());
            Console.WriteLine(nativeWindow.BackgroundColor);
            Console.WriteLine(nativeWindow.TextColor);
        }
Example #23
0
        static LRESULT WindowProcedure(WindowHandle window, WindowMessage message, WPARAM wParam, LPARAM lParam)
        {
            switch (message)
            {
            case WindowMessage.Create:
                dcScreen = Windows.CreateDeviceContext("DISPLAY", null);
                window.SetTimer(ID_TIMER, 100);
                return(0);

            case WindowMessage.Timer:
                POINT pt = Windows.GetCursorPosition();
                cr = dcScreen.GetPixel(pt);
                // Not sure why the sample did this
                // dcScreen.SetPixel(pt, 0);
                if (cr != crLast)
                {
                    crLast = cr;
                    window.Invalidate(false);
                }
                return(0);

            case WindowMessage.Paint:
                using (DeviceContext dc = window.BeginPaint())
                {
                    dc.SelectObject(StockFont.SystemFixed);
                    RECT rc = window.GetClientRectangle();
                    dc.DrawText($"0x{cr.R:X2} 0x{cr.G:X2} 0x{cr.B:X2}", rc,
                                TextFormat.SingleLine | TextFormat.Center | TextFormat.VerticallyCenter);
                }
                return(0);

            case WindowMessage.Destroy:
                dcScreen.Dispose();
                window.KillTimer(ID_TIMER);
                Windows.PostQuitMessage(0);
                return(0);
            }

            return(Windows.DefaultWindowProcedure(window, message, wParam, lParam));
        }
Example #24
0
        public Win32Window()
        {
            var wndClass = WNDCLASSEX.Create();

            wndClass.cbClsExtra    = 0;
            wndClass.cbWndExtra    = 0;
            wndClass.hbrBackground = CreateSolidBrush(COLORREF.Create(PlayerSettings.backgroundColor));
            wndClass.hCursor       = LoadCursor(IntPtr.Zero, IDC_ARROW);
            wndClass.hIcon         = IntPtr.Zero;
            wndClass.hIconSm       = IntPtr.Zero;
            wndClass.hInstance     = IntPtr.Zero;
            wndClass.lpfnWndProc   = Marshal.GetFunctionPointerForDelegate(this.wndproc = this.ProcessWindowsMessage);
            wndClass.lpszClassName = className;
            wndClass.style         = WindowClassStyles.VREDRAW | WindowClassStyles.HREDRAW;
            if (0 == RegisterClassEx(ref wndClass))
            {
                throw new Exception();
            }
            CreateWindowEx(0, className, title, WindowStyles.OVERLAPPEDWINDOW, 100, 100, 1280, 720, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
            ShowWindow(this.handle, WindowShowStyle.Show);
            UpdateWindow(this.handle);
        }
Example #25
0
        private unsafe void updateMetricsButton_Click(object sender, EventArgs e)
        {
            ListViewGroup group = listView1.Groups[0];
            int           id    = (int)typeof(ListViewGroup).GetProperty("ID", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(group);

            //listView1.MultiSelect = true;

            var metrics = new LVGROUPMETRICS
            {
                cbSize = (uint)sizeof(LVGROUPMETRICS),
                mask   = LVGMF.BORDERSIZE | LVGMF.BORDERCOLOR
            };

            metrics.Right    = 50;
            metrics.Left     = 50;
            metrics.Top      = 50;
            metrics.Bottom   = 50;
            metrics.crRight  = (uint)COLORREF.ColorToCOLORREF(Color.Red);
            metrics.crLeft   = (uint)COLORREF.ColorToCOLORREF(Color.Red);
            metrics.crTop    = (uint)COLORREF.ColorToCOLORREF(Color.Red);
            metrics.crBottom = (uint)COLORREF.ColorToCOLORREF(Color.Red);
            IntPtr r = User32.SendMessageW(listView1.Handle, (User32.WindowMessage)LVM.SETGROUPMETRICS, (IntPtr)id, ref metrics);
        }
Example #26
0
        private IntPtr OnNcPaint(IntPtr wparam, IntPtr lparam)
        {
            var hrgn = wparam;

            var deleteRegion = false;
            var hdc          = NativeMethods.GetDCEx(_hwnd, hrgn,
                                                     DeviceContextValues.Window | DeviceContextValues.IntersectRgn | DeviceContextValues.Cache |
                                                     DeviceContextValues.LockWindowUpdate);

            //if (hdc == IntPtr.Zero)
            //{
            //	hdc = NativeMethods.GetWindowDC(_hwnd);
            //	var windowRect = WindowRect;
            //	windowRect.Left = 0;
            //	windowRect.Top = 0;
            //	hrgn = NativeMethods.CreateRectRgnIndirect(windowRect);
            //	deleteRegion = true;
            //}

            var color = new COLORREF(0xff, 0x00, 0xff);
            var brush = NativeMethods.CreateSolidBrush(color.Value);

            NativeMethods.FillRgn(hdc, hrgn, brush);

            NativeMethods.DeleteObject(brush);

            if (deleteRegion)
            {
                NativeMethods.DeleteObject(hrgn);
            }

            NativeMethods.ReleaseDC(_hwnd, hdc);


            return(IntPtr.Zero);
        }
Example #27
0
 public static extern bool SetLayeredWindowAttributes(IntPtr hwnd, COLORREF crKey, byte bAlpha, uint dwFlags);
Example #28
0
 public static extern bool TransparentBlt(HDC hdcDest, int xDest, int yDest, int cxDest, int cyDest, HDC hdcSrc, int xSrc, int ySrc, int cxSrc, int cySrc, COLORREF crTransparent);
Example #29
0
		public static extern int GetThemeColor(
			IntPtr hTheme,
			int iPartId,
			int iStateId,
			int iPropId,
			ref COLORREF pColor );
Example #30
0
		internal extern static IntPtr Win32CreatePen(PenStyle fnPenStyle, int nWidth, ref COLORREF color);
Example #31
0
		private extern static uint Win32SetLayeredWindowAttributes (IntPtr hwnd, COLORREF crKey, byte bAlpha, LayeredWindowAttributes dwFlags);
Example #32
0
		internal override void FillReversibleRectangle (Rectangle rectangle, Color backColor)
		{
			RECT	rect;

			rect = new RECT();
			rect.left = rectangle.Left;
			rect.top = rectangle.Top;
			rect.right = rectangle.Right;
			rect.bottom = rectangle.Bottom;

			IntPtr		hdc;
			IntPtr		brush;
			IntPtr		oldbrush;
			COLORREF        clrRef = new COLORREF();

			clrRef.R = backColor.R;
			clrRef.G = backColor.G;
			clrRef.B = backColor.B;

			// Grab a brush
			brush = Win32CreateSolidBrush (clrRef);

			hdc = Win32GetDC(IntPtr.Zero);
			oldbrush = Win32SelectObject(hdc, brush);

			Win32PatBlt (hdc, rectangle.Left, rectangle.Top, rectangle.Width, rectangle.Height, PatBltRop.DSTINVERT);

			Win32SelectObject(hdc, oldbrush);
			Win32DeleteObject(brush);

			Win32ReleaseDC(IntPtr.Zero, hdc);
		}
Example #33
0
 public static extern IntPtr CreateSolidBrush(COLORREF crColor);
 public HRESULT SetBorderColor(COLORREF clrBorder)
 {
     return(((delegate * unmanaged <IVMRSurfaceAllocatorNotify *, COLORREF, int>)(lpVtbl[8]))((IVMRSurfaceAllocatorNotify *)Unsafe.AsPointer(ref this), clrBorder));
 }
Example #35
0
 internal static extern int GetThemeColor(IntPtr hTheme, int iPartId, int iStateId, int iPropId, out COLORREF pColor);
Example #36
0
        protected void UpdateColors() {
            if ( Created && _rebar != null ) {
                COLORSCHEME CSInfo = new COLORSCHEME();
                CSInfo.dwSize = (uint)Marshal.SizeOf( CSInfo );
                CSInfo.clrBtnHighlight = new COLORREF( _embossHighlight );
                CSInfo.clrBtnShadow = new COLORREF( _embossShadow );
                win32.SendMessage( _rebar.Handle, (int)win32.RB_SETCOLORSCHEME, 0, ref CSInfo );

                COLORREF color = new COLORREF( this.ForeColor );
                win32.SendMessage( _rebar.Handle, (int)win32.RB_SETTEXTCOLOR, 0, color );
                color = new COLORREF( this.BackColor );
                win32.SendMessage( _rebar.Handle, (int)win32.RB_SETBKCOLOR, 0, color );
            }
        }
 public static extern Int32 GetThemeColor(IntPtr hTheme, int iPartId, int iStateId, int iPropId, out COLORREF pColor);
Example #38
0
 public static extern bool SetSysColors(int cElements, int[] lpaElements, COLORREF lpaRgbValues);
Example #39
0
 public static extern uint SetPixel(IntPtr hdc, int X, int Y, COLORREF crColor);
Example #40
0
 public static extern bool SetSysColors(int cElements, int[] lpaElements, COLORREF lpaRgbValues);
Example #41
0
		// XXX this doesn't work at all for FrameStyle.Dashed - it draws like Thick, and in the Thick case
		// the corners are drawn incorrectly.
		internal override void DrawReversibleFrame (Rectangle rectangle, Color backColor, FrameStyle style) {
			IntPtr		hdc;
			IntPtr		pen;
			IntPtr		oldpen;
			COLORREF        clrRef = new COLORREF();

			// If we want the standard hatch pattern we would
			// need to create a brush

			clrRef.R = backColor.R;
			clrRef.G = backColor.G;
			clrRef.B = backColor.B;

			// Grab a pen
			pen = Win32CreatePen (style == FrameStyle.Thick ? PenStyle.PS_SOLID : PenStyle.PS_DASH,
					      style == FrameStyle.Thick ? 4 : 2, ref clrRef);

			hdc = Win32GetDC(IntPtr.Zero);
			Win32SetROP2(hdc, ROP2DrawMode.R2_NOT);
			oldpen = Win32SelectObject(hdc, pen);

			Win32MoveToEx(hdc, rectangle.Left, rectangle.Top, IntPtr.Zero);
			if ((rectangle.Width > 0) && (rectangle.Height > 0)) {
				Win32LineTo(hdc, rectangle.Right, rectangle.Top);
				Win32LineTo(hdc, rectangle.Right, rectangle.Bottom);
				Win32LineTo(hdc, rectangle.Left, rectangle.Bottom);
				Win32LineTo(hdc, rectangle.Left, rectangle.Top);
			} else {
				if (rectangle.Width > 0) {
					Win32LineTo(hdc, rectangle.Right, rectangle.Top);
				} else {
					Win32LineTo(hdc, rectangle.Left, rectangle.Bottom);
				}
			}

			Win32SelectObject(hdc, oldpen);
			Win32DeleteObject(pen);

			Win32ReleaseDC(IntPtr.Zero, hdc);
		}
 private extern static int GetThemeColor(IntPtr hTheme, int iPartId, int iStateId, int iPropId, out COLORREF pColor);
Example #43
0
 public static extern IntPtr CreatePen(PenStyle fnPenStyle, int nWidth, COLORREF crColor);
Example #44
0
 public static bool TryGetSystemColor(COLORREF colorRef, out List <User32.COLOR> colors)
 => s_systemColors.TryGetValue(colorRef, out colors);
Example #45
0
 //********************************************************************************
 /// <summary>
 /// 
 /// </summary>
 /// <param name="name"></param>
 /// <param name="value"></param>
 /// <param name="def"></param>
 /// <returns></returns>
 /// <created>UPh,25.04.2013</created>
 /// <changed>UPh,25.04.2013</changed>
 //********************************************************************************
 bool SerializeColorAttribute(string name, COLORREF *value, COLORREF def /*= false*/)
 {
     if (IsReading())
     {
         if (!GetColorAttribute(name, value))
             *value = def;
         return true;
     }
     else if (IsWriting())
     {
         WriteColorAttribute(name, *value);
         return true;
     }
     return false;
 }
Example #46
0
 public static extern int DrawShadowText(IntPtr hdc, string text, uint textLength, ref RECT r, int flags, COLORREF textColor, COLORREF shadowColor, int shadowXOffset, int shadowYOffset);
Example #47
0
 public NativePen(PenStyle fnPenStyle, int nWidth, COLORREF crColor) : this()
 {
     _hpen = NativeMethods.CreatePen(fnPenStyle, nWidth, crColor.Value);
 }
Example #48
0
 public static extern HBRUSH CreateSolidBrush(COLORREF crColor);
Example #49
0
 public static int GetBValue(COLORREF cr)
 {
     return (int)((cr.cr & 0xff0000) >> 0x10);
 }
Example #50
0
		internal override void SetWindowTransparency(IntPtr handle, double transparency, Color key) {
			LayeredWindowAttributes lwa = LayeredWindowAttributes.LWA_ALPHA;
			byte opacity = (byte)(transparency*255);
			COLORREF clrRef = new COLORREF();
			if (key != Color.Empty) {
				clrRef.R = key.R;
				clrRef.G = key.G;
				clrRef.B = key.B;
				lwa = (LayeredWindowAttributes)( (int)lwa | (int)LayeredWindowAttributes.LWA_COLORKEY );
			}
			RECT rc;
			rc.right = 1000;
			rc.bottom = 1000;
			Win32SetLayeredWindowAttributes(handle, clrRef, opacity, lwa);
		}
Example #51
0
 public static int GetGValue(COLORREF cr)
 {
     return (int)((cr.cr & 0xff00) >> 8);
 }
Example #52
0
		internal override void DrawReversibleLine(Point start, Point end, Color backColor) {
			IntPtr		hdc;
			IntPtr		pen;
			IntPtr		oldpen;
			POINT		pt;
			COLORREF        clrRef = new COLORREF();

			pt = new POINT();
			pt.x = 0;
			pt.y = 0;
			Win32ClientToScreen(IntPtr.Zero, ref pt);

			// If we want the standard hatch pattern we would
			// need to create a brush

			clrRef.R = backColor.R;
			clrRef.G = backColor.G;
			clrRef.B = backColor.B;

			// Grab a pen
			pen = Win32CreatePen(PenStyle.PS_SOLID, 1, ref clrRef);

			hdc = Win32GetDC(IntPtr.Zero);
			Win32SetROP2(hdc, ROP2DrawMode.R2_NOT);
			oldpen = Win32SelectObject(hdc, pen);

			Win32MoveToEx(hdc, pt.x + start.X, pt.y + start.Y, IntPtr.Zero);
			Win32LineTo(hdc, pt.x + end.X, pt.y + end.Y);

			Win32SelectObject(hdc, oldpen);
			Win32DeleteObject(pen);

			Win32ReleaseDC(IntPtr.Zero, hdc);
		}
Example #53
0
 public static int GetRValue(COLORREF cr)
 {
     return (((int)cr.cr) & 0xff);
 }
Example #54
0
		private extern static IntPtr Win32CreateSolidBrush(COLORREF clrRef);
Example #55
0
 public static extern COLORREF SetBkColor(HDC hdc, COLORREF crBack);
Example #56
0
		private extern static uint Win32GetLayeredWindowAttributes (IntPtr hwnd, out COLORREF pcrKey, out byte pbAlpha, out LayeredWindowAttributes pwdFlags);
Example #57
0
 public static extern COLORREF SetTextColor(HDC hdc, COLORREF crText);
Example #58
0
		internal extern static IntPtr Win32CreateHatchBrush(HatchStyle fnStyle, ref COLORREF color);
Example #59
0
 public static extern uint GetLayeredWindowAttributes(IntPtr hwnd, out COLORREF pcrKey, out byte pbAlpha, out uint pwdFlags);