lgltem:指定将被检索的控件标识符。
返回值:如果函数调用成功则返回值为给定控件的窗口句柄。如果函数调用失败,则返回值为NULL,表示为一个无效的对话框句柄或一个不存在的控件。若想获得更多错误信息,请调用GetLastError函数。
备注:可以通过使用任何父子窗口对来使用GetDlgltem函数,而不仅只是对话框。只要hDlg参数指定一个父窗口,且子窗口有一个独立的标识符(象CreateWindow中hMenu参数指定的或创建子窗口的CreateWindowEx指定的那样),GetDlgltem就会返回一个有效的句柄到子窗口。getdlgitem
Windows CE:GetDlgltem函数只为对话框中的直接于控制工作,它不通过嵌套的对话框来搜寻。
速查:Windows NT:3.1及以上版本;Windows:95及以上版本;WindowsCE:1.0及以上版本;头文件:winuser.h;库文件:user32.lib。getdlgitem
多数以GetDlgitem(控件标识符)来使用
2用法:C#
IntPtr hwnd;
IntPtr hwnd1;
IntPtr hwnd2;

IntPtr hwnd3;
IntPtr hwnd4;
hwnd = FindWindow(null, 'QQ2011');
hwnd1 = GetDlgItem(hwndQQ, 0);
hwnd2 = GetDlgItem(hwnd1, 0);
hwnd3 = GetDlgItem(hwnd2, 894);
SendMessage(hwnd3, 194, 0, this.txtInput.Text);
hwnd4 = GetDlgItem(hwnd1, 1);
SendMessage(hwnd4, 245, 0, Convert.ToString(0));/*
GetDlgItem Function

TheGetDlgItemfunction retrieves a handle to a control in thespecified dialog box.
Syntax
HWND GetDlgItem(
HWNDhDlg, intnIDDlgItem);
Parameters
hDlg[in] Handle to the dialog box that contains thecontrol.nIDDlgItem[in] Specifies the identifier of the control tobe retrieved.
Return Value
If the function succeeds, the return value is the window handle ofthe specified control.
If the function fails, the return value is NULL, indicating aninvalid dialog box handle or a nonexistent control. To get extendederror information, call GetLastError.
Remarks
You can use theGetDlgItemfunction with any parent-child windowpair, not just with dialog boxes. As long as thehDlgparameterspecifies a parent window and the child window has a uniqueidentifier (as specified by thehMenuparameter in the CreateWindoworCreateWindowExfunction that created the childwindow),GetDlgItemreturns a valid handle to the child window.
本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/jisuanjixue/article-33580-1.html
渔民们走
他航他的
机智的少年