怎么得到一个hwnd的name的值。

Bluekibo 2003-05-17 11:43:03
如:
var
Hnd : THandle;
begin
Hnd := FindWindow(Nil,'Form1');

我怎么根据这个hnd 得到 Form1 的 name 属性的值 是什么?
如果能知道其他属性,当然是最好的了。谢。
...全文
59 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
firetoucher 2003-05-19
  • 打赏
  • 举报
回复
用GetTextBuf
蓝色光芒 2003-05-19
  • 打赏
  • 举报
回复
UP
Bluekibo 2003-05-17
  • 打赏
  • 举报
回复
To: u2m(UpToMe)
谢谢,
你那个是得到属性的名称吧,我主要想得到属性对应的值。
有没有办法啊?
u2m 2003-05-17
  • 打赏
  • 举报
回复
GetWindowText只是得到他的title标题内容
xiaozhanger 2003-05-17
  • 打赏
  • 举报
回复
有handle了,用 GetWindowText可以吗,
njbudong 2003-05-17
  • 打赏
  • 举报
回复
呵呵,楼上的这个办法应该还可以.
不过没有试过.
u2m 2003-05-17
  • 打赏
  • 举报
回复
楼上得有用吗?我倒是有楼上函数得例子,但没研究过,看来要研究研究.

our callback function prototype}
function EnumWinProps(hWnd: HWND; pString: PChar; Data: THandle): BOOL; stdcall;

var
Form1: TForm1;

implementation

{these steps will be executed for each property
entry in the window's property list}
function EnumWinProps(hWnd: HWND; pString: PChar; Data: THandle): BOOL;
begin
{add the string and associated value to the list box}
Form1.ListBox1.Items.Add(Format('%s=%d',[pString,Data]));

{continue enumeration}
Result:=TRUE;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
{add a new property to the window's property list}
SetProp(Form1.Handle,PChar(Edit1.Text),StrToInt(Edit2.Text));

{clear the edit boxes}
Edit1.Text:='';
Edit2.Text:='';

{clear the list box}
Form1.ListBox1.Items.Clear;

{list all of the properties associated with the window}

EnumProps(Form1.Handle, @EnumWinProps);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
{clear the list box}
Form1.ListBox1.Items.Clear;

{list all of the properties associated with the window}
EnumProps(Form1.Handle, @EnumWinProps);
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
{remove the selected property from the property list}

RemoveProp(Form1.Handle,PChar(Copy(ListBox1.Items[ListBox1.ItemIndex],
0,Pos('=',ListBox1.Items[ListBox1.ItemIndex])-1)));

{clear the list box}
Form1.ListBox1.Items.Clear;

{list all of the properties associated with the window}
EnumProps(Form1.Handle, @EnumWinProps);
end;

procedure TForm1.Button4Click(Sender: TObject);
var
Data: THandle; // this stores the property entry data

begin
{get property entry data associated with the given string}
Data:=GetProp(Form1.Handle,PChar(Edit1.Text));

{if there was a property value returned...}
if (Data<>0) then
{...display it...}
Edit2.Text:=IntToStr(Data)
else
{...otherwise display an error message}
Edit2.Text:='No property found.';
end;
蓝色光芒 2003-05-17
  • 打赏
  • 举报
回复
EnumProps,PropEnumProc,具体的用法没有搞过。
Attribute VB_Name = "mdl_Hot_Key"
'\__________________________________________________________________________________
' SetHotkey 1, "Ctrl,112", "Add" '按 Ctrl F1 激活指定程序
' SetHotkey 2, 113, "Add" '按 F2 激活指定程序
' SetHotkey 3, "Ctrl Alt,113", "Add" '按 Ctrl Alt F2 激活指定程序
'注释:注:关于激活热键后的操作,由自定义函数 SetHotkey 的 KeyId 传送的来判断
'注销 3 个热键:
' SetHotkey 1, "", "Del" '退出程序是一定要用上的,不然会导至程序死掉
' SetHotkey 2, "", "Del"
' SetHotkey 3, "", "Del"
'请大家新建一个模块(.bas)文件,自定义 SetHotkey函数及其他,这样在以后的任何程序中只要调用此模块就可以了。
'注释: 本模块是有关热键操作的
'\____________________________________________________________________________________
Option Explicit
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function RegisterHotKey Lib "user32" (ByVal hwnd As Long, ByVal id As Long, ByVal fskey_Modifiers As Long, ByVal vk As Long) As Long
Private Declare Function UnregisterHotKey Lib "user32" (ByVal hwnd As Long, ByVal id As Long) As Long

Public Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function EnableWindow Lib "user32" (ByVal hwnd As Long, ByVal fEnable As Long) As Long
'Public Declare Function GetWindowRgn Lib "user32" (ByVal hwnd As Long, ByVal hRgn As Long) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long '|取得控件的在屏幕中的位置
Private Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long '|枚举子控件

Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Private Declare Function GetForegroundWindow Lib "user32" () As Long '|// 获得当前活动窗体句柄

Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Public Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
Public Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Public Declare Function GetDesktopWindow Lib "user32" () As Long
Public Declare Function IsWindow Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long

Public Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Public Declare Sub Mouse_Event Lib "user32" Alias "mouse_event" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
' // 鼠标动作标识 // 鼠标水平方向位置 // 鼠标垂直方向位置 // 鼠标轮子转动的数量 // 一个关联鼠标动作辅加信息

Const WM_HOTKEY =

5,930

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