词条 | GetDlgItem |
释义 | 函数功能:该函数检索指定的对话框中的控件句柄。 函数原型:HWND GetDlgltem(HWND hDlg,int nlDDlgltem); 参数: hDlg:标识含有控件的对话框。 nlDDlgltem:指定将被检索的控件标识符。 返回值:如果函数调用成功则返回值为给定控件的窗口句柄。如果函数调用失败,则返回值为NULL,表示为一个无效的对话框句柄或一个不存在的控件。若想获得更多错误信息,请调用GetLastError函数。 备注:可以通过使用任何父子窗口对来使用GetDlgltem函数,而不仅只是对话框。只要hDlg参数指定一个父窗口,且子窗口有一个独立的标识符(象CreateWindow中hMenu参数指定的或创建子窗口的CreateWindowEx指定的那样),GetDlgltem就会返回一个有效的句柄到子窗口。 Windows CE:GetDlgltem函数只为对话框中的直接于控制工作,它不通过嵌套的对话框来搜寻。 速查:Windows NT:3.1及以上版本;Windows:95及以上版本;Windows CE:1.0及以上版本;头文件:winuser.h;库文件:user32.lib。 用法: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 The GetDlgItemfunction retrieves a handle to a control in the specified dialog box. Syntax HWND GetDlgItem( HWND hDlg, int nIDDlgItem); Parameters hDlg[in] Handle to the dialog box that contains the control. nIDDlgItem[in] Specifies the identifier of the control to be retrieved. Return Value If the function succeeds, the return value is the window handle of the specified control. If the function fails, the return value is NULL, indicating an invalid dialog box handle or a nonexistent control. To get extended error information, call GetLastError. Remarks You can use the GetDlgItemfunction with any parent-child window pair, not just with dialog boxes. As long as the hDlgparameter specifies a parent window and the child window has a unique identifier (as specified by the hMenuparameter in the CreateWindowor CreateWindowExfunction that created the child window), GetDlgItemreturns a valid handle to the child window. |
随便看 |
百科全书收录4421916条中文百科知识,基本涵盖了大多数领域的百科知识,是一部内容开放、自由的电子版百科全书。