binhttruong
Programmer
I have a COM object called CATLAdmin and one of method is ShowLoginDlg. When this metod is called, it displays a logon dialog to allow the user to enter there user id and password. After the user click on the OK button the user id is saved to the variable lpvUserID (see code below) so it could be passed back to the main application, but the lpvUserID value was empty when it exited the ShowLoginDlg funtion.
STDMETHODIMP CATLAdmin::ShowLoginDlg(LPVARIANT lpvUserID,LPVARIANT lpvResult)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
//Initialize return value.
lpvAdmin->vt = VT_BOOL;
lpvUserID->vt = VT_BSTR;
//Instantiate and show login window.
CDlgLogin dlgLogin();
if (dlgLogin.DoModal() == IDOK)
{
// At this point there is a valid User ID
// saved to lpvUserID
lpvUserID->bstrVal = _bstr_t((dlgLogin.m_pUserData)->m_strUserID);
//Set a successful return value.
lpvResult->boolVal = TRUE;
}
else
{
lpvResult->boolVal = FALSE;
}
return (S_OK);
}
inline _variant_t IATLAdmin::ShowLoginDlg (VARIANT * lpvUserID)
{
VARIANT _result;
VariantInit(&_result);
//When viewed in debug mode for the lpvUserID is empty!! What happened to the value????
HRESULT _hr = raw_ShowWndLoginEx(lpvUserID, &_result);
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
return _variant_t(_result, false);
}
Thank you for any suggestions that would help me.
BT
STDMETHODIMP CATLAdmin::ShowLoginDlg(LPVARIANT lpvUserID,LPVARIANT lpvResult)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
//Initialize return value.
lpvAdmin->vt = VT_BOOL;
lpvUserID->vt = VT_BSTR;
//Instantiate and show login window.
CDlgLogin dlgLogin();
if (dlgLogin.DoModal() == IDOK)
{
// At this point there is a valid User ID
// saved to lpvUserID
lpvUserID->bstrVal = _bstr_t((dlgLogin.m_pUserData)->m_strUserID);
//Set a successful return value.
lpvResult->boolVal = TRUE;
}
else
{
lpvResult->boolVal = FALSE;
}
return (S_OK);
}
inline _variant_t IATLAdmin::ShowLoginDlg (VARIANT * lpvUserID)
{
VARIANT _result;
VariantInit(&_result);
//When viewed in debug mode for the lpvUserID is empty!! What happened to the value????
HRESULT _hr = raw_ShowWndLoginEx(lpvUserID, &_result);
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
return _variant_t(_result, false);
}
Thank you for any suggestions that would help me.
BT