当前位置: 首页>>代码示例>>C#>>正文


C# PAINTSTRUCT类代码示例

本文整理汇总了C#中PAINTSTRUCT的典型用法代码示例。如果您正苦于以下问题:C# PAINTSTRUCT类的具体用法?C# PAINTSTRUCT怎么用?C# PAINTSTRUCT使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PAINTSTRUCT类属于命名空间,在下文中一共展示了PAINTSTRUCT类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EndPaint

	public static extern bool EndPaint (IntPtr hwnd, ref PAINTSTRUCT ps);
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:1,代码来源:Win32.cs

示例2: WndProc


//.........这里部分代码省略.........
                            break;

                        case (int)NotificationCodes.NM_CUSTOMDRAW:
                            m.Result = new IntPtr((int)OnCustomDraw(ref m));
                            messageProcessed = true;
                            break;

                        case (int)ListViewNotificationCodes.LVN_ODSTATECHANGED:
                            {
                                messageProcessed = true;
                                NMLVODSTATECHANGE lvod = (NMLVODSTATECHANGE)m.GetLParam(typeof(NMLVODSTATECHANGE));
                                int num1 = lvod.uOldState & (int)ListViewItemStates.LVIS_SELECTED;
                                int num2 = lvod.uNewState & (int)ListViewItemStates.LVIS_SELECTED;
                                if (num2 == num1)
                                    return;
                                this.OnSelectedIndexChanged(EventArgs.Empty);
                                break;
                            }

                        default:
                            break;
                    }
                    break;

                case WM_NOTIFY:
                    nm1 = (NMHDR)m.GetLParam(typeof(NMHDR));
                    if (nm1.code == (int)NotificationCodes.NM_RCLICK)
                    {
                        IntPtr header = (IntPtr)SendMessage(Handle, (int)ListViewMessages.LVM_GETHEADER, IntPtr.Zero, IntPtr.Zero);
                        uint curpos = GetMessagePos();
                        Point ptheader = PointToClient(new Point((int)(short)curpos, (int)curpos >> 16));
                        HDHITTESTINFO hdhti = new HDHITTESTINFO();
                        hdhti.pt = ptheader;
                        SendMessage(header, HeaderMessageCodes.HDM_HITTEST, IntPtr.Zero, ref hdhti);
                        OnColumnRightClick(new ColumnClickEventArgs(hdhti.iItem));
                    }
                    else if (nm1.code == (int)HeaderNotificationCodes.HDN_ITEMCLICKW)
                    {
                        if (OnCustomSort(ref m))
                        {
                            m.Result = IntPtr.Zero;
                            messageProcessed = true;
                        }
                    }
                    break;

                case WM_ERASEBKGND:
                    //removes flicker
                    return;

                case WM_MOUSEHOVER:
                    messageProcessed = true;
                    break;

                case WM_PAINT:
                    // The designer host does not call OnResize()
                    if (internalGraphics == null)
                        OnResize(EventArgs.Empty);

                    //Set up
                    RECT updateRect = new RECT();
                    if (GetUpdateRect(m.HWnd, ref updateRect, false) == 0)
                        break;

                    PAINTSTRUCT paintStruct = new PAINTSTRUCT();
                    IntPtr screenHdc = BeginPaint(m.HWnd, ref paintStruct);
                    using (Graphics screenGraphics = Graphics.FromHdc(screenHdc))
                    {

                        //Draw Internal Graphics
                        internalGraphics.Clear(this.BackColor);
                        IntPtr hdc = internalGraphics.GetHdc();
                        Message printClientMessage = Message.Create(Handle, WM_PRINTCLIENT, hdc, IntPtr.Zero);
                        DefWndProc(ref printClientMessage);
                        internalGraphics.ReleaseHdc(hdc);

                        //Add the missing OnPaint() call
                        OnPaint(new PaintEventArgs(internalGraphics, Rectangle.FromLTRB(
                            updateRect.left,
                            updateRect.top,
                            updateRect.right,
                            updateRect.bottom)));

                        //Draw Screen Graphics
                        screenGraphics.DrawImage(internalBitmap, 0, 0);
                    }

                    //Tear down
                    EndPaint(m.HWnd, ref paintStruct);
                    return;

                default:
                    break;
            }
            if (!messageProcessed)
            {
                try { base.WndProc(ref m); }
                catch { }
            }
        }
