CWnd::GetDlgItem使用注意

MSDN:

Return Value

A pointer to the given control or child window. If no control with the integer ID given by the nID parameter exists, the value is NULL.

The returned pointer may be temporary and should not be stored for later use.

返回的是一个临时的CWnd指针,

因此可能下面这样的做法是可能达不到语气的效果哦:

if(pWnd == GetDlgItem(IDC_EDIT_UPDATE_ITEM))

换成这样就OK了:

if(pWnd->GetDlgCtrlID() == IDC_EDIT_UPDATE_ITEM)

posted on 2011-03-15 10:31  AlexLeo  阅读(295)  评论(0编辑  收藏  举报

导航