using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace JJMediSys { public partial class DispenseMsg : Form { Dispensing fordispensing; [DllImport("Gdi32.dll", EntryPoint = "CreateRoundRectRgn")] private static extern IntPtr CreateRoundRectRgn ( int nLeftRect, // x-coordinate of upper-left corner int nTopRect, // y-coordinate of upper-left corner int nRightRect, // x-coordinate of lower-right corner int nBottomRect, // y-coordinate of lower-right corner int nWidthEllipse, // height of ellipse int nHeightEllipse // width of ellipse ); [DllImport("dwmapi.dll")] public static extern int DwmExtendFrameIntoClientArea(IntPtr hWnd, ref MARGINS pMarInset); [DllImport("dwmapi.dll")] public static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, ref int attrValue, int attrSize); [DllImport("dwmapi.dll")] public static extern int DwmIsCompositionEnabled(ref int pfEnabled); private bool m_aeroEnabled; // variables for box shadow private const int CS_DROPSHADOW = 0x00020000; private const int WM_NCPAINT = 0x0085; private const int WM_ACTIVATEAPP = 0x001C; public struct MARGINS // struct for box shadow { public int leftWidth; public int rightWidth; public int topHeight; public int bottomHeight; } private const int WM_NCHITTEST = 0x84; // variables for dragging the form private const int HTCLIENT = 0x1; private const int HTCAPTION = 0x2; protected override CreateParams CreateParams { get { m_aeroEnabled = CheckAeroEnabled(); CreateParams cp = base.CreateParams; if (!m_aeroEnabled) cp.ClassStyle |= CS_DROPSHADOW; return cp; } } private bool CheckAeroEnabled() { if (Environment.OSVersion.Version.Major >= 6) { int enabled = 0; DwmIsCompositionEnabled(ref enabled); return (enabled == 1) ? true : false; } return false; } protected override void WndProc(ref Message m) { switch (m.Msg) { case WM_NCPAINT: // box shadow if (m_aeroEnabled) { var v = 2; DwmSetWindowAttribute(this.Handle, 2, ref v, 4); MARGINS margins = new MARGINS() { bottomHeight = 1, leftWidth = 1, rightWidth = 1, topHeight = 1 }; DwmExtendFrameIntoClientArea(this.Handle, ref margins); } break; default: break; } base.WndProc(ref m); if (m.Msg == WM_NCHITTEST && (int)m.Result == HTCLIENT) // drag the form m.Result = (IntPtr)HTCAPTION; } public DispenseMsg(Dispensing dispensing) { m_aeroEnabled = false; InitializeComponent(); fordispensing = dispensing; } private void DispenseMsg_Load(object sender, EventArgs e) { LabErrorInfo.Text = fordispensing.ErrorInfoStr; int x = fordispensing.Location.X + (fordispensing.Width - this.Width) / 2; int y = fordispensing.Location.Y + (fordispensing.Height - this.Height) / 2; this.Location = new Point(x, y); } private void button2_Click(object sender, EventArgs e) { if (MessageBox.Show("重发当前患者试管,请作废当前患者已出的试管,请确认已取走贴标单元已打印的标签并复位设备!", "注意", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { fordispensing.DispenseRetry = true; } this.Close(); } private void BReset_Click(object sender, EventArgs e) { fordispensing.fm1.SysReset(); } private void BNext_Click(object sender, EventArgs e) { if (MessageBox.Show("请确认已取走贴标单元已打印的标签并复位设备!", "注意", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { fordispensing.DispenseNext = true; } this.Close(); } private void BCancel_Click(object sender, EventArgs e) { SystemSet.CancelDispensing = true; //手动点击终止后 ,TubeLabelTool.cs中的循环将退出 并返回手动取消状态 if (!fordispensing.isStop)//处于可手动终止状态 fordispensing.DispenseCancel = true; // //fordispensing.Closewin(); this.Close(); } } }