2

在这个关于如何处理 SysLink 控件的 WM_NOTIFY 消息的Microsoft 示例g_hLink中,他们有以下代码,即 SysLink 控件的句柄:

// g_hLink is the handle of the SysLink control.
case WM_NOTIFY:

    switch (((LPNMHDR)lParam)->code)
    {
    
    case NM_CLICK:          // Fall through to the next case.
    
    case NM_RETURN:
        {
            PNMLINK pNMLink = (PNMLINK)lParam;
            LITEM   item    = pNMLink->item;
            
            if ((((LPNMHDR)lParam)->hwndFrom == g_hLink) && (item.iLink == 0))
              {
                ShellExecute(NULL, L"open", item.szUrl, NULL, NULL, SW_SHOW);
              }
            
            else if (wcscmp(item.szID, L"idInfo") == 0)
              {
                MessageBox(hDlg, L"This isn't much help.", L"Example", MB_OK);
              }
            
            break;
        }
    }
    
    break;

我不明白为什么(((LPNMHDR)lParam)->hwndFrom == g_hLink)else 子句不需要条件?

或者这只是示例中的错误?

4

0 回答 0