تقييم الموضوع :
  • 6 أصوات - بمعدل 3.5
  • 1
  • 2
  • 3
  • 4
  • 5
uWindowStyle unit
#1
{
  Coded by Agmcz
  Date: 21-01-2016
  Thanks to SMP3
  .......
  Added func WS_EX_Exists (12-03-2016) 
}

unit uWindowStyle;

interface

uses
  Windows, Classes;

procedure GetWindowStylesList(hWindow: THandle; out StylesList: TStringList);
procedure GetWindowStylesExtendedList(hWindow: THandle; out StylesList: TStringList);
function WS_Exists(hWindow: THandle; Style: Integer): Boolean;
function WS_EX_Exists(hWindow: THandle; ExStyle: Integer): Boolean;

implementation

procedure GetWindowStylesList(hWindow: THandle; out StylesList: TStringList);
const
  WSStr: array[0..17] of string = (
    'WS_OVERLAPPED',
    'WS_POPUP',
    'WS_CHILD',
    'WS_MINIMIZE',
    'WS_VISIBLE',
    'WS_DISABLED',
    'WS_CLIPSIBLINGS',
    'WS_CLIPCHILDREN',
    'WS_MAXIMIZE',
    'WS_CAPTION',
    'WS_BORDER',
    'WS_DLGFRAME',
    'WS_VSCROLL',
    'WS_HSCROLL',
    'WS_SYSMENU',
    'WS_THICKFRAME',
    'WS_GROUP',
    'WS_TABSTOP');
  WSInt: array[0..17] of Integer = (
    0,
    $80000000,
    $40000000,
    $20000000,
    $10000000,
    $8000000,
    $4000000,
    $2000000,
    $1000000,
    $C00000,
    $800000,
    $400000,
    $200000,
    $100000,
    $80000,
    $40000,
    $20000,
    $10000);
var
  I, dwOldLong: Integer;
begin
  dwOldLong := GetWindowLong(hWindow, GWL_STYLE);
  for I := Low(WSInt) to High(WSInt) do
  begin
    if dwOldLong or WSInt[I] = dwOldLong then
      StylesList.Add(WSStr[I]);
  end;
end;

procedure GetWindowStylesExtendedList(hWindow: THandle; out StylesList: TStringList);
const
  EXWSStr: array[0..23] of string = (
    'WS_EX_DLGMODALFRAME',
    'WS_EX_NOPARENTNOTIFY',
    'WS_EX_TOPMOST',
    'WS_EX_ACCEPTFILES',
    'WS_EX_TRANSPARENT',
    'WS_EX_MDICHILD',
    'WS_EX_TOOLWINDOW',
    'WS_EX_WINDOWEDGE',
    'WS_EX_CLIENTEDGE',
    'WS_EX_CONTEXTHELP',
    'WS_EX_RIGHT',
    'WS_EX_LEFT',
    'WS_EX_RTLREADING',
    //'WS_EX_LTRREADING',     // = 0;
    'WS_EX_LEFTSCROLLBAR',
    //'WS_EX_RIGHTSCROLLBAR', // = 0;
    'WS_EX_CONTROLPARENT',
    'WS_EX_STATICEDGE',
    'WS_EX_APPWINDOW',
    'WS_EX_OVERLAPPEDWINDOW', // = (WS_EX_WINDOWEDGE or WS_EX_CLIENTEDGE);
    'WS_EX_PALETTEWINDOW',    // = (WS_EX_WINDOWEDGE or WS_EX_TOOLWINDOW or WS_EX_TOPMOST);
    'WS_EX_LAYERED',
    'WS_EX_NOINHERITLAYOUT',
    'WS_EX_LAYOUTRTL',
    'WS_EX_COMPOSITED',
    'WS_EX_NOACTIVATE');
  EXWSInt: array[0..23] of Integer = (
    1,
    4,
    8,
    $10,
    $20,
    $40,
    $80,
    $100,
    $200,
    $400,
    $1000,
    0,
    $2000,
    //0,
    $4000,
    //0,
    $10000,
    $20000,
    $40000,
    WS_EX_OVERLAPPEDWINDOW,
    WS_EX_PALETTEWINDOW,
    $00080000,
    $00100000,
    $00400000,
    $02000000,
    $08000000);
var
  I, dwOldLong: Integer;
begin
  dwOldLong := GetWindowLong(hWindow, GWL_EXSTYLE);
  for I := Low(EXWSInt) to High(EXWSInt) do
  begin
    if dwOldLong or EXWSInt[I] = dwOldLong then
      StylesList.Add(EXWSStr[I]);
  end;
end;

function WS_Exists(hWindow: THandle; Style: Integer): Boolean;
var
  dwOldLong: Integer;
begin
  dwOldLong := GetWindowLong(hWindow, GWL_STYLE);
  Result := dwOldLong or Style = dwOldLong;
end;

function WS_Ex_Exists(hWindow: THandle; ExStyle: Integer): Boolean;
var
  dwOldLong: Integer;
begin
  dwOldLong := GetWindowLong(hWindow, GWL_EXSTYLE);
  Result := dwOldLong or ExStyle = dwOldLong;
end;

{
Usage:
//GetWindowStylesList
var
  SL: TStringList;
begin
  SL := TStringList.Create;
  try
    GetWindowStylesList(Handle, SL);
    //SL
  finally
    SL.Free;
  end;
end;

//GetWindowStylesExtendedList
var
  SL: TStringList;
begin
  SL := TStringList.Create;
  try
    GetWindowStylesExtendedList(Handle, SL);
    //SL
  finally
    SL.Free;
  end;
end;

//WS_Exists
begin
  if WS_Exists(Handle, WS_VISIBLE) then
    //Exists
end;

//WS_EX_Exists
begin
  if WS_EX_Exists(Handle, WS_EX_LAYERED) then
    //Exists
end;
}

end. 
أعضاء أعجبوا بهذه المشاركة : AT4RE , M!X0R , hassan33


الردود في هذا الموضوع
uWindowStyle unit - بواسطة AX302 - 19-10-2018, 08:26 PM
RE: uWindowStyle unit - بواسطة TeRcO - 10-11-2024, 04:59 PM

التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 3 ) ضيف كريم