分享

getdlgitem

 牛人的尾巴 2017-01-12
所属类别 :
函数

函数功能

返回窗口中指定参数ID的子元素的句柄,可以通过返回的句柄对窗口内的子元素进行操作。

基本信息

  • 外文名称

    GetDlgItem

  • 说    明

    根据继承关系

  • 返回值

    标识所标记的控制窗口句柄

  • 参数 nID

    接收消息的控件的标识

折叠 编辑本段 函数功能

返回窗口中指定参数ID的子元素的句柄,可以通过返回的句柄对窗口内的子元素进行操作。

折叠 编辑本段 函数说明

根据继承关系,有如下几类:

1).CWindow::GetDlgItem

HWND GetDlgItem( int nID)const;

说明——

参数 nID:接收消息的控件的标识;

返回值:标识所标记的控制窗口句柄

2).CWnd::GetDlgItem

CWnd* GetDlgItem ( int nID ) const;

void CWnd::GetDlgItem( int nID, HWND* phWnd ) const;

说明——

参数 nID:接收消息的控件的标识;

参数phWnd:子类窗口的指针;

返回值:标识所标记的控件(或子类窗口)的指针;

Example

// Uses GetDlgItem to return a pointer to a user interface control.

CEdit* pBoxOne;

pBoxOne = (CEdit*) GetDlgItem(IDC_EDIT1);

GotoDlgCtrl(pBoxOne);

3).Windows SDK

HWND GetDlgItem(

HWND hDlg, // handle to dialog box

int nIDDlgItem // control identifier

折叠 编辑本段 参数

折叠 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。

多数以GetDlgitem(控件标识符);来使用

折叠 用法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.

词条标签: 窗体

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多