开发者ID:robjer,项目名称:tesvsnip,代码行数:101,代码来源:virtuallistview.cs

示例3: CustomProc

 protected void CustomProc(ref Message m)
 {
     switch (m.Msg)
     {
         case WM_PAINT:
             {
                 PAINTSTRUCT ps = new PAINTSTRUCT();
                 if (!_bPainting)
                 {
                     _bPainting = true;
                     BeginPaint(m.HWnd, ref ps);
                     PaintThis(ps.hdc, ps.rcPaint);
                     EndPaint(m.HWnd, ref ps);
                     _bPainting = false;
                     base.WndProc(ref m);
                 }
                 else
                 {
                     base.WndProc(ref m);
                 }
                 break;
             }
         case WM_CREATE:
             {
                 GetFrameSize();
                 FrameChanged();
                 m.Result = MSG_HANDLED;
                 base.WndProc(ref m);
                 break;
             }
         case WM_NCCALCSIZE:
             {
                 if (m.WParam != IntPtr.Zero && m.Result == IntPtr.Zero)
                 {
                     if (_bExtendIntoFrame)
                     {
                         NCCALCSIZE_PARAMS nc = (NCCALCSIZE_PARAMS)Marshal.PtrToStructure(m.LParam, typeof(NCCALCSIZE_PARAMS));
                         nc.rect0.Top -= (_tMargins.cyTopHeight > CaptionHeight ? CaptionHeight : _tMargins.cyTopHeight);
                         nc.rect1 = nc.rect0;
                         Marshal.StructureToPtr(nc, m.LParam, false);
                         m.Result = (IntPtr)WVR_VALIDRECTS;
                     }
                     base.WndProc(ref m);
                 }
                 else
                 {
                     base.WndProc(ref m);
                 }
                 break;
             }
         case WM_SYSCOMMAND:
             {
                 UInt32 param;
                 if (IntPtr.Size == 4)
                     param = (UInt32)(m.WParam.ToInt32());
                 else
                     param = (UInt32)(m.WParam.ToInt64());
                 if ((param & 0xFFF0) == SC_RESTORE)
                 {
                     this.Height = _iStoreHeight;
                 }
                 else if (this.WindowState == FormWindowState.Normal)
                 {
                     _iStoreHeight = this.Height;
                 }
                 base.WndProc(ref m);
                 break;
             }
         case WM_NCHITTEST:
             {
                 if (m.Result == (IntPtr)HIT_CONSTANTS.HTNOWHERE)
                 {
                     IntPtr res = IntPtr.Zero;
                     if (DwmDefWindowProc(m.HWnd, (uint)m.Msg, m.WParam, m.LParam, ref res))
                         m.Result = res;
                     else
                         m.Result = (IntPtr)HitTest();
                 }
                 else
                     base.WndProc(ref m);
                 break;
             }
         case WM_DWMCOMPOSITIONCHANGED:
         case WM_ACTIVATE:
             {
                 DwmExtendFrameIntoClientArea(this.Handle, ref _tMargins);
                 m.Result = MSG_HANDLED;
                 base.WndProc(ref m);
                 break;
             }
         default:
             {
                 base.WndProc(ref m);
                 break;
             }
     }
 }
开发者ID:ptx-console,项目名称:cheetah-web-browser,代码行数:97,代码来源:Form1.cs

示例4: EndPaint

 private static extern bool EndPaint(IntPtr hWnd, ref PAINTSTRUCT ps);
开发者ID:ViniciusConsultor,项目名称:ecustomsgs1,代码行数:1,代码来源:cScrollBar.cs

示例5: BeginPaint

 public static extern IntPtr BeginPaint(IntPtr hWnd, ref PAINTSTRUCT paintStruct);
