Hi
I have a DLL that is called by Visual Basic and which
displays a modal form. I have compiled this DLL and it
works perfectly, apart from the fact that I want to be
able to pass it a string to display in the title bar, but
the SetWindowText function doesn't seem to do anything.
My code is shown below. Any help would be much appreciated.
Thanks
void __stdcall GetLogin(BSTR appname, BSTR caption, BSTR*
username, BSTR* password, bool reshow)
{
//read the current username from the registry for
this application
CString currentuser = theApp.GetProfileString
((LPSTR)appname, USERNAME, NULLSTRING);
//read the current password from the registry for
this application and decrypt it
CString currentpassword = Encrypt(
theApp.GetProfileString((LPSTR)appname,
PASSWORD, NULLSTRING));
//variables to represent new password
CString retuser, retpass;
if(reshow || (currentuser.GetLength() == 0))
{ //if we need to show the form because either
there is no existing username or because we are told to...
Login flogin;
//update the caption of the form
flogin.SetWindowText((LPSTR)caption);
//THE ABOVE LINE DOESN'T DO ANYTHING...
//show the form modally
flogin.DoModal();
//retrieve the values entered
retuser = flogin.m_Username;
retpass = flogin.m_Password;
//update the registry settings for this
application, after encrypting the password
theApp.WriteProfileString((LPSTR)appname,
USERNAME, retuser.operator LPCTSTR());
theApp.WriteProfileString((LPSTR)appname,
PASSWORD,
Encrypt(retpass).operator LPCTSTR
());
}
else
{
//if values already exist in registry,
just set return values to these
retuser = currentuser;
retpass = currentpassword;
}
//copy return values to byref parameters passed in
LPCSTR luser = retuser.operator LPCTSTR();
LPCSTR lpass = retpass.operator LPCTSTR();
*username = SysAllocStringByteLen(luser,
retuser.GetLength());
*password = SysAllocStringByteLen(lpass,
retpass.GetLength());
}