O uso é o seguinte:
NparentHandle: HWND;
NCHILDHANDLE: HWND;
nParentHandle: = findWindow (nulo, '' notepad '');
Se nparentHandle <> 0 então
NCHILDHANDLE: = FindChildWindow (NPARENTHANDLE, '' SOMECHILDITSCLASSNAME '');
------ Código da função ------
var
HWNDFINDCHILDWindow: HWND;
função enumwindowsforfindchildwindowproc (whandle: hwnd; lparam: lparam): bool;
const
Max_window_name_len = 80;
var
StargetClassName: String;
NHANDLE: HWND;
scurrclassName: string;
Bresult: booleano;
Começar
if (hwndfindchildwindow <> 0) então
saída;
stargetClassName: = pchar (lparam);
scurrclassName: = getWindowclass (whandle);
BRESULT: = CompareText (ScurrclassName, StargetClassName) = 0;
If (Bresult) então
HWNDFINDCHILDWindow: = whandle
outro
FindChildWindow (Whandle, PChar (LPARAM));
fim;
função findChildWindow (hwndParent: hwnd; className: pchar): hwnd;
Começar
tentar
Enumchildwindows (hwndparent, @enumwindowsforfindchildwindowproc, longnt (pchar (className)));
Resultados: = hWndfindChildWindow;
exceto
na exceção do
Resultados: = 0;
fim;
fim;
// retorna ao formulário atual com foco
função getfocusedWindowFromParent (parentwnd: hwnd): hwnd;
var
Otherthread,
Buffer: DWORD;
IdCurrThread: DWORD;
Começar
OtherThread: = getWindowThreadProcessId (parentwnd, @buffer);
idcurrthread: = getCurrentThreadId;
Se apthThreadInput (IdCurrThread, OtherThread, True), então comece
Resultado: = getFocus;
ATTHTHTHREADINPUT (IDCURRTHREAD, OUTHERTHREAD, FALSE);
fim
outro
Resultado: = getFocus;
fim;
// Obtenha a subformada que atualmente se concentra, mesmo que seja a forma de outros aplicativos
função getFocusEdChildWindow: HWND;
Começar
Resultado: = getFocusEdWindowFromParent (GetFeRoundWindow);
fim;
// Obtenha o texto do formulário
função eigetwintext (nhandle: integer): string;
var
PCTEXT: Array [0..32768] de Char;
Começar
SendMessage (nhandle, wm_getText, 32768, longInt (@pctext));
Resultados: = pcText;
fim;
// Defina o texto do formulário
Procedimento eisetwintext (nhandle: número inteiro; const snewText: string);
Começar
SendMessage (nhandle, wm_settext, comprimento (renewtext), longint (pchar (acabamento (snewtext))));
fim;
// retorna o nome da classe do formulário
função eigetwindowclass (const nhandle: hwnd): string;
var
SzclassName: Array [0..255] de Char;
Começar
GetClassName (nhandle, szclassName, 255);
Resultado: = szclassName;
fim;