如题,我想要的效果是选中窗体中的某个控件(比如按钮)就在其周围产生虚线框
解决方案 »
- 正在连接到 用户名 密码
- Win Form 接收摄像头信号,截图直接存入数据库,本地不留档.
- socket 客户端 接收监听服务端 的返回消息
- clr via第9章中的一个疑问
- Currenex 接口
- winform 饼图显示问题,请高手进!!!
- 俺是写VB.net的,有一段C#代码俺看不明白,求解!
- java哪个IDE有这个功能?
- 請問Duwamish7那個用于加密的Duwamish7.snk文件是怎么產生
- DataGridView(Winform)双击表头时如何不触发这个DataGridView的双击事件
- 请问为什么我用vs。net打不开项目???
- 将richtextbox的背景设置为透明,结果就无法显示文字了
public static void DrawReversibleFrame(Rectangle rectangle, Color backColor, FrameStyle style)
{
int num;
Color white;
IntPtr ptr2;
if (backColor.GetBrightness() < 0.5)
{
num = 10;
white = Color.White;
}
else
{
num = 7;
white = Color.Black;
}
IntPtr handle = System.Windows.Forms.UnsafeNativeMethods.GetDCEx(new HandleRef(null, System.Windows.Forms.UnsafeNativeMethods.GetDesktopWindow()), System.Windows.Forms.NativeMethods.NullHandleRef, 0x403);
switch (style)
{
case FrameStyle.Dashed:
ptr2 = System.Windows.Forms.SafeNativeMethods.CreatePen(2, 1, ColorTranslator.ToWin32(backColor));
break; default:
ptr2 = System.Windows.Forms.SafeNativeMethods.CreatePen(0, 2, ColorTranslator.ToWin32(backColor));
break;
}
int nDrawMode = System.Windows.Forms.SafeNativeMethods.SetROP2(new HandleRef(null, handle), num);
IntPtr ptr3 = System.Windows.Forms.SafeNativeMethods.SelectObject(new HandleRef(null, handle), new HandleRef(null, System.Windows.Forms.UnsafeNativeMethods.GetStockObject(5)));
IntPtr ptr4 = System.Windows.Forms.SafeNativeMethods.SelectObject(new HandleRef(null, handle), new HandleRef(null, ptr2));
System.Windows.Forms.SafeNativeMethods.SetBkColor(new HandleRef(null, handle), ColorTranslator.ToWin32(white));
System.Windows.Forms.SafeNativeMethods.Rectangle(new HandleRef(null, handle), rectangle.X, rectangle.Y, rectangle.Right, rectangle.Bottom);
System.Windows.Forms.SafeNativeMethods.SetROP2(new HandleRef(null, handle), nDrawMode);
System.Windows.Forms.SafeNativeMethods.SelectObject(new HandleRef(null, handle), new HandleRef(null, ptr3));
System.Windows.Forms.SafeNativeMethods.SelectObject(new HandleRef(null, handle), new HandleRef(null, ptr4));
if (ptr2 != IntPtr.Zero)
{
System.Windows.Forms.SafeNativeMethods.DeleteObject(new HandleRef(null, ptr2));
}
System.Windows.Forms.UnsafeNativeMethods.ReleaseDC(System.Windows.Forms.NativeMethods.NullHandleRef, new HandleRef(null, handle));
}