应该能获得吧,你要查查windows消息,哪个是关于控件字体的。

解决方案 »

  1.   

    根据SPY++中取得的类名(或标题名)及层次关系
    [DllImport("user32.dll", EntryPoint = "FindWindow")]
    private extern static IntPtr FindWindow(string lpClassName, string lpWindowName);
    [DllImport("user32.dll")]
    static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);private void button1_Click(object sender, EventArgs e)
    {
      IntPtr hWnd1 = FindWindow(null, "主窗口标题");   
      SetForegroundWindow(hWnd1);
      IntPtr hWnd2 = FindWindowEx(hWnd1, IntPtr.Zero, null, "控件文本");   
      IntPtr hWnd3 = FindWindowEx(hWnd1, IntPtr.Zero, "控件类名", null);  
      System.Text.StringBuilder   str   =   new   System.Text.StringBuilder(255); 
    SendMessage(hWnd2 ,   0xD,   str.Capacity,   str); 
    MessageBox.Show(str.ToString());  
    }
      
      

  2.   

    Hi, wuyq11
    SendMessage 可以得到字符串但是不能得到字体信息啊,可能是我没说清楚,我想得到的是控件上的Font信息,不知道能不能得到。
      

  3.   

    我看到SendMessage第二个参数可以支持WM_GETFONT ,但是不知道怎么用。麻烦高手讲解一下。
      

  4.   

    SendMessage(hWnd2 ,WM_GETFONT, str.Capacity, str);  
      

  5.   

    SendMessage(hWnd2 ,WM_GETFONT, str.Capacity, str); 这样得不到字体信息啊,我把str改成Font类型的也不可以。不知道doubleu2005 你有没有试过。