zoukankan      html  css  js  c++  java
  • 枚举当前所有的 IE 窗口 回复 "混岗" 的问题

    问题来源: http://www.cnblogs.com/del/archive/2008/02/28/1085432.html#1247615

    致 "混岗" 同学: 你同时提到 IE 中的 "输入框", 没有明白你的意思; 这个例子只是找顶层窗口, IE 的 "输入框" 是 IE 窗口的子窗口, 需要在此基础上继续枚举子窗口.

    本例效果图(测试时, 我打开了: 搜狐、谷歌和我的博客):



    代码文件:
    unit Unit1;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;
    
    type
      TForm1 = class(TForm)
        Button1: TButton;
        Memo1: TMemo;
        procedure FormCreate(Sender: TObject);
        procedure Button1Click(Sender: TObject);
      end;
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.dfm}
    
    procedure TForm1.FormCreate(Sender: TObject);
    begin
      Memo1.Align := alTop;
      Memo1.ScrollBars := ssBoth;
      Memo1.Clear;
    end;
    
    procedure TForm1.Button1Click(Sender: TObject);
    const
      className = 'IEFrame'; {这是 IE 浏览器的类名}
    var
      h: HWnd;
      buf: array[Byte] of Char;
    begin
      h := GetWindow(Handle, GW_HWNDFIRST);
      while h <> 0 do
      begin
        GetClassName(h, buf, Length(buf));
        if buf = className then {找到咋处理? 显示它的标题吧}
        begin
          GetWindowText(h, buf, Length(buf));
          Memo1.Lines.Add(buf)
        end;
        h := GetWindow(h, GW_HWNDNEXT);
      end;
    end;
    
    end.
    
    窗体文件:
    object Form1: TForm1
      Left = 0
      Top = 0
      Caption = 'Form1'
      ClientHeight = 168
      ClientWidth = 319
      Color = clBtnFace
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'Tahoma'
      Font.Style = []
      OldCreateOrder = False
      OnCreate = FormCreate
      PixelsPerInch = 96
      TextHeight = 13
      object Button1: TButton
        Left = 126
        Top = 127
        Width = 75
        Height = 25
        Caption = 'Button1'
        TabOrder = 0
        OnClick = Button1Click
      end
      object Memo1: TMemo
        Left = 8
        Top = 8
        Width = 185
        Height = 113
        Lines.Strings = (
          'Memo1')
        TabOrder = 1
      end
    end
    
  • 相关阅读:
    ELK初学搭建(logstash)
    认识基本的UI资源
    C# 枚举器
    NGUI---使用脚本控制聊天系统的内容显示,输入事件交互
    NGUI----简单聊天系统一
    C# 类型、存储和变量
    C# Execl表格文件转xml文件
    网易云音乐如何从0到亿级用户整理笔记
    如何成为一名完美的传道授业解惑者
    grouping sets,cube,rollup,grouping__id,group by
  • 原文地址:https://www.cnblogs.com/del/p/1237804.html
Copyright © 2011-2022 走看看