S
sunli_py
Unregistered / Unconfirmed
GUEST, unregistred user!
请问我用DELPHI做调用其它程序窗口时为什么Tmainmenu的菜单按钮句柄和类名获取不到啊,而界面上的其它控件的句柄和类名都能获取到?以下是我用的两个函数function EnumWindowsProc(AhWnd: LongInt; AForm: Tfrm_main): boolean; stdcall;function EnumChildWndProc(AhWnd: LongInt; AlParam: lParam): boolean; stdcall;function EnumWindowsProc(AhWnd: LongInt; AForm: Tfrm_main): boolean;var lpszClassName, lpszWindowText: array[0..254] of char;begin GetWindowText(AhWnd, lpszWindowText, 254); GetClassName(AhWnd, lpszClassName, 254); Aform.memo1.lines.add(StrPas(lpszWindowText)); Aform.memo1.lines.add(StrPas(lpszClassName)); Aform.memo1.lines.add('--------------------'); Result := True;end;function EnumChildWndProc(AhWnd: LongInt; AlParam: lParam): boolean; stdcall;var WndClassName: array[0..254] of Char; WndCaption: array[0..254] of Char;begin GetClassName(AhWnd, wndClassName, 254); GetWindowText(aHwnd, WndCaption, 254); with frm_main.memo1 do begin lines.add('句柄:' + inttostr(AhWnd)); lines.add('类名:' + string(wndClassName)); lines.add('标题:' + string(wndCaption)); lines.add('-------'); arr_classname[i,0]:= inttostr(AhWnd); arr_classname[i,1]:= string(wndClassName); arr_classname[i,3]:= string(wndCaption); i:=i+1; end; result := true;end;谢谢