Top.Mail.Ru
Мастера DELPHI, Delphi programming community Титульная страница Поиск, карта сайта Написать письмо 
| Новости | Поиск | FAQ | Статьи | Книги | Новости VCL |
| Форумы ЧАТ | Орешник | KOL и MCK |
Форумы -» Основная («Начинающим»)/ Базы / WinAPI / Компоненты / Сети / Media / Игры / Corba и COM / KOL / FreePascal / .Net / Прочее / RSDN.ORG

« предыдущая ветвь | форум | следующая ветвь »

Можно ли по ID просесса узнать хендл окна этого просесса ? [D5, WinXP]


Страницы:   1 2 3

-=SS=- ©   (2004-12-15 18:17:00) 

Собственно ИМХО может кто знает какие - то апишные функции
зараннее благодарен


GuAV   (2004-12-18 19:29:00) [1]

Понял. Т.е. EnumWindows перечислит и Owned windows. Спасибо.


Leonid Troyanovsky   (2004-12-18 19:24:00) [2]


> Но тогда, поскольку The EnumWindows function enumerates
> all top-level windows, и это
>
> > If a
> > window has neither style, the taskbar decides to
> >create a button if
> > the window is unowned and does not create a button if
>
> >the window is
> > owned.
>
>
> не надо проверять ;-)


Owner-owned vs parent-child.
Скажем, окно Application обычно owner для форм (top-level).

--
С уважением, LVT.


GuAV   (2004-12-18 19:14:00) [3]

Piter ©   (18.12.04 19:09) [41]
Почему?


Потому что ты поставишь в параметр hWndParent 0 (или HWND_DESKYOP = 0), т.к. других окон у тебя нет.

VCL подставляет Application.Handle


Leonid Troyanovsky   (2004-12-18 19:13:00) [4]


> Piter ©   (18.12.04 19:11) [43]
> [41]


[35]

--
С уважением, LVT.


GuAV   (2004-12-18 19:11:00) [5]

Понял.
Но тогда, поскольку The EnumWindows function enumerates all top-level windows, и это

> If a
> window has neither style, the taskbar decides to
>create a button if
> the window is unowned and does not create a button if
>the window is
> owned.


не надо проверять ;-)


Piter   (2004-12-18 19:11:00) [6]

Leonid Troyanovsky ©   (18.12.04 19:09) [42]
Тебе все сообщения видны?


[41]


Leonid Troyanovsky   (2004-12-18 19:09:00) [7]


> Piter ©   (18.12.04 18:51) [37]

> > > имхо, первое окно, созданное приложением и
> > > отображается на Панели Задач


Нет, конечно.
Тебе все сообщения видны?

--
С уважением, LVT.


Piter   (2004-12-18 19:09:00) [8]

Ну вот если написать простейшую программу на WinApi, которая будет создавать окно CreateWindow и не применять никаких особенных стилей - то окно отобразится на Панели Задач. Почему?


Leonid Troyanovsky   (2004-12-18 19:05:00) [9]


> GuAV ©   (18.12.04 18:43) [36]

> Неточность в том, что если окно WS_CHILD, то никакие  WS_EX_APPWINDOW
> не помогут - можете проверить.


А причем тут WS_CHILD?
Речь шла про EnumWindows & top-level windows.


> PS: интересный спор ни о чём.


Это называется обсуждением, IMHO.

--
С уважением, LVT.


GuAV   (2004-12-18 19:02:00) [10]

GuAV ©   (18.12.04 17:45) [33]
То что имеет значение не порядок, а стили и владалец.


GuAV   (2004-12-18 19:01:00) [11]

2 Piter ©   (18.12.04 18:51) [37]
GuAV ©   (18.12.04 17:45) [33]


Piter   (2004-12-18 18:51:00) [12]

Leonid Troyanovsky ©   (18.12.04 14:04) [32]
В отсутствии определения "главное окно" любое высказывание
может быть представлено как истинное


не в этом суть:


> > имхо, первое окно, созданное приложениеми есть
>"главное",
> > то есть отображается на Панели Задач


GuAV   (2004-12-18 18:43:00) [13]

Leonid Troyanovsky ©   (18.12.04 18:31) [35]

Неточность в том, что если окно WS_CHILD, то никакие  WS_EX_APPWINDOW не помогут - можете проверить.

PS: интересный спор ни о чём.


Leonid Troyanovsky   (2004-12-18 18:31:00) [14]


> GuAV ©   (18.12.04 17:45) [33]
..
> Немного поэксперементировав пришел к выводу, что проверка
> должна выглядеть так:



От:Tomas Restrepo (winder@bigfoot.com)
Тема:Re: How to EnumWindows...
Группы новостей:microsoft.public.win32.programmer.kernel
Дата:1999/04/06

Maurizio,

You have to do some test on each of the windows returned by EnumWindows() to
decide wheter to show it or not. The test were described by Jeffrey Richter in
the Nov '97 issue of MSJ. Quoting:

"The rules the taskbar uses to decide whether a button should be shown
for a window are really quite simple, but are not well documented.
When you create a window, the taskbar examines the window's extended
style to see if either the WS_EX_APPWINDOW (defined as 0x00040000) or
WS_EX_TOOLWINDOW (defined as 0x00000080) style is turned on. If
WS_EX_APPWINDOW is turned on, the taskbar shows a button for the
window, and if WS_EX_ TOOLWINDOW is turned on, the taskbar does not
show a button for the window. You should never create a window that
has both of these extended styles.

You can create a window that doesn't have either of these styles. If a
window has neither style, the taskbar decides to create a button if
the window is unowned and does not create a button if the window is
owned.

One final note: before making any of the above tests, the taskbar
first checks to see if a window has the standard WS_VISIBLE window
style turned on. If this style bit is off, the window is hidden; the
taskbar never shows a button for a hidden window. Only if the
WS_VISIBLE style bit is on will the taskbar check the WS_EX_APPWINDOW,
WS_ EX_TOOLWINDOW, and window ownership information."

Which, BTW,  David Lowndes has posted in this group several times in the past

--
Tomas Restrepo

--
С уважением, LVT.


GuAV   (2004-12-18 18:06:00) [15]

GuAV ©   (18.12.04 17:45) [33]
, что проверка должна выглядеть так:

Хотя нет, правильно в [29]


GuAV   (2004-12-18 17:45:00) [16]

Piter ©   (18.12.04 2:21) [30]
а что ты скажешь на:

Piter ©   (18.12.04 0:44) [25]
имхо, первое окно, созданное приложением и есть "главное", то есть отображается на Панели Задач


То что имеет значение не порядок, а стили и владалец.
В VCL приложении обычно ни одна форма не видна на TaskBar, для этого исспользуется окно Application.Handle.

type
 TForm1 = class(TForm)
 private
   { Private declarations }
 protected
   procedure CreateParams(var Params: TCreateParams); override;
 public
   { Public declarations }
 end;

var
 Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.CreateParams(var Params: TCreateParams);
begin
 inherited;
 // любая из нижеследуючих строк приводит к появлению формы на taskbar
 Params.WndParent := HWND_DESKTOP;
 Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
end;


Немного поэксперементировав пришел к выводу, что проверка должна выглядеть так:
if (WindowOwner = 0) and ((WinStyle and WS_VISIBLE) <> 0) and ((WinStyle and WS_CHILD) = 0) and
 (((ExStyle and WS_EX_TOOLWINDOW) = 0) or ((ExStyle and WS_EX_APPWINDOW) <> 0)) then


Leonid Troyanovsky   (2004-12-18 14:04:00) [17]


> Piter ©   (18.12.04 02:21) [30]
> GuAV ©   (18.12.04 1:28) [28]
>
> а что ты скажешь на:
>
> Piter ©   (18.12.04 0:44) [25]
> имхо, первое окно, созданное приложением и есть "главное",
> то есть отображается на Панели Задач


В отсутствии определения "главное окно" любое высказывание
может быть представлено как истинное.

--
С уважением, LVT.

PS Собс-но, проще руководстваться целью: "что нужно от
этого окна".


Leonid Troyanovsky   (2004-12-18 13:56:00) [18]


> Игорь Шевченко ©   (18.12.04 01:56) [29]

> Проверка, очевидно должна выглядеть так (надо проверить):
>
> if (WindowOwner = 0) and ((WinStyle and WS_VISIBLE) <> 0)
> and
>   (((ExStyle and WS_EX_TOOLWINDOW) = 0) or ((ExStyle and
> WS_EX_APPWINDOW) <> 0)) then



Проверка должна выглядеть так (можешь проверить):


function IsTaskbarBtnExist(h: HWND): Boolean;
var
 exstyle: Longint;
begin
 Result:= IsWindowVisible(h);
 if Result then
   begin
     exstyle := GetWindowLong(h, GWL_EXSTYLE);
     Result := exstyle and WS_EX_APPWINDOW <> 0;
     if not Result and
        (exstyle and WS_EX_TOOLWINDOW = 0) then
       Result := GetWindowLong(h, GWL_HWNDPARENT) = 0;
    end;
end;


--
С уважением, LVT.


Piter   (2004-12-18 02:21:00) [19]

GuAV ©   (18.12.04 1:28) [28]

а что ты скажешь на:

Piter ©   (18.12.04 0:44) [25]
имхо, первое окно, созданное приложением и есть "главное", то есть отображается на Панели Задач


Игорь Шевченко   (2004-12-18 01:56:00) [20]

GuAV ©   (18.12.04 01:28) [28]

Спасибо. К сожалению, я практически не обновляю сайт.

Проверка, очевидно должна выглядеть так (надо проверить):

if (WindowOwner = 0) and ((WinStyle and WS_VISIBLE) <> 0) and
  (((ExStyle and WS_EX_TOOLWINDOW) = 0) or ((ExStyle and WS_EX_APPWINDOW) <> 0)) then


С уважением,


Страницы:   1 2 3

Наверх

Титульная страница Поиск, карта сайта Написать письмо