开发者ID:robjer,项目名称:tesvsnip,代码行数:1,代码来源:virtuallistview.cs

示例6: PaintEventStart

		internal override PaintEventArgs PaintEventStart(ref Message msg, IntPtr handle, bool client) {
			IntPtr		hdc;
			PAINTSTRUCT	ps;
			PaintEventArgs	paint_event;
			RECT		rect;
			Rectangle	clip_rect;
			Hwnd		hwnd;

			clip_rect = new Rectangle();
			rect = new RECT();
			ps = new PAINTSTRUCT();

			hwnd = Hwnd.ObjectFromHandle(msg.HWnd);
			
			if (client) {
				if (Win32GetUpdateRect(msg.HWnd, ref rect, false)) {
					if (handle != msg.HWnd) {
						// We need to validate the window where the paint message
						// was generated, otherwise we'll never stop getting paint 
						// messages.
						Win32GetClientRect (msg.HWnd, out rect);
						Win32ValidateRect (msg.HWnd, ref rect);
						hdc = Win32GetDC (handle);
					} else {
						hdc = Win32BeginPaint (handle, ref ps);
						rect = ps.rcPaint;
					}
				} else {
					hdc = Win32GetDC(handle);
				}
				clip_rect = rect.ToRectangle ();
			} else {
				hdc = Win32GetWindowDC (handle);

				// HACK this in for now
				Win32GetWindowRect (handle, out rect);
				clip_rect = new Rectangle (0, 0, rect.Width, rect.Height);
			}

			// If we called BeginPaint, store the PAINTSTRUCT,
			// otherwise store hdc, so that PaintEventEnd can know
			// whether to call EndPaint or ReleaseDC.
			if (ps.hdc != IntPtr.Zero) {
				hwnd.drawing_stack.Push (ps);
			} else {
				hwnd.drawing_stack.Push (hdc);
			}
			
			Graphics dc = Graphics.FromHdc(hdc);
			hwnd.drawing_stack.Push (dc);

			paint_event = new PaintEventArgs(dc, clip_rect);

			return paint_event;
		}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:55,代码来源:XplatUIWin32.cs

示例7: Win32EndPaint

		private extern static bool Win32EndPaint(IntPtr hWnd, ref PAINTSTRUCT ps);
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:1,代码来源:XplatUIWin32.cs

示例8: WndProc

        // Actual rendering is here
        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
                case WM_ERASEBKGND:
                    return;
                case WM_PAINT:
                    PAINTSTRUCT paintStruct = new PAINTSTRUCT();
                    IntPtr screenHdc = BeginPaint(m.HWnd, ref paintStruct);

                    if (Tasks != null)
                    {
                        using (var screen = Graphics.FromHdc(screenHdc))
                        {
                            screen.Clear(BackColor);

                            Int32 width = Width;
                            Int32 height = Height;

                            var pointOutline = new Pen(Color.Black, 1);
                            var pointOutlineSelected = new Pen(Color.Orange, 2);
                            var pointFill = new SolidBrush(Color.MediumPurple);
                            var pointFillCurrent = new SolidBrush(Color.Red);

                            var visitedLinkPen = new Pen(Color.DarkSlateBlue, 4);
                            var activeLinkPen = new Pen(Color.HotPink, 2);

                            if (Tasks.Count > 0)
                            {
                                // Draw Visited Links
                                if (Path.Count > 1)
                                {
                                    Int32 i = 0;
                                    DataPoint c = Path[i];
                                    do
                                    {
                                        i++;

                                        DataPoint n = Path[i];

                                        Int32 x0 = (Int32) (c.Location.X * width);
                                        Int32 y0 = (Int32) (c.Location.Y * height);
                                        Int32 x1 = (Int32) (n.Location.X * width);
                                        Int32 y1 = (Int32) (n.Location.Y * height);

                                        screen.DrawLine(visitedLinkPen, x0, y0, x1, y1);

                                        c = n;

                                    } while (i < Path.Count - 1);
                                }

                                // Draw Tasks
                                foreach (var t in Tasks)
                                {
                                    Int32 x = (Int32) (t.Location.X * width);
                                    Int32 y = (Int32) (t.Location.Y * height);

                                    var outlinePen = t.Equals(SelectedTask) ? pointOutlineSelected : pointOutline;
                                    var fillBrush = pointFill;

                                    screen.FillEllipse(fillBrush, x - TaskPointRadius, y - TaskPointRadius,
                                                       2 * TaskPointRadius, 2 * TaskPointRadius);
                                    screen.DrawEllipse(outlinePen, x - TaskPointRadius, y - TaskPointRadius,
                                                       2 * TaskPointRadius, 2 * TaskPointRadius);
                                }
                            }
                            else
                            {
                                screen.DrawString("Shift+Click to add tasks", new Font(Font.FontFamily, 12, FontStyle.Bold), new SolidBrush(Color.DarkGray), 10, 10);
                            }

                            // Draw Border
                            screen.DrawRectangle(pointOutline, 0, 0, width - 1, height - 1);
                        }
                    }

                    EndPaint(m.HWnd, ref paintStruct);
                    return;
                default:
                    base.WndProc(ref m);
                    break;
            }
        }
