忘了顺带一个问题 关于析构函数执行的问题
http://bbs.csdn.net/topics/390309862

解决方案 »

  1.   

    有个问题想问你,一开始截图是那个灰色半透明的窗体怎么做的,我用窗口结果childwindowfrompointex就只能找的我的窗口,下面的都被我的窗口盖住了。求解啊
      

  2.   

    你的第一个问题 我是 获取到屏幕图像 在上面 画了一层 黑色的半透明的矩形
    至于第二个  childwindowfrompointex 可以忽悠禁用窗体 将自己的窗体禁用就可以忽略过去了
      

  3.   

    - -!、、this.Enable = false;
    IntPtr hWnd = Win32.ChildWindowFromPointEx(Win32.GetDesktopWindow(), pt,  
            Win32.CWP_SKIPINVISIBL | Win32.CWP_SKIPDISABLED);函数功能:该函数确定属于父窗口的哪一个子窗口(如果存在的话)包含着指定的点。该函数可以忽略不可见的、禁止的和透明的子窗口。    函数原型:HWND ChidWindowFromaPointEx(HWND hwndParent,POINT pt,UNIT uFlags);    参数:    hWndParent:父窗口句柄。    pt:指定一个POINT结构,该结构定义了被检查的点的坐标。    uFlags:指明忽略的子窗口的类型。该参数可以是下列参数的组合。    CWP_ALL:不忽略任一子窗口。CWP_SKIPINVISIBLE:忽略不可见的子窗口。    CWP_SKIPDISABLE:忽略禁止的子窗口。CWP_SKIPTRABSPARENT:忽略透明子窗口。    返回值:返回值为包含该点并且满足由uFlags定义的规则的第一个子窗口的句柄。如果该点在父窗口内,但在任一满足条件的子窗口外,则返回值为父窗口句柄。如果该点在父窗口之外或函数失败,则返回值为NULL。    备注:系统有一个与某一父窗口有联系的所有子窗口的内部列表。列表中的句柄顺序依据这些子窗口的Z序。如果有多于一个的子窗口包含该点,那么系统返回在列表中包含该点并且满足由uFlags定义的规则的第一个窗口的句柄。    速查:WindowS NT:4.0以上版本;Windows:95以上版本;Windows CE:不支持;头文件:Winuser.h;库文件:user32.lib。
      

  4.   

    还是不行,不能透过去。我是用一个窗体,背景设为黑,然后把不透明度调低用来做那个灰色的效果。当时就是childwindowfrompointex透不过去
      

  5.   

    还是不行,不能透过去。我是用一个窗体,背景设为黑,然后把不透明度调低用来做那个灰色的效果。当时就是childwindowfrompointex透不过去
      

  6.   

    你能不能做个可以透过的给我看看。只要childwindowfrompointex可以透过就行。
      

  7.   


    public partial class Form1 : Form
    {
    [DllImport("user32.dll")]
    public static extern IntPtr GetDesktopWindow(); [DllImport("user32.dll")]//在桌面找寻子窗体
    public static extern IntPtr ChildWindowFromPointEx(IntPtr pHwnd, Point pt, uint uFlgs);
    public const int CWP_SKIPDISABLED = 0x2;   //忽略不可用窗体
    public const int CWP_SKIPINVISIBL = 0x1;   //忽略隐藏的窗体 [DllImport("user32.dll")]//获得句柄对象的位置
    public static extern bool GetWindowRect(IntPtr hWnd, out LPRECT lpRect); public struct LPRECT
    {
    public int Left;
    public int Top;
    public int Right;
    public int Bottom;
    } public Form1() {
    InitializeComponent(); Timer t = new Timer();
    t.Interval = 500;
    t.Enabled = true;
    t.Tick += new EventHandler(t_Tick);
    this.FormBorderStyle = FormBorderStyle.None;
    this.Location = new Point(0, 0);
    this.Size = new Size(Screen.PrimaryScreen.Bounds.Width,
    Screen.PrimaryScreen.Bounds.Height); this.Load += (s, e) => this.BeginInvoke(new MethodInvoker(() => this.Enabled = false));
    m_bmpScreen = GetScreen(); this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
    } private Rectangle m_rect;
    private Bitmap m_bmpScreen; void t_Tick(object sender, EventArgs e) {
    IntPtr hWnd = ChildWindowFromPointEx(GetDesktopWindow(), MousePosition,
    CWP_SKIPDISABLED | CWP_SKIPINVISIBL);
    LPRECT lpRect = new LPRECT();
    GetWindowRect(hWnd, out lpRect);
    m_rect.X = lpRect.Left; m_rect.Y = lpRect.Top;
    m_rect.Width = lpRect.Right - lpRect.Left;
    m_rect.Height = lpRect.Bottom - lpRect.Top;
    this.Invalidate();
    } protected override void OnPaint(PaintEventArgs e) {
    Graphics g = e.Graphics;
    g.DrawImage(m_bmpScreen, 0, 0);
    g.DrawRectangle(Pens.Cyan, m_rect);
    base.OnPaint(e);
    } private Bitmap GetScreen() {
    Bitmap bmp = new Bitmap(this.Width, this.Height);
    using (Graphics g = Graphics.FromImage(bmp)) {
    g.CopyFromScreen(0, 0, 0, 0, bmp.Size);
    }
    return bmp;
    }
    }
      

  8.   

    哈哈,比自己做的现在用的漂亮多了,工具条也很好。
    PS:有个bug,选中后再选中区域双击后会有异常