HWND FindWindowEx(HWND hwndParent,HWND hwndChildAfter,LPCTSTR lpszClass,LPCTSTR lpszWindow);第一参数,
第二参数,
第三参数,
第四参数,分别怎么使用,可以示一些源码,并说明一下吗?国内的相关FindWindowEx的Blog都说得不怎么清楚,MSDN说的,就第三个参数,和第四个参数不理解。主要理解第三,四参数。谢谢了。没有可用分了。

解决方案 »

  1.   

    lpszClass:窗口类名。在win32编程中,创建一个窗口需要先创建一个窗口类,就是这个名字,比如记事本的类名是notepadlpszWindow:窗口标题。这个没什么好解释的,一眼就看出来了,比如打开a.txt文件,标题栏是:
    "a.txt - 记事本"
      

  2.   

    {窗口的类名}
    {窗口的标题}我的这篇文章里面有例子
    http://blog.csdn.net/lovefootball/archive/2009/02/24/3933232.aspx自己结合Spy++看一下就明白了
      

  3.   


    我之前就是这样认为:
    第三:类名
    第四:.Text属性但用了就知道,不是这个。因为我用SPY++找到控件相关的类名。如Button控件的类名:
    WindowsForms10.BUTTON.app.0.14fd2b5Button.Text="确定";我就把第三参数赋值为"WindowsForms10.BUTTON.app.0.14fd2b5".
    第四参数赋值为"确定";但结果还是找不到。
      

  4.   

    我试过了,确实不行,估计不支持.Net的类名
      

  5.   

    用不着类名,窗口标题就可以了。类名指定为null
      

  6.   

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.Runtime .InteropServices ;namespace WindowsApplication128
    {
        public partial class Form1 : Form
        {
            [DllImport("user32.dll")]
            static extern int GetClassName(IntPtr Handle, [Out] StringBuilder ClassName, int MaxCount);        [DllImport("user32.dll")]
            static extern int SendMessage(IntPtr Handle, int WParam, int LParam);        [DllImport("user32.dll")]
            static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);        Button B = new Button();        public Form1()
            {
                InitializeComponent();            B.Parent = this;
                B.Click += new EventHandler(B_Click);            this.Shown += new EventHandler(Form1_Shown);
            }
            private void B_Click(object sender, EventArgs e)
            {
                MessageBox.Show("!!!");
            }        void Form1_Shown(object sender, EventArgs e)
            {
                int WM_CLICK = 0x00F5;            StringBuilder ClassName = new StringBuilder(256);
                GetClassName(B.Handle, ClassName, ClassName.Capacity);            IntPtr Handle = FindWindowEx(this.Handle, IntPtr.Zero, ClassName.ToString(), String.Empty);
                SendMessage(Handle, WM_CLICK, 0);
            }
        }
    }
      

  7.   

    我用了就能找到啊, string lpszClass = "WindowsForms10.BUTTON.app.0.21af1a5";
                string lpszWindow = "button1";
                IntPtr EdithWnd = new IntPtr(0);
                EdithWnd = FindWindowEx(ParenthWnd, EdithWnd, lpszClass, lpszWindow);其中ParenthWnd是控件父窗体的句柄,可以用spy++查,也可以用FindWindow来获得的