Delphi Builder

nave

Member
Joined
Jun 8, 2005
Messages
10
Reaction score
0
Location
москва
Господа опытные программисты, помогите советом, пожалуйста

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

ploki

Member
Joined
May 16, 2005
Messages
237
Reaction score
180
Location
Москва
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

New member
Joined
Mar 7, 2009
Messages
3
Reaction score
1
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]
 
Top