开发者ID:jluchiji,项目名称:cbro,代码行数:85,代码来源:VisualizerSurface.cs

示例9: DrawEventArgs

    public DrawEventArgs(IGraphPort device, PAINTSTRUCT pStruct)
	{
        fPaintStruct = pStruct;
		fDevice = device;
	}
开发者ID:Wiladams,项目名称:NewTOAPIA,代码行数:5,代码来源:DrawEventArgs.cs

示例10: WndProc

		protected override void WndProc(ref Message message) {
			switch (message.Msg) {
				case 15: {
					var paintStruct = new PAINTSTRUCT();
					IntPtr targetDC = BeginPaint(message.HWnd, ref paintStruct);
					var rectangle = new Rectangle(paintStruct.rcPaint_left, paintStruct.rcPaint_top,
					                              paintStruct.rcPaint_right - paintStruct.rcPaint_left,
					                              paintStruct.rcPaint_bottom - paintStruct.rcPaint_top);
					if ((rectangle.Width > 0) && (rectangle.Height > 0)) {
						using (BufferedGraphics graphics = BufferedGraphicsManager.Current.Allocate(targetDC, base.ClientRectangle)) {
							IntPtr hdc = graphics.Graphics.GetHdc();
							Message m = Message.Create(base.Handle, 0x318, hdc, IntPtr.Zero);
							DefWndProc(ref m);
							graphics.Graphics.ReleaseHdc(hdc);
							graphics.Render();
						}
					}
					EndPaint(message.HWnd, ref paintStruct);
					message.Result = IntPtr.Zero;
					return;
				}
				case 20:
					message.Result = (IntPtr) 1;
					return;

					/*case 0x20:
					LinkLabel2.SetCursor(LinkLabel2.LoadCursor(0, 0x7f00));
					message.Result = IntPtr.Zero;
					return;*/
			}
			base.WndProc(ref message);
		}
开发者ID:hbaes,项目名称:updateSystem.NET,代码行数:32,代码来源:explorerTreeView.cs

示例11: EndPaint

 internal static extern bool EndPaint(IntPtr hWnd, ref PAINTSTRUCT lpPaint);
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:1,代码来源:NativeMethods.cs

