本文整理汇总了C#中PAINTSTRUCT类的典型用法代码示例。如果您正苦于以下问题:C# PAINTSTRUCT类的具体用法?C# PAINTSTRUCT怎么用?C# PAINTSTRUCT使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PAINTSTRUCT类属于命名空间,在下文中一共展示了PAINTSTRUCT类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EndPaint
public static extern bool EndPaint (IntPtr hwnd, ref PAINTSTRUCT ps);
示例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 { }
}
}
示例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;
}
}
}
示例4: EndPaint
private static extern bool EndPaint(IntPtr hWnd, ref PAINTSTRUCT ps);
示例5: BeginPaint
public static extern IntPtr BeginPaint(IntPtr hWnd, ref PAINTSTRUCT paintStruct);
示例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;
}
示例7: Win32EndPaint
private extern static bool Win32EndPaint(IntPtr hWnd, ref PAINTSTRUCT ps);
示例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;
}
}
示例9: DrawEventArgs
public DrawEventArgs(IGraphPort device, PAINTSTRUCT pStruct)
{
fPaintStruct = pStruct;
fDevice = device;
}
示例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);
}
示例11: EndPaint
internal static extern bool EndPaint(IntPtr hWnd, ref PAINTSTRUCT lpPaint);
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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;
//.........这里部分代码省略.........