Re: WM_NCDESTROY and ERROR_INVALID_WINDOW_HANDLE
Joseph,
Thanks for the reply.
The code is fairly simple -
void CMyCombo::OnNcDestroy()
{
CString str;
DWORD dwErr;
SetLastError(0);
GetWindowText(str);
dwErr = GetLastError();
TRACE(_T("Last Error = %d"), dwErr); // return 1400 ==
ERROR_INVALID_WINDOW_HANDLE
}
As far as dealing with the error, there isn't anything I can do. The
window is already invalid so I wont be able to get the text. All I
*could* do was to get the text in OnDestroy() and store it to be
referred to in OnNcDestroy().
Thanks,
Neel.
On Feb 13, 11:59 pm, Joseph M. Newcomer <newco...@flounder.com> wrote:
Show the code.
Note that a successful API call rarely changes the value returned by GetLastError(), that
is, for nearly every API call the following code is nonsensical:
APICall(...);
if(::GetLastError() != ERROR_SUCCESS) ...
The only valid approach is
if(!APICall(...))
{
DwORD err = ::GetLastError();
... deal with error
}
joe
On 13 Feb 2007 00:12:37 -0800, neelag...@hotmail.com wrote:
Hi,
I have a custom combobox exported from dll and I use GetWindowText()
to get its text on WM_NCDESTROY. Now, it is understandable if I got
ERROR_INVALID_WINDOW_HANDLE as last error (GetLastError()), but, it
only happens in some of the applications that load the dll from which
this class is exported. For rest of the applications that use this
class exported from dll, everything works fine. Is there a reason why
I should get the error only in some applications and not in others?
Thanks in advance,
Neel.
Joseph M. Newcomer [MVP]
email: newco...@flounder.com
Web:http://www.flounder.com
MVP Tips:http://www.flounder.com/mvp_tips.htm