示例12: WndProc

        protected override void WndProc(ref Message m)
        {
            PAINTSTRUCT ps = new PAINTSTRUCT();

            switch (m.Msg)
            {
                case WM_PAINT:
                    if (!_bPainting && _maskTimer > 1)
                    {
                        _bPainting = true;
                        // start painting engine
                        BeginPaint(m.HWnd, ref ps);
                        drawMask();
                        // done
                        EndPaint(m.HWnd, ref ps);
                        _bPainting = false;
                    }
                    else
                    {
                        base.WndProc(ref m);
                    }
                    break;

                case WM_TIMER:
                    if ((_safeTimer > 50) && (!inArea()))
                    {
                        stopTimer();
                    }
                    else
                    {
                        if (_bFadeIn == true)
                            fadeIn();
                        else
                            fadeOut();
                    }
                    _safeTimer++;
                    base.WndProc(ref m);
                    break;

                case WM_MOUSEMOVE:
                    if (inArea())
                        fadeIn();
                    else
                        fadeOut();
                    base.WndProc(ref m);
                    break;

                case WM_MOUSELEAVE:
                    fadeOut();
                    base.WndProc(ref m);
                    break;

                case WM_LBUTTONDOWN:
                    Dispose();
                    base.WndProc(ref m);
                    break;

                default:
                    base.WndProc(ref m);
                    break;
            }
        }
开发者ID:ViniciusConsultor,项目名称:ecustomsgs1,代码行数:62,代码来源:cTransition.cs

示例13: WndProc

        protected override void WndProc(ref Message m)
        {
            PAINTSTRUCT pntStrct = new PAINTSTRUCT();
            switch (m.Msg)
            {
                case WM_PAINT:
                    if (!_bPainting)
                    {
                        _bPainting = true;
                        // start painting engine
                        BeginPaint(m.HWnd, ref pntStrct);
                        drawTabControl();
                        ValidateRect(m.HWnd, ref pntStrct.rcPaint);
                        // done
                        EndPaint(m.HWnd, ref pntStrct);

                        _bPainting = false;
                    }
                    else
                    {
                        base.WndProc(ref m);
                    }
                    break;

                case WM_MOUSEMOVE:
                    // only necessary if vertically aligned..
                    drawTabControl();
                    base.WndProc(ref m);
                    break;

                case WM_MOUSELEAVE:
                    drawTabControl();
                    base.WndProc(ref m);
                    break;

                default:
                    base.WndProc(ref m);
                    break;
            }
        }
开发者ID:ViniciusConsultor,项目名称:ecustomsgs1,代码行数:40,代码来源:cTabControl.cs

示例14: WndProc

        protected override void WndProc(ref Message m)
        {
            switch(m.Msg)
            {
                case WM_ERASEBKGND:
                case WM_PAINT:
                    if (Width == 0 || Height == 0)
                        return;

                    //Buffer vorbereiten:
                    if (buffer == null)
                    {
                        buffer = new Bitmap(Width, Height);
                    }
                    if (buffer.Width != Width || buffer.Height != Height)
                    {
                        buffer.Dispose();//!!!
                        buffer = new Bitmap(Width, Height);
                    }
                    //Hdc besorgen:
                    IntPtr hdc = m.WParam;
                    PAINTSTRUCT ps=new PAINTSTRUCT();
                    bool callEndPaint = false ;
                    Rectangle drawingRegion;
                    if (hdc == IntPtr.Zero)
                    {
                        hdc = BeginPaint(Handle, out ps);
                        callEndPaint = true;
                        drawingRegion=ps.rcPaint;
                    }
                    else
                    {
                        drawingRegion=ClientRectangle;
                    }
                    if (hdc == IntPtr.Zero)
                    { return; }
                    //auf Buffer zeichnen:
                    using (Graphics ownGx = Graphics.FromImage(buffer))
                    {
                        IntPtr ownHdc=ownGx.GetHdc();
                        Message newM = new Message();
                        newM.Msg=m.Msg;
                        newM.HWnd = Handle;
                        newM.WParam=ownHdc;
                        newM.LParam=m.LParam;
                        DefWndProc(ref newM);
                        ownGx.ReleaseHdc(ownHdc);
                        //man kann hier den Buffer beliebig manipulieren.
                        if (m.Msg == WM_PAINT) OnPaint(new PaintEventArgs(ownGx, drawingRegion));
                        else OnPaintBackground(new PaintEventArgs(ownGx, drawingRegion));
                    }
                    //Buffer zeichnen:
                    if(m.Msg==WM_PAINT)
                    {
                        using (Graphics gx = Graphics.FromHdc(hdc))
                        {
                            gx.DrawImage(buffer, drawingRegion, drawingRegion, GraphicsUnit.Pixel);
                        }
                    }
                    //Aufräumen:
                    if (callEndPaint)
                    { EndPaint(Handle, ref ps); }
                    m.Result = IntPtr.Zero;
                    return;
                default:
                    base.WndProc(ref m);
                    return;
            }
        }
