Delphi Builder

nave

Турист
Регистрация
8 Июн 2005
Сообщения
10
Реакции
0
Credits
14
Господа опытные программисты, помогите советом, пожалуйста

Есть проблема, вернее, задача + есть алгоритм её решения. и всё бы хорошо, но для реализации кое-чего не хватает.
так вот:
думаю, что есть в приложении массив, который содержит все В НАСТОЯЩИЙ МОМЕНТ (ТО ЕСТЬ ВО ВРЕМЯ РАБОТЫ ПРОГРАММЫ, А НЕ НАПИСАНИЯ КОДА !!)открытые формы. ну и думаю есть счетчик этих открытых форм. как назывется первое и второе?? как бы мне к ним обратиться.....
 

ploki

Местный
Регистрация
16 Май 2005
Сообщения
237
Реакции
180
Credits
0
RTFM (F1):

Class TScreen

Property TScreen.Forms (public property Forms: TForm read GetForm)

Lists all the forms currently displayed in the application.

Description:
Use Forms to access a form by index. The value of Index is a number between zero (the first form) and FormCount - 1. Forms can be used with FormCount when an application needs to iterate over all its forms, including all dialogs.
Forms only lists the TForm descendants in the application. This does not include, for example, property pages. To get a list that includes TCustomForm descendants that do not descend from TForm, use CustomForms instead.

Warning: The order in which Forms lists its forms is affected by the Z order of the forms. Do not change the Z order of forms when using Forms to iterate over the forms in an application.

Property TScreen.FormCount (public property FormCount: Integer read GetFormCount)

Indicates the number of forms displayed on the screen.

Description
Read FormCount to learn the number of forms currently displayed on the screen. These forms can be accessed by the Forms property. FormCount can be used with Forms to iterate over all the forms in an application.
 

xss20

Турист
Регистрация
8 Мар 2009
Сообщения
3
Реакции
1
Credits
6
Try EnumWindows:

function EnumProcess(hHwnd: HWND; lParam : integer): boolean; stdcall;
var
pPid : DWORD;
title, ClassName : string;
begin
//if the returned value in null the
//callback has failed, so set to false and exit.
if (hHwnd=NULL) then
begin
result := false;
end
else
begin
//additional functions to get more
//information about a process.
//get the Process Identification number.
GetWindowThreadProcessId(hHwnd,pPid);
//set a memory area to receive
//the process class name
SetLength(ClassName, 255);
//get the class name and reset the
//memory area to the size of the name
SetLength(ClassName,
GetClassName(hHwnd,
PChar(className),
Length(className)));
SetLength(title, 255);
//get the process title; usually displayed
//on the top bar in visible process
SetLength(title, GetWindowText(hHwnd, PChar(title), Length(title)));
//Display the process information
//by adding it to a list box
Form1.ProcessListBox.Items.Add
('Class Name = ' + className +
'; Title = ' + title +
'; HWND = ' + IntToStr(hHwnd) +
'; Pid = ' + IntToStr(pPid));
Result := true;
end;
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
//Clear any previous calls
if ProcessListBox.Count > 0 then
ProcessListBox.Clear;
//define the tag flag
lp := 0; //globally declared integer
//call the windows function with the address
//of handling function and show an error message if it fails
if EnumWindows(@EnumProcess,lp) = false then
ShowMessage('Error: Could not obtain process window hook from system.');
end;
[/B]