CWindow::IsWindow // testing the member hWnd
-
While testing my application (a Win32 dll using WTL/ATL not a COM server, that exports functions to a mfc app) on Win98 I have had the following problem. Under Windows XP/ Win 2000 the following works fine, and as expected if(pPage->m_hWnd != NULL && ::IsWindow(pPage->m_hWnd) == TRUE){ _sError.Format("%s %d", "Showing page ", pPage->m_nPageID); ::MessageBox(NULL, _sError,"",MB_OK); pPage->EnableWindow(TRUE); pPage->ShowWindow(SW_RESTORE); bResult = pPage->OnSetActive(); } however under win 98, ::IsWindow always returns FALSE, regrdless.... has anyone a workaround for this as (I think?) it adds a bit more safety. I have even tried pPage->IsWindow(), but this also fails Anyone had similar problems? bum... and I thought I´d got rid of all the bugs :(
-
While testing my application (a Win32 dll using WTL/ATL not a COM server, that exports functions to a mfc app) on Win98 I have had the following problem. Under Windows XP/ Win 2000 the following works fine, and as expected if(pPage->m_hWnd != NULL && ::IsWindow(pPage->m_hWnd) == TRUE){ _sError.Format("%s %d", "Showing page ", pPage->m_nPageID); ::MessageBox(NULL, _sError,"",MB_OK); pPage->EnableWindow(TRUE); pPage->ShowWindow(SW_RESTORE); bResult = pPage->OnSetActive(); } however under win 98, ::IsWindow always returns FALSE, regrdless.... has anyone a workaround for this as (I think?) it adds a bit more safety. I have even tried pPage->IsWindow(), but this also fails Anyone had similar problems? bum... and I thought I´d got rid of all the bugs :(
I don't really think this is the problem, but it costs nothing to give it a try: replace your check with
if(pPage->m_hWnd != NULL && ::IsWindow(pPage->m_hWnd)){
...Note the docs say the result on success of
IsWindow
is nonzero, which is not the same as being equal toTRUE
. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo -
I don't really think this is the problem, but it costs nothing to give it a try: replace your check with
if(pPage->m_hWnd != NULL && ::IsWindow(pPage->m_hWnd)){
...Note the docs say the result on success of
IsWindow
is nonzero, which is not the same as being equal toTRUE
. Joaquín M López Muñoz Telefónica, Investigación y DesarrolloThnaks, this did the job, but why did my function work on NT4/2000/XP. but on Win98 (and I presume on Win95) not, this was what confused me......? Thnaks once again Grüß Phil bum... and I thought I´d got rid of all the bugs :(
-
Thnaks, this did the job, but why did my function work on NT4/2000/XP. but on Win98 (and I presume on Win95) not, this was what confused me......? Thnaks once again Grüß Phil bum... and I thought I´d got rid of all the bugs :(
The docs say that ::IsWindow() returns non-zero if the argument is a valid window. In one case, the O/S returns TRUE. In another case, the O/S is returning (possibly) the window handle, or something else, that is non-zero. As a rule, the following:
BOOL condition = ::Windows_API_Call(...);
...
if (condition) {
...
}is preferable to
if (condition == TRUE) {
...
}since the Windows API (where BOOL is defined) tends to play fast-and-loose with BOOL return values. Often, they define the return value of an API call as BOOL (which you assume has only two values, TRUE and FALSE), when it would be better to specify it as a DWORD. The return value in that case means one thing when it is non-zero, and something else when it is zero. Gary R. Wheeler