开发者ID:ago1024,项目名称:WurmTools,代码行数:69,代码来源:LabelProgressBar.cs

示例15: WndProc

        /// <summary>
        /// message pump
        /// </summary>
        /// <param name="m">message struct</param>
        protected override void WndProc(ref Message m)
        {
            TOOLINFO tI = new TOOLINFO(0);
            RECT tR = new RECT();
            Size sZ = new Size();
            Point pT = new Point();
            DrawEventArgs dR;

            switch (m.Msg)
            {
                // window painting
                case WM_PAINT:
                    PAINTSTRUCT tPaint = new PAINTSTRUCT();
                    string sT = String.Empty;
                    string sC = String.Empty;
                    if (_eCustomStyle != TipStyle.Default)
                    {
                        if (!_bPainting)
                        {
                            _bPainting = true;
                            // start painting engine
                            BeginPaint(m.HWnd, ref tPaint);
                            dR = getEventParams();
                            if (Draw != null)
                            {
                                dR.Hdc = tPaint.hdc;
                                Draw(this, dR);
                            }
                            else
                            {
                                drawTip(dR.Bounds, dR.Caption, dR.Title, tPaint.hdc, dR.ParentWnd);
                            }
                            // done
                            EndPaint(m.HWnd, ref tPaint);
                            _bPainting = false;
                        }
                        else
                        {
                            base.DefWndProc(ref m);
                        }
                    }
                    else
                    {
                        // call the old proc
                        base.WndProc(ref m);
                    }
                    break;

                case (WM_NOTIFY | WM_REFLECT):
                    NMHDR nM = new NMHDR(0);
                    RtlMoveMemory(ref nM, m.LParam, Marshal.SizeOf(nM));
                    if (nM.hwndFrom == _hTipWnd)
                    {
                        switch (nM.code)
                        {
                            //case TTN_GETDISPINFOA: <- not working
                            //case TTN_GETDISPINFOW:
                            //    break;
                            case TTN_SHOW:
                                Point tp = new Point();
                                SendMessage(_hTipWnd, TTM_GETCURRENTTOOL, 0, ref tI);
                                _hParentWnd = tI.hwnd;
                                //// SIZE ////
                                // tip size set globally
                                if ((_oSize.Width != 0) || (_oSize.Height != 0))
                                {
                                    tR.Left = 0;
                                    tR.Top = 0;
                                    tR.Bottom = _oSize.Height;
                                    tR.Right = _oSize.Width;
                                    SendMessage(_hTipWnd, TTM_ADJUSTRECT, 1, ref tR);
                                    SetWindowPos(_hTipWnd,
                                                HWND_TOP,
                                                0, 0,
                                                tR.Right, tR.Bottom,
                                                SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOOWNERZORDER);
                                    m.Result = RETURN_TRUE;
                                }
                                else
                                {
                                    // tip size set individually
                                    tI.uId = _hTipWnd;
                                    // get tool parent
                                    SendMessage(_hTipWnd, TTM_GETCURRENTTOOL, 0, ref tI);
                                    if (tI.hwnd != IntPtr.Zero)
                                    {
                                        // test the dictionary
                                        if (_dSize.ContainsKey(tI.hwnd))
                                        {
                                            sZ = _dSize[tI.hwnd];
                                            // size tip
                                            if ((sZ.Width != 0) || (sZ.Height != 0))
                                            {
                                                tR.Left = 0;
                                                tR.Top = 0;
                                                tR.Bottom = sZ.Height;
//.........这里部分代码省略.........
开发者ID:JackWangCUMT,项目名称:winform-control-lib,代码行数:101,代码来源:WSNToolTip.cs


注:本文中的PAINTSTRUCT类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。