9/10/2023 0 Comments Win32 transparent rectangle![]() ![]() NativeMethods.SelectObject(memDc, oldBitmap) įorums for all current editions of the ComponentOne. NativeMethods.ReleaseDC(IntPtr.Zero, screenDc) NativeMethods.UpdateLayeredWindow(Handle, screenDc, ref ptDst, ref size, memDc, ref ptSrc, 0, ref blend, Win32.ULW_ALPHA) Win32.BLENDFUNCTION blend = new Win32.BLENDFUNCTION() Win32.POINT ptDst = new Win32.POINT(_x, _y) Win32.POINT ptSrc = new Win32.POINT(0, 0) ![]() ![]() Win32.SIZE size = new Win32.SIZE(_bmpWidth, _bmpHeight) OldBitmap = NativeMethods.SelectObject(memDc, hBitmap) HBitmap = bitmap.GetHbitmap(Color.FromArgb(0)) IntPtr memDc = NativeMethods.CreateCompatibleDC(screenDc) IntPtr screenDc = NativeMethods.GetDC(IntPtr.Zero) Win32.SWP_NOACTIVATE | Win32.SWP_NOOWNERZORDER | Win32.SWP_NOSIZE | Win32.SWP_NOMOVE) īitmap bitmap = PrepareBitmapWithC1Gauge() ![]() NativeMethods.SetWindowPos(Handle, topMost ? new IntPtr(Win32.HWND_TOPMOST) : IntPtr.Zero, Left, Top, Width, Height, Internal void BringGaugeToFront(bool topMost) NativeMethods.ShowWindow(Handle, Win32.SW_SHOWNOACTIVATE) M.Result = new IntPtr(Win32.MA_NOACTIVATE) Protected override void WndProc(ref Message m) Protected override void OnHandleCreated(EventArgs e) Protected override CreateParams CreateParamsĬp.ExStyle = Win32.WS_EX_LAYERED | Win32.WS_EX_NOACTIVATE Public int cy public SIZE(int width, int height) Internal static extern bool UpdateLayeredWindow( If you need real transparency use the layered popup window that is drawn with UpdateLayeredWindow API: the button is still covered with either UserControl or C1Gauge. To the constructor of UserControl2 and remove “g.Dispose() ” from the OnPaint method because that’s a bug.Īs the result of all those manipulations the first and second gauges will be drawn similarly, i.e. SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true) If you remove “SetStyle(ControlStyles.Opaque, true) ” the gauge starts to flicker each time when the value is changed because the UserControl fills its background with Form’s background color to simulate transparency. When you paint semi-transparent pixels over and over they eventually become “black”. After changing value the OnPaint method draws the image once again but it doesn’t clear the previous image because of “SetStyle(ControlStyles.Opaque, true) ” When you get the image with c1Gauge1.GetImage() itĬontains semi-transparent pixels at the border of the gauge. To display the DIB to the second device, call SetDIBits or StretchDIBits.This problem is in your code, not in C1Gauge. To transfer data between DCs for different devices, convert the memory bitmap to a DIB by calling GetDIBits. When used in a multiple monitor system, both hdcSrc and hdcDest must refer to the same device or the function will fail. TransparentBlt does not mirror a bitmap if either the width or height, of either the source or destination, is negative. The source device context specifies the transformation type for the source coordinates. The destination device context specifies the transformation type for the destination coordinates. When the SetStretchBltMode function is used, the iStretchMode modes of BLACKONWHITE and WHITEONBLACK are converted to COLORONCOLOR for the TransparentBlt function. If the source and destination rectangles are not the same size, the source bitmap is stretched to match the destination rectangle. Use AlphaBlend to specify 32 bits-per-pixel bitmaps with transparency. However, for 32 bpp bitmaps, it just copies the alpha value over. The TransparentBlt function supports all formats of source bitmaps. The TransparentBlt function works with compatible bitmaps (DDBs). If the function fails, the return value is FALSE. If the function succeeds, the return value is TRUE. The RGB color in the source bitmap to treat as transparent. The height, in logical units, of the source rectangle. The width, in logical units, of the source rectangle. The y-coordinate, in logical units, of the source rectangle. The x-coordinate, in logical units, of the source rectangle. The height, in logical units, of the destination rectangle. The width, in logical units, of the destination rectangle. The y-coordinate, in logical units, of the upper-left corner of the destination rectangle. The x-coordinate, in logical units, of the upper-left corner of the destination rectangle. Syntax BOOL TransparentBlt(Ī handle to the destination device context. The TransparentBlt function performs a bit-block transfer of the color data corresponding to a rectangle of pixels from the specified source device context into a destination device context. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |