You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

670 lines
24 KiB

1 month ago
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Drawing.Drawing2D;
  7. using System.Linq;
  8. using System.Runtime.InteropServices;
  9. using System.Text;
  10. using System.Windows.Forms;
  11. namespace Customize.Controls
  12. {
  13. /// <summary>
  14. /// Class FrmAnchorTips.
  15. /// Implements the <see cref="System.Windows.Forms.Form" />
  16. /// </summary>
  17. /// <seealso cref="System.Windows.Forms.Form" />
  18. public partial class FrmAnchorTips : Form
  19. {
  20. /// <summary>
  21. /// The m string MSG
  22. /// </summary>
  23. private string m_strMsg = string.Empty;
  24. /// <summary>
  25. /// Gets or sets the string MSG.
  26. /// </summary>
  27. /// <value>The string MSG.</value>
  28. public string StrMsg
  29. {
  30. get { return m_strMsg; }
  31. set
  32. {
  33. m_strMsg = value;
  34. if (string.IsNullOrEmpty(value))
  35. return;
  36. ResetForm(value);
  37. }
  38. }
  39. /// <summary>
  40. /// The have handle
  41. /// </summary>
  42. bool haveHandle = false;
  43. /// <summary>
  44. /// The m rect control
  45. /// </summary>
  46. Rectangle m_rectControl;
  47. /// <summary>
  48. /// Gets or sets the rect control.
  49. /// </summary>
  50. /// <value>The rect control.</value>
  51. public Rectangle RectControl
  52. {
  53. get { return m_rectControl; }
  54. set
  55. {
  56. m_rectControl = value;
  57. }
  58. }
  59. /// <summary>
  60. /// The m location
  61. /// </summary>
  62. AnchorTipsLocation m_location;
  63. /// <summary>
  64. /// The m background
  65. /// </summary>
  66. Color? m_background = null;
  67. /// <summary>
  68. /// The m fore color
  69. /// </summary>
  70. Color? m_foreColor = null;
  71. /// <summary>
  72. /// The m font size
  73. /// </summary>
  74. int m_fontSize = 10;
  75. #region 构造函数 English:Constructor
  76. /// <summary>
  77. /// Initializes a new instance of the <see cref="FrmAnchorTips"/> class.
  78. /// </summary>
  79. /// <param name="rectControl">The rect control.</param>
  80. /// <param name="strMsg">The string MSG.</param>
  81. /// <param name="location">The location.</param>
  82. /// <param name="background">The background.</param>
  83. /// <param name="foreColor">Color of the fore.</param>
  84. /// <param name="fontSize">Size of the font.</param>
  85. /// <param name="autoCloseTime">The automatic close time.</param>
  86. private FrmAnchorTips(
  87. Rectangle rectControl,
  88. string strMsg,
  89. AnchorTipsLocation location = AnchorTipsLocation.RIGHT,
  90. Color? background = null,
  91. Color? foreColor = null,
  92. int fontSize = 10,
  93. int autoCloseTime = 5000)
  94. {
  95. InitializeComponent();
  96. m_rectControl = rectControl;
  97. m_location = location;
  98. m_background = background;
  99. m_foreColor = foreColor;
  100. m_fontSize = fontSize;
  101. StrMsg = strMsg;
  102. if (autoCloseTime > 0)
  103. {
  104. Timer t = new Timer();
  105. t.Interval = autoCloseTime;
  106. t.Tick += (a, b) =>
  107. {
  108. this.Close();
  109. };
  110. t.Enabled = true;
  111. }
  112. }
  113. /// <summary>
  114. /// Resets the form.
  115. /// </summary>
  116. /// <param name="strMsg">The string MSG.</param>
  117. private void ResetForm(string strMsg)
  118. {
  119. Graphics g = this.CreateGraphics();
  120. Font _font = new Font("微软雅黑", m_fontSize);
  121. Color _background = m_background == null ? Color.FromArgb(255, 77, 58) : m_background.Value;
  122. Color _foreColor = m_foreColor == null ? Color.White : m_foreColor.Value;
  123. System.Drawing.SizeF sizeText = g.MeasureString(strMsg, _font);
  124. g.Dispose();
  125. var formSize = new Size((int)sizeText.Width + 20, (int)sizeText.Height + 20);
  126. if (formSize.Width < 20)
  127. formSize.Width = 20;
  128. if (formSize.Height < 20)
  129. formSize.Height = 20;
  130. if (m_location == AnchorTipsLocation.LEFT || m_location == AnchorTipsLocation.RIGHT)
  131. {
  132. formSize.Width += 20;
  133. }
  134. else
  135. {
  136. formSize.Height += 20;
  137. }
  138. #region 获取窗体path English:Get the form path
  139. GraphicsPath path = new GraphicsPath();
  140. Rectangle rect;
  141. switch (m_location)
  142. {
  143. case AnchorTipsLocation.TOP:
  144. rect = new Rectangle(1, 1, formSize.Width - 2, formSize.Height - 20 - 1);
  145. this.Location = new Point(m_rectControl.X + (m_rectControl.Width - rect.Width) / 2, m_rectControl.Y - rect.Height - 20);
  146. break;
  147. case AnchorTipsLocation.RIGHT:
  148. rect = new Rectangle(20, 1, formSize.Width - 20 - 1, formSize.Height - 2);
  149. this.Location = new Point(m_rectControl.Right, m_rectControl.Y + (m_rectControl.Height - rect.Height) / 2);
  150. break;
  151. case AnchorTipsLocation.BOTTOM:
  152. rect = new Rectangle(1, 20, formSize.Width - 2, formSize.Height - 20 - 1);
  153. this.Location = new Point(m_rectControl.X + (m_rectControl.Width - rect.Width) / 2, m_rectControl.Bottom);
  154. break;
  155. default:
  156. rect = new Rectangle(1, 1, formSize.Width - 20 - 1, formSize.Height - 2);
  157. this.Location = new Point(m_rectControl.X - rect.Width - 20, m_rectControl.Y + (m_rectControl.Height - rect.Height) / 2);
  158. break;
  159. }
  160. int cornerRadius = 2;
  161. path.AddArc(rect.X, rect.Y, cornerRadius * 2, cornerRadius * 2, 180, 90);//左上角
  162. #region 上边
  163. if (m_location == AnchorTipsLocation.BOTTOM)
  164. {
  165. path.AddLine(rect.X + cornerRadius, rect.Y, rect.Left + rect.Width / 2 - 10, rect.Y);//上
  166. path.AddLine(rect.Left + rect.Width / 2 - 10, rect.Y, rect.Left + rect.Width / 2, rect.Y - 19);//上
  167. path.AddLine(rect.Left + rect.Width / 2, rect.Y - 19, rect.Left + rect.Width / 2 + 10, rect.Y);//上
  168. path.AddLine(rect.Left + rect.Width / 2 + 10, rect.Y, rect.Right - cornerRadius * 2, rect.Y);//上
  169. }
  170. else
  171. {
  172. path.AddLine(rect.X + cornerRadius, rect.Y, rect.Right - cornerRadius * 2, rect.Y);//上
  173. }
  174. #endregion
  175. path.AddArc(rect.X + rect.Width - cornerRadius * 2, rect.Y, cornerRadius * 2, cornerRadius * 2, 270, 90);//右上角
  176. #region 右边
  177. if (m_location == AnchorTipsLocation.LEFT)
  178. {
  179. path.AddLine(rect.Right, rect.Y + cornerRadius * 2, rect.Right, rect.Y + rect.Height / 2 - 10);//右
  180. path.AddLine(rect.Right, rect.Y + rect.Height / 2 - 10, rect.Right + 19, rect.Y + rect.Height / 2);//右
  181. path.AddLine(rect.Right + 19, rect.Y + rect.Height / 2, rect.Right, rect.Y + rect.Height / 2 + 10);//右
  182. path.AddLine(rect.Right, rect.Y + rect.Height / 2 + 10, rect.Right, rect.Y + rect.Height - cornerRadius * 2);//右
  183. }
  184. else
  185. {
  186. path.AddLine(rect.Right, rect.Y + cornerRadius * 2, rect.Right, rect.Y + rect.Height - cornerRadius * 2);//右
  187. }
  188. #endregion
  189. path.AddArc(rect.X + rect.Width - cornerRadius * 2, rect.Y + rect.Height - cornerRadius * 2, cornerRadius * 2, cornerRadius * 2, 0, 90);//右下角
  190. #region 下边
  191. if (m_location == AnchorTipsLocation.TOP)
  192. {
  193. path.AddLine(rect.Right - cornerRadius * 2, rect.Bottom, rect.Left + rect.Width / 2 + 10, rect.Bottom);
  194. path.AddLine(rect.Left + rect.Width / 2 + 10, rect.Bottom, rect.Left + rect.Width / 2, rect.Bottom + 19);
  195. path.AddLine(rect.Left + rect.Width / 2, rect.Bottom + 19, rect.Left + rect.Width / 2 - 10, rect.Bottom);
  196. path.AddLine(rect.Left + rect.Width / 2 - 10, rect.Bottom, rect.X + cornerRadius * 2, rect.Bottom);
  197. }
  198. else
  199. {
  200. path.AddLine(rect.Right - cornerRadius * 2, rect.Bottom, rect.X + cornerRadius * 2, rect.Bottom);
  201. }
  202. #endregion
  203. path.AddArc(rect.X, rect.Bottom - cornerRadius * 2, cornerRadius * 2, cornerRadius * 2, 90, 90);//左下角
  204. #region 左边
  205. if (m_location == AnchorTipsLocation.RIGHT)
  206. {
  207. path.AddLine(rect.Left, rect.Y + cornerRadius * 2, rect.Left, rect.Y + rect.Height / 2 - 10);//左
  208. path.AddLine(rect.Left, rect.Y + rect.Height / 2 - 10, rect.Left - 19, rect.Y + rect.Height / 2);//左
  209. path.AddLine(rect.Left - 19, rect.Y + rect.Height / 2, rect.Left, rect.Y + rect.Height / 2 + 10);//左
  210. path.AddLine(rect.Left, rect.Y + rect.Height / 2 + 10, rect.Left, rect.Y + rect.Height - cornerRadius * 2);//左
  211. }
  212. else
  213. {
  214. path.AddLine(rect.X, rect.Bottom - cornerRadius * 2, rect.X, rect.Y + cornerRadius * 2);//左
  215. }
  216. #endregion
  217. path.CloseFigure();
  218. #endregion
  219. Bitmap bit = new Bitmap(formSize.Width, formSize.Height);
  220. this.Size = formSize;
  221. #region 画图 English:Drawing
  222. Graphics gBit = Graphics.FromImage(bit);
  223. gBit.SetGDIHigh();
  224. gBit.FillPath(new SolidBrush(_background), path);
  225. gBit.DrawString(strMsg, _font, new SolidBrush(_foreColor), rect.Location + new Size(10, 10));
  226. gBit.Dispose();
  227. #endregion
  228. SetBits(bit);
  229. }
  230. #endregion
  231. #region 显示一个提示 English:Show a hint
  232. /// <summary>
  233. /// Shows the tips.
  234. /// </summary>
  235. /// <param name="parentControl">The parent control.</param>
  236. /// <param name="strMsg">The string MSG.</param>
  237. /// <param name="location">The location.</param>
  238. /// <param name="background">The background.</param>
  239. /// <param name="foreColor">Color of the fore.</param>
  240. /// <param name="deviation">The deviation.</param>
  241. /// <param name="fontSize">Size of the font.</param>
  242. /// <param name="autoCloseTime">The automatic close time.</param>
  243. /// <returns>FrmAnchorTips.</returns>
  244. public static FrmAnchorTips ShowTips(
  245. Control parentControl,
  246. string strMsg,
  247. AnchorTipsLocation location = AnchorTipsLocation.RIGHT,
  248. Color? background = null,
  249. Color? foreColor = null,
  250. Size? deviation = null,
  251. int fontSize = 10,
  252. int autoCloseTime = 5000)
  253. {
  254. Point p;
  255. if (parentControl is Form)
  256. {
  257. p = parentControl.Location;
  258. }
  259. else
  260. {
  261. p = parentControl.Parent.PointToScreen(parentControl.Location);
  262. }
  263. if (deviation != null)
  264. {
  265. p = p + deviation.Value;
  266. }
  267. return ShowTips(new Rectangle(p, parentControl.Size), strMsg, location, background, foreColor, fontSize, autoCloseTime);
  268. }
  269. #endregion
  270. #region 显示一个提示 English:Show a hint
  271. /// <summary>
  272. /// Shows the tips.
  273. /// </summary>
  274. /// <param name="rectControl">The rect control.</param>
  275. /// <param name="strMsg">The string MSG.</param>
  276. /// <param name="location">The location.</param>
  277. /// <param name="background">The background.</param>
  278. /// <param name="foreColor">Color of the fore.</param>
  279. /// <param name="fontSize">Size of the font.</param>
  280. /// <param name="autoCloseTime">The automatic close time.</param>
  281. /// <returns>FrmAnchorTips.</returns>
  282. public static FrmAnchorTips ShowTips(
  283. Rectangle rectControl,
  284. string strMsg,
  285. AnchorTipsLocation location = AnchorTipsLocation.RIGHT,
  286. Color? background = null,
  287. Color? foreColor = null,
  288. int fontSize = 10,
  289. int autoCloseTime = 5000)
  290. {
  291. FrmAnchorTips frm = new FrmAnchorTips(rectControl, strMsg, location, background, foreColor, fontSize, autoCloseTime);
  292. frm.TopMost = true;
  293. frm.Show();
  294. return frm;
  295. }
  296. #endregion
  297. #region Override
  298. /// <summary>
  299. /// 引发 <see cref="E:System.Windows.Forms.Form.Closing" /> 事件。
  300. /// </summary>
  301. /// <param name="e">一个包含事件数据的 <see cref="T:System.ComponentModel.CancelEventArgs" />。</param>
  302. protected override void OnClosing(CancelEventArgs e)
  303. {
  304. e.Cancel = true;
  305. base.OnClosing(e);
  306. haveHandle = false;
  307. this.Dispose();
  308. }
  309. /// <summary>
  310. /// Handles the <see cref="E:HandleCreated" /> event.
  311. /// </summary>
  312. /// <param name="e">包含事件数据的 <see cref="T:System.EventArgs" />。</param>
  313. protected override void OnHandleCreated(EventArgs e)
  314. {
  315. InitializeStyles();
  316. base.OnHandleCreated(e);
  317. haveHandle = true;
  318. }
  319. /// <summary>
  320. /// Gets the create parameters.
  321. /// </summary>
  322. /// <value>The create parameters.</value>
  323. protected override CreateParams CreateParams
  324. {
  325. get
  326. {
  327. CreateParams cParms = base.CreateParams;
  328. cParms.ExStyle |= 0x00080000; // WS_EX_LAYERED
  329. return cParms;
  330. }
  331. }
  332. #endregion
  333. /// <summary>
  334. /// Initializes the styles.
  335. /// </summary>
  336. private void InitializeStyles()
  337. {
  338. SetStyle(ControlStyles.AllPaintingInWmPaint, true);
  339. SetStyle(ControlStyles.UserPaint, true);
  340. UpdateStyles();
  341. }
  342. #region 根据图片显示窗体 English:Display Forms Based on Pictures
  343. /// <summary>
  344. /// 功能描述:根据图片显示窗体 English:Display Forms Based on Pictures
  345. /// 作  者:HZH
  346. /// 创建日期:2019-08-29 15:31:16
  347. /// 任务编号:
  348. /// </summary>
  349. /// <param name="bitmap">bitmap</param>
  350. /// <exception cref="System.ApplicationException">The picture must be 32bit picture with alpha channel.</exception>
  351. /// <exception cref="ApplicationException">The picture must be 32bit picture with alpha channel.</exception>
  352. private void SetBits(Bitmap bitmap)
  353. {
  354. if (!haveHandle) return;
  355. if (!Bitmap.IsCanonicalPixelFormat(bitmap.PixelFormat) || !Bitmap.IsAlphaPixelFormat(bitmap.PixelFormat))
  356. throw new ApplicationException("The picture must be 32bit picture with alpha channel.");
  357. IntPtr oldBits = IntPtr.Zero;
  358. IntPtr screenDC = Win32.GetDC(IntPtr.Zero);
  359. IntPtr hBitmap = IntPtr.Zero;
  360. IntPtr memDc = Win32.CreateCompatibleDC(screenDC);
  361. try
  362. {
  363. Win32.Point topLoc = new Win32.Point(Left, Top);
  364. Win32.Size bitMapSize = new Win32.Size(bitmap.Width, bitmap.Height);
  365. Win32.BLENDFUNCTION blendFunc = new Win32.BLENDFUNCTION();
  366. Win32.Point srcLoc = new Win32.Point(0, 0);
  367. hBitmap = bitmap.GetHbitmap(Color.FromArgb(0));
  368. oldBits = Win32.SelectObject(memDc, hBitmap);
  369. blendFunc.BlendOp = Win32.AC_SRC_OVER;
  370. blendFunc.SourceConstantAlpha = 255;
  371. blendFunc.AlphaFormat = Win32.AC_SRC_ALPHA;
  372. blendFunc.BlendFlags = 0;
  373. Win32.UpdateLayeredWindow(Handle, screenDC, ref topLoc, ref bitMapSize, memDc, ref srcLoc, 0, ref blendFunc, Win32.ULW_ALPHA);
  374. }
  375. finally
  376. {
  377. if (hBitmap != IntPtr.Zero)
  378. {
  379. Win32.SelectObject(memDc, oldBits);
  380. Win32.DeleteObject(hBitmap);
  381. }
  382. Win32.ReleaseDC(IntPtr.Zero, screenDC);
  383. Win32.DeleteDC(memDc);
  384. }
  385. }
  386. #endregion
  387. #region 无焦点窗体处理
  388. /// <summary>
  389. /// Sets the active window.
  390. /// </summary>
  391. /// <param name="handle">The handle.</param>
  392. /// <returns>IntPtr.</returns>
  393. [System.Runtime.InteropServices.DllImport("user32.dll")]
  394. private extern static IntPtr SetActiveWindow(IntPtr handle);
  395. /// <summary>
  396. /// The wm activate
  397. /// </summary>
  398. private const int WM_ACTIVATE = 0x006;
  399. /// <summary>
  400. /// The wm activateapp
  401. /// </summary>
  402. private const int WM_ACTIVATEAPP = 0x01C;
  403. /// <summary>
  404. /// The wm ncactivate
  405. /// </summary>
  406. private const int WM_NCACTIVATE = 0x086;
  407. /// <summary>
  408. /// The wa inactive
  409. /// </summary>
  410. private const int WA_INACTIVE = 0;
  411. /// <summary>
  412. /// The wm mouseactivate
  413. /// </summary>
  414. private const int WM_MOUSEACTIVATE = 0x21;
  415. /// <summary>
  416. /// The ma noactivate
  417. /// </summary>
  418. private const int MA_NOACTIVATE = 3;
  419. /// <summary>
  420. /// WNDs the proc.
  421. /// </summary>
  422. /// <param name="m">要处理的 Windows <see cref="T:System.Windows.Forms.Message" />。</param>
  423. protected override void WndProc(ref Message m)
  424. {
  425. if (m.Msg == WM_MOUSEACTIVATE)
  426. {
  427. m.Result = new IntPtr(MA_NOACTIVATE);
  428. return;
  429. }
  430. else if (m.Msg == WM_NCACTIVATE)
  431. {
  432. if (((int)m.WParam & 0xFFFF) != WA_INACTIVE)
  433. {
  434. if (m.LParam != IntPtr.Zero)
  435. {
  436. SetActiveWindow(m.LParam);
  437. }
  438. else
  439. {
  440. SetActiveWindow(IntPtr.Zero);
  441. }
  442. }
  443. }
  444. base.WndProc(ref m);
  445. }
  446. #endregion
  447. }
  448. /// <summary>
  449. /// Enum AnchorTipsLocation
  450. /// </summary>
  451. public enum AnchorTipsLocation
  452. {
  453. /// <summary>
  454. /// The left
  455. /// </summary>
  456. LEFT,
  457. /// <summary>
  458. /// The top
  459. /// </summary>
  460. TOP,
  461. /// <summary>
  462. /// The right
  463. /// </summary>
  464. RIGHT,
  465. /// <summary>
  466. /// The bottom
  467. /// </summary>
  468. BOTTOM
  469. }
  470. /// <summary>
  471. /// Class Win32.
  472. /// </summary>
  473. class Win32
  474. {
  475. /// <summary>
  476. /// Struct Size
  477. /// </summary>
  478. [StructLayout(LayoutKind.Sequential)]
  479. public struct Size
  480. {
  481. /// <summary>
  482. /// The cx
  483. /// </summary>
  484. public Int32 cx;
  485. /// <summary>
  486. /// The cy
  487. /// </summary>
  488. public Int32 cy;
  489. /// <summary>
  490. /// Initializes a new instance of the <see cref="Size" /> struct.
  491. /// </summary>
  492. /// <param name="x">The x.</param>
  493. /// <param name="y">The y.</param>
  494. public Size(Int32 x, Int32 y)
  495. {
  496. cx = x;
  497. cy = y;
  498. }
  499. }
  500. /// <summary>
  501. /// Struct BLENDFUNCTION
  502. /// </summary>
  503. [StructLayout(LayoutKind.Sequential, Pack = 1)]
  504. public struct BLENDFUNCTION
  505. {
  506. /// <summary>
  507. /// The blend op
  508. /// </summary>
  509. public byte BlendOp;
  510. /// <summary>
  511. /// The blend flags
  512. /// </summary>
  513. public byte BlendFlags;
  514. /// <summary>
  515. /// The source constant alpha
  516. /// </summary>
  517. public byte SourceConstantAlpha;
  518. /// <summary>
  519. /// The alpha format
  520. /// </summary>
  521. public byte AlphaFormat;
  522. }
  523. /// <summary>
  524. /// Struct Point
  525. /// </summary>
  526. [StructLayout(LayoutKind.Sequential)]
  527. public struct Point
  528. {
  529. /// <summary>
  530. /// The x
  531. /// </summary>
  532. public Int32 x;
  533. /// <summary>
  534. /// The y
  535. /// </summary>
  536. public Int32 y;
  537. /// <summary>
  538. /// Initializes a new instance of the <see cref="Point" /> struct.
  539. /// </summary>
  540. /// <param name="x">The x.</param>
  541. /// <param name="y">The y.</param>
  542. public Point(Int32 x, Int32 y)
  543. {
  544. this.x = x;
  545. this.y = y;
  546. }
  547. }
  548. /// <summary>
  549. /// The ac source over
  550. /// </summary>
  551. public const byte AC_SRC_OVER = 0;
  552. /// <summary>
  553. /// The ulw alpha
  554. /// </summary>
  555. public const Int32 ULW_ALPHA = 2;
  556. /// <summary>
  557. /// The ac source alpha
  558. /// </summary>
  559. public const byte AC_SRC_ALPHA = 1;
  560. /// <summary>
  561. /// Creates the compatible dc.
  562. /// </summary>
  563. /// <param name="hDC">The h dc.</param>
  564. /// <returns>IntPtr.</returns>
  565. [DllImport("gdi32.dll", ExactSpelling = true, SetLastError = true)]
  566. public static extern IntPtr CreateCompatibleDC(IntPtr hDC);
  567. /// <summary>
  568. /// Gets the dc.
  569. /// </summary>
  570. /// <param name="hWnd">The h WND.</param>
  571. /// <returns>IntPtr.</returns>
  572. [DllImport("user32.dll", ExactSpelling = true, SetLastError = true)]
  573. public static extern IntPtr GetDC(IntPtr hWnd);
  574. /// <summary>
  575. /// Selects the object.
  576. /// </summary>
  577. /// <param name="hDC">The h dc.</param>
  578. /// <param name="hObj">The h object.</param>
  579. /// <returns>IntPtr.</returns>
  580. [DllImport("gdi32.dll", ExactSpelling = true)]
  581. public static extern IntPtr SelectObject(IntPtr hDC, IntPtr hObj);
  582. /// <summary>
  583. /// Releases the dc.
  584. /// </summary>
  585. /// <param name="hWnd">The h WND.</param>
  586. /// <param name="hDC">The h dc.</param>
  587. /// <returns>System.Int32.</returns>
  588. [DllImport("user32.dll", ExactSpelling = true)]
  589. public static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);
  590. /// <summary>
  591. /// Deletes the dc.
  592. /// </summary>
  593. /// <param name="hDC">The h dc.</param>
  594. /// <returns>System.Int32.</returns>
  595. [DllImport("gdi32.dll", ExactSpelling = true, SetLastError = true)]
  596. public static extern int DeleteDC(IntPtr hDC);
  597. /// <summary>
  598. /// Deletes the object.
  599. /// </summary>
  600. /// <param name="hObj">The h object.</param>
  601. /// <returns>System.Int32.</returns>
  602. [DllImport("gdi32.dll", ExactSpelling = true, SetLastError = true)]
  603. public static extern int DeleteObject(IntPtr hObj);
  604. /// <summary>
  605. /// Updates the layered window.
  606. /// </summary>
  607. /// <param name="hwnd">The HWND.</param>
  608. /// <param name="hdcDst">The HDC DST.</param>
  609. /// <param name="pptDst">The PPT DST.</param>
  610. /// <param name="psize">The psize.</param>
  611. /// <param name="hdcSrc">The HDC source.</param>
  612. /// <param name="pptSrc">The PPT source.</param>
  613. /// <param name="crKey">The cr key.</param>
  614. /// <param name="pblend">The pblend.</param>
  615. /// <param name="dwFlags">The dw flags.</param>
  616. /// <returns>System.Int32.</returns>
  617. [DllImport("user32.dll", ExactSpelling = true, SetLastError = true)]
  618. public static extern int UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDst, ref Point pptDst, ref Size psize, IntPtr hdcSrc, ref Point pptSrc, Int32 crKey, ref BLENDFUNCTION pblend, Int32 dwFlags);
  619. /// <summary>
  620. /// Exts the create region.
  621. /// </summary>
  622. /// <param name="lpXform">The lp xform.</param>
  623. /// <param name="nCount">The n count.</param>
  624. /// <param name="rgnData">The RGN data.</param>
  625. /// <returns>IntPtr.</returns>
  626. [DllImport("gdi32.dll", ExactSpelling = true, SetLastError = true)]
  627. public static extern IntPtr ExtCreateRegion(IntPtr lpXform, uint nCount, IntPtr rgnData);
  628. }
  629. }