Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. CWindow::IsWindow // testing the member hWnd

CWindow::IsWindow // testing the member hWnd

Scheduled Pinned Locked Moved ATL / WTL / STL
c++comsysadmintestingbeta-testing
4 Posts 3 Posters 25 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Phil Benson
    wrote on last edited by
    #1

    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 :(

    Who the F*** is general failure and why is he reading my hard drive?

    J 1 Reply Last reply
    0
    • P Phil Benson

      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 :(

      J Offline
      J Offline
      Joaquin M Lopez Munoz
      wrote on last edited by
      #2

      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 to TRUE. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

      P 1 Reply Last reply
      0
      • J Joaquin M Lopez Munoz

        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 to TRUE. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

        P Offline
        P Offline
        Phil Benson
        wrote on last edited by
        #3

        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 :(

        Who the F*** is general failure and why is he reading my hard drive?

        G 1 Reply Last reply
        0
        • P Phil Benson

          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 :(

          G Offline
          G Offline
          Gary R Wheeler
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups