CListCtrl window disappears?!
-
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
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
-
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
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?
-
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
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
-
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
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
-
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
Did you use Alt+Tab when dialog is open? Tomasz Sowinski -- http://www.shooltz.com
-
Did you use Alt+Tab when dialog is open? Tomasz Sowinski -- http://www.shooltz.com
[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...?!?!
-
[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...?!?!
Check top->GetDlgCtrlID(). It may give you an idea which window is on top, Tomasz Sowinski -- http://www.shooltz.com
-
Check top->GetDlgCtrlID(). It may give you an idea which window is on top, Tomasz Sowinski -- http://www.shooltz.com
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
-
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
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
-
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
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