zoukankan      html  css  js  c++  java
  • Delphi调用WINAPI时到底应该是指针还是结构体(注意是Delphi变量本身就是指针)

    看MSDN,GetWindowRect的说明如下:

    BOOL WINAPI GetWindowRect(
      _In_  HWND   hWnd,
      _Out_ LPRECT lpRect // 注意,没*号指针
    );

    BOOL WINAPI GetWindowPlacement(
      _In_    HWND            hWnd,
      _Inout_ WINDOWPLACEMENT *lpwndpl  // 注意,有*号指针,这里可能已经是双重指针
    );

    但是实际调用直接传递Rect结构体,而不是指针:
    procedure TWinControl.UpdateBounds;
    var
      ParentHandle: HWnd; // 4字节
      Rect: TRect; // 16字节
      WindowPlacement: TWindowPlacement; // 44字节
    begin
      // 非最小化状态下,取得Win控件显示区域
      if IsIconic(FHandle) then // API
      begin
        WindowPlacement.Length := SizeOf(WindowPlacement);
        GetWindowPlacement(FHandle, @WindowPlacement); // API,传递的是指针
        Rect := WindowPlacement.rcNormalPosition;
      end else
        GetWindowRect(FHandle, Rect); // API,取得客户区,注意第二个参数是结构体本身,而不是结构体指针,在Delphi里直接使用
    end;
    
    
    
  • 相关阅读:
    种子销售管理需求
    三角函数
    软件人性化的体现
    三角函数
    ProductManager
    不能说的秘密
    种子销售管理需求
    JTable使用
    不能说的秘密
    设计模式(了解篇)转载
  • 原文地址:https://www.cnblogs.com/findumars/p/4770275.html
Copyright © 2011-2022 走看看