Форум: "Начинающим";
Текущий архив: 2008.01.13;
Скачать: [xml.tar.bz2];
ВнизРазложить стиль окна Найти похожие ветки
← →
сосед (2007-12-14 16:25) [0]Нет ли чего нибудь попроще(постандартнее, покрасивше... правильнее) чем вот это:
function GetWindowStyle(const Wnd: HWND; Lst: TStrings): Integer;
begin
Result := GetWindowLong(Wnd, GWL_STYLE);
if not Assigned(LSt) or (Result=0) then Exit;
if Result and WS_OVERLAPPED = WS_OVERLAPPED then Lst.Add("WS_OVERLAPPED");
if Result and WS_POPUP = WS_POPUP then Lst.Add("WS_POPUP");
if Result and WS_CHILD = WS_CHILD then Lst.Add("WS_CHILD");
if Result and WS_MINIMIZE = WS_MINIMIZE then Lst.Add("WS_MINIMIZE");
if Result and WS_VISIBLE = WS_VISIBLE then Lst.Add("WS_VISIBLE");
if Result and WS_DISABLED = WS_DISABLED then Lst.Add("WS_DISABLED");
if Result and WS_CLIPSIBLINGS = WS_CLIPSIBLINGS then Lst.Add("WS_CLIPSIBLINGS");
if Result and WS_CLIPCHILDREN = WS_CLIPCHILDREN then Lst.Add("WS_CLIPCHILDREN");
if Result and WS_MAXIMIZE = WS_MAXIMIZE then Lst.Add("WS_MAXIMIZE");
if Result and WS_CAPTION = WS_CAPTION then Lst.Add("WS_CAPTION");
if Result and WS_BORDER = WS_BORDER then Lst.Add("WS_BORDER");
if Result and WS_DLGFRAME = WS_DLGFRAME then Lst.Add("WS_DLGFRAME");
if Result and WS_VSCROLL = WS_VSCROLL then Lst.Add("WS_VSCROLL");
if Result and WS_HSCROLL = WS_HSCROLL then Lst.Add("WS_HSCROLL");
if Result and WS_SYSMENU = WS_SYSMENU then Lst.Add("WS_SYSMENU");
if Result and WS_THICKFRAME = WS_THICKFRAME then Lst.Add("WS_THICKFRAME");
if Result and WS_GROUP = WS_GROUP then Lst.Add("WS_GROUP");
if Result and WS_TABSTOP = WS_TABSTOP then Lst.Add("WS_TABSTOP");
Lst.Add("");
if Result and WS_MINIMIZEBOX = WS_MINIMIZEBOX then Lst.Add("WS_MINIMIZEBOX");
if Result and WS_MAXIMIZEBOX = WS_MAXIMIZEBOX then Lst.Add("WS_MAXIMIZEBOX");
Lst.Add("");
if Result and WS_TILED = WS_TILED then Lst.Add("WS_TILED");
if Result and WS_ICONIC = WS_ICONIC then Lst.Add("WS_ICONIC");
if Result and WS_SIZEBOX = WS_SIZEBOX then Lst.Add("WS_SIZEBOX");
Lst.Add("");
Lst.Add("[Common Window Styles]");
if Result and WS_OVERLAPPEDWINDOW = WS_OVERLAPPEDWINDOW then Lst.Add("WS_OVERLAPPEDWINDOW");
if Result and WS_TILEDWINDOW = WS_TILEDWINDOW then Lst.Add("WS_TILEDWINDOW");
if Result and WS_POPUPWINDOW = WS_POPUPWINDOW then Lst.Add("WS_POPUPWINDOW");
if Result and WS_CHILDWINDOW = WS_CHILDWINDOW then Lst.Add("WS_CHILDWINDOW");
end;
И еще одна такая же для GWL_EXSTYLE
← →
Anatoly Podgoretsky © (2007-12-14 16:29) [1]> сосед (14.12.2007 16:25:00) [0]
В цикле и массив констант?
Но проще нельзя, здесь самое простое, линейное исполнение.
← →
clickmaker © (2007-12-14 16:34) [2]
> сосед (14.12.07 16:25)
по-проще - вряд ли, а по красивше
type TStyleNames = record
Style: Cardinal;
Name: string;
end;
забить константный массив записей, в цикле проверять текущий стиль and R[i].Style then Lst.Add(R[i].Name)
← →
сосед (2007-12-14 17:38) [3]
> Anatoly Podgoretsky © (14.12.07 16:29) [1]
> clickmaker © (14.12.07 16:34) [2]
Спасибо.
Получилось вот так:type
TStyleName = record
Style: Cardinal;
Name: String;
end;
const
STYLE_NAMES: array [0..26] of TStyleName =(
(Style: WS_OVERLAPPED; Name: "WS_OVERLAPPED"),
(Style: WS_POPUP; Name: "WS_POPUP"),
(Style: WS_CHILD; Name: "WS_CHILD"),
(Style: WS_MINIMIZE; Name: "WS_MINIMIZE"),
(Style: WS_VISIBLE; Name: "WS_VISIBLE"),
(Style: WS_DISABLED; Name: "WS_DISABLED"),
(Style: WS_CLIPSIBLINGS; Name: "WS_CLIPSIBLINGS"),
(Style: WS_CLIPCHILDREN; Name: "WS_CLIPCHILDREN"),
(Style: WS_MAXIMIZE; Name: "WS_MAXIMIZE"),
(Style: WS_CAPTION; Name: "WS_CAPTION"),
(Style: WS_BORDER; Name: "WS_BORDER"),
(Style: WS_DLGFRAME; Name: "WS_DLGFRAME"),
(Style: WS_VSCROLL; Name: "WS_VSCROLL"),
(Style: WS_HSCROLL; Name: "WS_HSCROLL"),
(Style: WS_SYSMENU; Name: "WS_SYSMENU"),
(Style: WS_THICKFRAME; Name: "WS_THICKFRAME"),
(Style: WS_GROUP; Name: "WS_GROUP"),
(Style: WS_TABSTOP; Name: "WS_TABSTOP"),
(Style: WS_MINIMIZEBOX; Name: "WS_MINIMIZEBOX"),
(Style: WS_MAXIMIZEBOX; Name: "WS_MAXIMIZEBOX"),
(Style: WS_TILED; Name: "WS_TILED"),
(Style: WS_ICONIC; Name: "WS_ICONIC"),
(Style: WS_SIZEBOX; Name: "WS_SIZEBOX"),
(Style: WS_OVERLAPPEDWINDOW; Name: "WS_OVERLAPPEDWINDOW"),
(Style: WS_TILEDWINDOW; Name: "WS_TILEDWINDOW"),
(Style: WS_POPUPWINDOW; Name: "WS_POPUPWINDOW"),
(Style: WS_CHILDWINDOW; Name: "WS_CHILDWINDOW"));
EXTSTYLE_NAMES: array [0..25] of TStyleName =(
(Style: WS_EX_DLGMODALFRAME; Name: "WS_EX_DLGMODALFRAME"),
(Style: WS_EX_NOPARENTNOTIFY; Name: "WS_EX_NOPARENTNOTIFY"),
(Style: WS_EX_TOPMOST; Name: "WS_EX_TOPMOST"),
(Style: WS_EX_ACCEPTFILES; Name: "WS_EX_ACCEPTFILES"),
(Style: WS_EX_TRANSPARENT; Name: "WS_EX_TRANSPARENT"),
(Style: WS_EX_MDICHILD; Name: "WS_EX_MDICHILD"),
(Style: WS_EX_TOOLWINDOW; Name: "WS_EX_TOOLWINDOW"),
(Style: WS_EX_WINDOWEDGE; Name: "WS_EX_WINDOWEDGE"),
(Style: WS_EX_CLIENTEDGE; Name: "WS_EX_CLIENTEDGE"),
(Style: WS_EX_CONTEXTHELP; Name: "WS_EX_CONTEXTHELP"),
(Style: WS_EX_RIGHT; Name: "WS_EX_RIGHT"),
(Style: WS_EX_LEFT; Name: "WS_EX_LEFT"),
(Style: WS_EX_RTLREADING; Name: "WS_EX_RTLREADING"),
(Style: WS_EX_LTRREADING; Name: "WS_EX_LTRREADING"),
(Style: WS_EX_LEFTSCROLLBAR; Name: "WS_EX_LEFTSCROLLBAR"),
(Style: WS_EX_RIGHTSCROLLBAR; Name: "WS_EX_RIGHTSCROLLBAR"),
(Style: WS_EX_CONTROLPARENT; Name: "WS_EX_CONTROLPARENT"),
(Style: WS_EX_STATICEDGE; Name: "WS_EX_STATICEDGE"),
(Style: WS_EX_APPWINDOW; Name: "WS_EX_APPWINDOW"),
(Style: WS_EX_OVERLAPPEDWINDOW; Name: "WS_EX_OVERLAPPEDWINDOW"),
(Style: WS_EX_PALETTEWINDOW; Name: "WS_EX_PALETTEWINDOW"),
(Style: WS_EX_LAYERED; Name: "WS_EX_LAYERED"),
(Style: WS_EX_NOINHERITLAYOUT; Name: "WS_EX_NOINHERITLAYOUT"),
(Style: WS_EX_LAYOUTRTL; Name: "WS_EX_LAYOUTRTL"),
(Style: WS_EX_COMPOSITED; Name: "WS_EX_COMPOSITED"),
(Style: WS_EX_NOACTIVATE; Name: "WS_EX_NOACTIVATE"));
.................
function GetWindowStyle(const Wnd: HWND; Lst: TStrings; ExtStl: Boolean=False): Integer;
const Style: array [Boolean] of Integer = (GWL_STYLE, GWL_EXSTYLE);
var N: Integer;
begin
Result:=GetWindowLong(Wnd, Style[ExtStl]);
if not Assigned(LSt) or (Result=0) then Exit;
if ExtStl then begin
Lst.Add("(ExtStyle for "+IntToStr(Wnd)+")");
for N:=Low(EXTSTYLE_NAMES) to High(EXTSTYLE_NAMES) do
if Result and EXTSTYLE_NAMES[N].Style = EXTSTYLE_NAMES[N].Style then Lst.Add(EXTSTYLE_NAMES[N].Name);
end else begin
Lst.Add("(Style for "+IntToStr(Wnd)+")");
for N:=Low(STYLE_NAMES) to High(STYLE_NAMES) do
if Result and STYLE_NAMES[N].Style = STYLE_NAMES[N].Style then Lst.Add(STYLE_NAMES[N].Name);
end;
end;
Может кому пригодится, просто "нудно" эти константы "наполнять" :)
Страницы: 1 вся ветка
Форум: "Начинающим";
Текущий архив: 2008.01.13;
Скачать: [xml.tar.bz2];
Память: 0.49 MB
Время: 0.006 c