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. C / C++ / MFC
  4. CListCtrl window disappears?!

CListCtrl window disappears?!

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
12 Posts 2 Posters 0 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.
  • T Offline
    T Offline
    Tommy H D Svensson
    wrote on last edited by
    #1

    Hi, Has anyone had this problem before: If I click in the CListCtrl in report view and ALT+TAB toggles to another program (which completly hides the control) and then toggles back to the app with the CListCtrl, the control disappears. However it works if I don't click the CListCtrl and performs the some thing as above. I've included the CListCtrl (report view) on a dialog which in turn is on a tab page. Any ideas anyone? /Tommy

    T 1 Reply Last reply
    0
    • T Tommy H D Svensson

      Hi, Has anyone had this problem before: If I click in the CListCtrl in report view and ALT+TAB toggles to another program (which completly hides the control) and then toggles back to the app with the CListCtrl, the control disappears. However it works if I don't click the CListCtrl and performs the some thing as above. I've included the CListCtrl (report view) on a dialog which in turn is on a tab page. Any ideas anyone? /Tommy

      T Offline
      T Offline
      Tomasz Sowinski
      wrote on last edited by
      #2

      I've included the CListCtrl (report view) on a dialog which in turn is on a tab page. But it isn't a propertypage/sheet, right? Probably you have a problem with z-order. Try to handle WM_ACTIVATEAPP and bring contents of tab to front. Tomasz Sowinski -- http://www.shooltz.com

      T 2 Replies Last reply
      0
      • T Tomasz Sowinski

        I've included the CListCtrl (report view) on a dialog which in turn is on a tab page. But it isn't a propertypage/sheet, right? Probably you have a problem with z-order. Try to handle WM_ACTIVATEAPP and bring contents of tab to front. Tomasz Sowinski -- http://www.shooltz.com

        T Offline
        T Offline
        Tommy H D Svensson
        wrote on last edited by
        #3

        Yes you're right, no propertypage/sheet. But I tried to loacate which window is on top with GetTopWindow and from the result the CListCtrl should be on top, but maybe the result is incorrect when I'm in debug mode (see comments below). See if we can narrow the problem down. It works like this: I have my CTabStrl in the var m_TabCtrl. I've created several dialogs each of which is "activated" like this when I click on a tab: void CSystemInfoDlg::OnSelchangeTab1(NMHDR* pNMHDR, LRESULT* pResult) { ActivateTab(m_TabCtrl.GetCurSel()); *pResult = 0; } void CSystemInfoDlg::ActivateTab(int nTab) { if (pCurDlg) { pCurDlg->ShowWindow(SW_HIDE); } pCurDlg = pDlgs[nTab]; pCurDlg->ShowWindow(SW_SHOW); } When I try to debug it works?!!? I'm clicking on a CListCtrl which is on every pDlgs and after toggling away the app and toggling it back and then doing something to reach a breakpoint and then continue with F5, the CListCtrl shows up again... But that doesn't happen if I don't debug... Any ideas? /T

        T 1 Reply Last reply
        0
        • T Tomasz Sowinski

          I've included the CListCtrl (report view) on a dialog which in turn is on a tab page. But it isn't a propertypage/sheet, right? Probably you have a problem with z-order. Try to handle WM_ACTIVATEAPP and bring contents of tab to front. Tomasz Sowinski -- http://www.shooltz.com

          T Offline
          T Offline
          Tommy H D Svensson
          wrote on last edited by
          #4

          Also, I must add, when the CListCtrl is gone I can activate parts of it by clicking "on it"... It lights up row wise but the entire CListCtrl border doesn't show... Somehow it reacts to my mouse clicks. Is it then possible it is hidden by a window with higher z since it responds to user actions?

          1 Reply Last reply
          0
          • T Tommy H D Svensson

            Yes you're right, no propertypage/sheet. But I tried to loacate which window is on top with GetTopWindow and from the result the CListCtrl should be on top, but maybe the result is incorrect when I'm in debug mode (see comments below). See if we can narrow the problem down. It works like this: I have my CTabStrl in the var m_TabCtrl. I've created several dialogs each of which is "activated" like this when I click on a tab: void CSystemInfoDlg::OnSelchangeTab1(NMHDR* pNMHDR, LRESULT* pResult) { ActivateTab(m_TabCtrl.GetCurSel()); *pResult = 0; } void CSystemInfoDlg::ActivateTab(int nTab) { if (pCurDlg) { pCurDlg->ShowWindow(SW_HIDE); } pCurDlg = pDlgs[nTab]; pCurDlg->ShowWindow(SW_SHOW); } When I try to debug it works?!!? I'm clicking on a CListCtrl which is on every pDlgs and after toggling away the app and toggling it back and then doing something to reach a breakpoint and then continue with F5, the CListCtrl shows up again... But that doesn't happen if I don't debug... Any ideas? /T

            T Offline
            T Offline
            Tomasz Sowinski
            wrote on last edited by
            #5

            I've dusted off one very old project I was involved in. There was similar problem - there was a CListCltr directly on CDialog (no list controls) which was disappearing after Alt+Tab. Adding a WM_ACTIVATEAPP handler solved the problem:

            void CSomeDlg::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
            {
            CDialog::OnActivate(nState, pWndOther, bMinimized);
            if (nState == WA_ACTIVE)
            {
            m_lst.BringWindowToTop();
            }
            }

            Tomasz Sowinski -- http://www.shooltz.com

            T 1 Reply Last reply
            0
            • T Tomasz Sowinski

              I've dusted off one very old project I was involved in. There was similar problem - there was a CListCltr directly on CDialog (no list controls) which was disappearing after Alt+Tab. Adding a WM_ACTIVATEAPP handler solved the problem:

              void CSomeDlg::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
              {
              CDialog::OnActivate(nState, pWndOther, bMinimized);
              if (nState == WA_ACTIVE)
              {
              m_lst.BringWindowToTop();
              }
              }

              Tomasz Sowinski -- http://www.shooltz.com

              T Offline
              T Offline
              Tommy H D Svensson
              wrote on last edited by
              #6

              Hmm, I did like this - Added ON_WM_ACTIVATEAPP in the message map - Added the OnActivate method to one of the dialogs - Added a breakpoint at CDialog::OnActivate(...) but the breakpoint was never found... Did I do something wrong? /T

              T 1 Reply Last reply
              0
              • T Tommy H D Svensson

                Hmm, I did like this - Added ON_WM_ACTIVATEAPP in the message map - Added the OnActivate method to one of the dialogs - Added a breakpoint at CDialog::OnActivate(...) but the breakpoint was never found... Did I do something wrong? /T

                T Offline
                T Offline
                Tomasz Sowinski
                wrote on last edited by
                #7

                Did you use Alt+Tab when dialog is open? Tomasz Sowinski -- http://www.shooltz.com

                T 1 Reply Last reply
                0
                • T Tomasz Sowinski

                  Did you use Alt+Tab when dialog is open? Tomasz Sowinski -- http://www.shooltz.com

                  T Offline
                  T Offline
                  Tommy H D Svensson
                  wrote on last edited by
                  #8

                  [Tomasz, please send me a mail instead because I have to poll for new messages... don't know why but I'm not getting any replies in my mailbox.] Yes, I clicked the tab -> the dialog with the CListCtrl showed up -> I clicked the CListCtrl somewhere -> tabbed away -> tabbed back -> the CListCtrl is gone. Now I wanted to check which window was on the top of the z-order by using GetTopWindow(). And I did this by reacting to a click on the dlg, not the CListCtrl, AFTER I had toggled back the app (that is when the CListCtrl had disappeared). So I set a breakpoint in the OnLButtonDown handler to check the handles for the dialog and the ctrl. If the CListCtrl is beneath the dialog then the handles of ctrl and top should NOT be equal. At least that's what I thought... void CsomeDlg::OnLButtonDown(UINT nFlags, CPoint point) { CWnd* ctrl = &m_List; CWnd* dlg = this; CWnd* top = GetTopWindow(); } The handles were all different... but that maybe depends on something else... what wa important here was that when I pressed F5 to continue running the app, the CListCtrl showed up again...?!?!

                  T 1 Reply Last reply
                  0
                  • T Tommy H D Svensson

                    [Tomasz, please send me a mail instead because I have to poll for new messages... don't know why but I'm not getting any replies in my mailbox.] Yes, I clicked the tab -> the dialog with the CListCtrl showed up -> I clicked the CListCtrl somewhere -> tabbed away -> tabbed back -> the CListCtrl is gone. Now I wanted to check which window was on the top of the z-order by using GetTopWindow(). And I did this by reacting to a click on the dlg, not the CListCtrl, AFTER I had toggled back the app (that is when the CListCtrl had disappeared). So I set a breakpoint in the OnLButtonDown handler to check the handles for the dialog and the ctrl. If the CListCtrl is beneath the dialog then the handles of ctrl and top should NOT be equal. At least that's what I thought... void CsomeDlg::OnLButtonDown(UINT nFlags, CPoint point) { CWnd* ctrl = &m_List; CWnd* dlg = this; CWnd* top = GetTopWindow(); } The handles were all different... but that maybe depends on something else... what wa important here was that when I pressed F5 to continue running the app, the CListCtrl showed up again...?!?!

                    T Offline
                    T Offline
                    Tomasz Sowinski
                    wrote on last edited by
                    #9

                    Check top->GetDlgCtrlID(). It may give you an idea which window is on top, Tomasz Sowinski -- http://www.shooltz.com

                    T 1 Reply Last reply
                    0
                    • T Tomasz Sowinski

                      Check top->GetDlgCtrlID(). It may give you an idea which window is on top, Tomasz Sowinski -- http://www.shooltz.com

                      T Offline
                      T Offline
                      Tommy H D Svensson
                      wrote on last edited by
                      #10

                      Yes, it did! It says the dialog is on top. But, from what I know the CListCtrl is a child window of the dialog and therefore the ctrl should be visible as well... or is it not a child window? Do I have to make an explicit call to m_List.Create from the dlg to make it a child? I always thought that I if I drag a ctrl on a dialog, the explicit creation of the ctrl is not needed since the wizard adds a variable for me and updates the DDX stuff... It's like the ctrl doesn't update its painting... Well, I'll send you a sample project. :) /T

                      T 1 Reply Last reply
                      0
                      • T Tommy H D Svensson

                        Yes, it did! It says the dialog is on top. But, from what I know the CListCtrl is a child window of the dialog and therefore the ctrl should be visible as well... or is it not a child window? Do I have to make an explicit call to m_List.Create from the dlg to make it a child? I always thought that I if I drag a ctrl on a dialog, the explicit creation of the ctrl is not needed since the wizard adds a variable for me and updates the DDX stuff... It's like the ctrl doesn't update its painting... Well, I'll send you a sample project. :) /T

                        T Offline
                        T Offline
                        Tomasz Sowinski
                        wrote on last edited by
                        #11

                        I've just realized that you're clicking on a dialog surface - it's no surprise that it becomes a top window. Anyway, I have no idea why aren't you getting a WM_ACTIVATEAPP message. Can you check with Spy++, if your app gets one when you Alt-Tab? BTW: you don't need to call Create on m_List. It's created by Windows during the call to DialogBox or CreateDialog. Tomasz Sowinski -- http://www.shooltz.com

                        T 1 Reply Last reply
                        0
                        • T Tomasz Sowinski

                          I've just realized that you're clicking on a dialog surface - it's no surprise that it becomes a top window. Anyway, I have no idea why aren't you getting a WM_ACTIVATEAPP message. Can you check with Spy++, if your app gets one when you Alt-Tab? BTW: you don't need to call Create on m_List. It's created by Windows during the call to DialogBox or CreateDialog. Tomasz Sowinski -- http://www.shooltz.com

                          T Offline
                          T Offline
                          Tommy H D Svensson
                          wrote on last edited by
                          #12

                          Hi Tomasz, I just got a solution to the problem with a little help from another Codeproject dude [thx Joel!]. The thing is that whenever a WM_ERASEBKGND is received by a CTabCtrl, all window children of CTabCtrl that are CListCtrls don't get properly repainted if they have been "focused". The fix is just to call RedrawWindow on the CListCtrl when ever appropriate. As always Tomasz, thx for your superb help and 'be there'-frequency! /Tommy

                          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