zoukankan      html  css  js  c++  java
  • GetParent、SetParent、MoveWindow

    提示: SetParent 应该 Windows.SetParent, 因为 TForm 的父类有同名方法.


    //声明:
    
    {获取父窗口句柄}
    GetParent(hWnd: HWND): HWND;
    
    {指定父窗口}
    SetParent(
      hWndChild: HWND;    {子句柄}
      hWndNewParent: HWND {父句柄}
    ): HWND;              {成功返回原父窗口句柄; 失败返回 0}
    
    {移动窗口}
    MoveWindow(
      hWnd: HWND;               {窗口句柄}
      X, Y: Integer;            {位置}
      nWidth, nHeight: Integer; {大小}
      bRepaint: BOOL            {True 表示刷新; False 表示不刷新}
    ): BOOL;

    //举例:
    unit Unit1;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, ExtCtrls;
    
    type
      TForm1 = class(TForm)
        Edit1: TEdit;
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      end;
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.dfm}
    
    procedure TForm1.Button1Click(Sender: TObject);
    begin
      if GetParent(Edit1.Handle)=Handle then
      begin
        Windows.SetParent(Edit1.Handle, Button1.Handle);
        MoveWindow(Edit1.Handle, 0,0, Edit1.Width, Edit1.Height, True);
      end else begin
        Windows.SetParent(Edit1.Handle, Self.Handle);
        MoveWindow(Edit1.Handle, 0,0, Edit1.Width, Edit1.Height, True);
      end;
    end;
    
    end.

    http://www.cnblogs.com/del/archive/2008/03/10/1097964.html

    GetParent - 获取指定窗口的父窗口句柄
    IsChild - 判断两个窗口是不是父子关系
    http://www.cnblogs.com/del/category/122518.html

  • 相关阅读:
    Jmeter beanshell preprocessor随机添加任意多个请求参数
    Jmeter 场景设计
    jmeter 参数化
    .net 匿名方法
    jmeter 运行脚本报错 java.net.BindException: Address already in use
    Jmeter mysql性能测试
    ngcordova 监控网络制式改变
    建立apk定时自动打包系统第一篇——Ant多渠道打包并指定打包目录和打包日期
    Kafka架构
    Linux命令
  • 原文地址:https://www.cnblogs.com/findumars/p/5342768.html
Copyright © 2011-2022 走看看