有对话框里的控件的句柄,怎么得到
没有的时候呢?

解决方案 »

  1.   

    CWnd * pWnd = GetDlgItem(IDC_BUTTON1) ;
    HWND hwnd = pWnd->GetSafeHwnd();
      

  2.   

    技术上可行
    符合你的要求吗?
    如果不明白,你可以
    (1),给我发短消息(请附帖子的地址).
    (2),根据http://www.vcshare.net上的联系方式与我联系,推荐QQ.
    (3),如果问题简单,请在http://www.vcshare.net/bbs上发帖.
        如果问题比较复杂,请把代码压成*.rar当附件发在我的论坛上发帖.
        同时在www.csdn.net上发帖,并给出在我的论坛的链接.
    ---------------
    压代码前,请先删除debug,release文件夹,及*.opt,*.ncb,*.plg,*.aps.
      

  3.   

    SDK:
    GetParent(控件句柄);
    MFC:
    (GetDlgItem(控件ID)->GetParent())->GetSafeHwnd();
      

  4.   

    HWND GetDlgItem(HWND hDlg,int nIDDlgItem);hDlg
    [in] Handle to the dialog box that contains the control. 
    nIDDlgItem
    [in] Specifies the identifier of the control to be retrieved. You can use the GetDlgItem function with any parent-child window pair, not just with dialog boxes. As long as the hDlg parameter specifies a parent window and the child window has a unique identifier (as specified by the hMenu parameter in the CreateWindow or CreateWindowEx function that created the child window), GetDlgItem returns a valid handle to the child window.