Home > Back-end >  Turn to handle problems
Turn to handle problems

Time:10-24

Why can't get the handle of the text information
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

# include & lt; The VCL. H>
# pragma hdrstop

# include "Unit1. H"
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
# pragma package (smart_init)
# pragma resource "*. DFM
"
BOOL CALLBACK EnumFunc (HWND HWND, LPARAM lp);
BOOL CALLBACK EnumChildWinProc (HWND HWND, LPARAM LPARAM);
TForm1 * Form1;
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
__fastcall TForm1: : TForm1 (TComponent * Owner)
: TForm (the Owner)
{



}
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
BOOL CALLBACK EnumFunc (HWND HWND, LPARAM lp)
{
return true;
}
BOOL CALLBACK EnumChildWinProc (HWND HWND, LPARAM LPARAM)
{
String STR.
Char wndclassname [255].
Char wndcaption [255].
STR="WindowsForms10. EDIT. App. 0.2 c908d5";
GetWindowText (HWND wndcaption, 255);
SendMessage (HWND, WM_GETTEXT, 255, an Integer (& amp; Wndcaption));
GetClassName (HWND wndclassname, 255);

Form1 - & gt; Memo1 - & gt; Lines - & gt; Add (StrPas (wndclassname));
Form1 - & gt; Memo1 - & gt; Lines - & gt; Add (StrPas (wndcaption));
Form1 - & gt; Memo1 - & gt; Lines - & gt; Add (IntToStr (HWND) (int));
Form1 - & gt; Memo1 - & gt; Lines - & gt; Add (" -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - ");
Form1 - & gt; Memo2 - & gt; Lines - & gt; Add (IntToStr (HWND) (int));

return true;

}
////////////////////////////////////////////////////////////////////////////////
Void __fastcall TForm1: : Button1Click (TObject * Sender)
{
Form1 - & gt; Memo2 - & gt; Lines - & gt; The Clear ();
The HWND HWND;
HWND=FindWindow (NULL, "Form1");

if(! HWND)
{
Label6 - & gt; Failed to get information Caption="";
return;
}
The else
{
Label6 - & gt; Caption="information success";

Memo1 - & gt; Lines - & gt; The Clear ();
EnumChildWindows (HWND, (int (__stdcall *) ()) EnumChildWinProc, 0).
String xm=Form1 - & gt; Memo2 - & gt; Lines - & gt; Strings [28].
Char XMTX [255].
HWND=(HWND) StrToInt (xm);
GetWindowText (HWND XMTX, 255);
Int wndcaption;
SendMessage (HWND, WM_GETTEXT, 255, an Integer (& amp; Wndcaption));
String MSTR=XMTX;
Memo3 - & gt; Lines - & gt; Add (MSTR);

}


}
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

CodePudding user response:

I traverse all window handle first, then the handle, the name of the class, the TEXT information is added to the MEMO1, add a handle to memo2, obtaining memo2 handle, and then according to the handle for TEXT information, why don't get it? Thank you brother,

CodePudding user response:

Your help

CodePudding user response:

First of all, make sure you get to handle correctly, secondly, the content of the Memo components, with GetWindowText can access to it,

CodePudding user response:

I get to handle is correct, fill out into the Memo is correct, I had a corresponding, also with the getwindowtext access available meters to admire, code has been sent, consult everybody warrior I where do wrong,

CodePudding user response:

0.2 c908d5 WindowsForms10. EDIT. App. This is what the control

CodePudding user response:

Seems the.net generated by the window,

CodePudding user response:

I also encountered the same problem, solving!!!!!
  • Related