Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1294
  • Last Modified:

CTabCtrl + CListCtrl causing problems

Ok I have a dialog that has a CTabCtrl and 2 CListCtrls.

The tab and the 2 lists are sibling controls. I was stretching the tab control to be the whole area of the dialog, then I was moving the two lists on top of the tab control to give the appearance that it was contained inside of it, something like this:
-----------------
|tab1  | tab 2 |
--------------------------------------------------------------
|                                                                           |
|   ------------------------------------------------------     |
|   |   list 1                                                       |    |
|   ------------------------------------------------------     |
|                                                                           |
|   ------------------------------------------------------     |
|   |   list 2                                                       |     |
|   ------------------------------------------------------     |
--------------------------------------------------------------

but now my lsits controls have some repainting issues. If I give one of the lists focus, open another window so it covers the list control, then switch focus back to my list, it fails to repaint that area where the overlap was. Is there anyway around this? I didnt want to make the 2 lists children of the tab because then it's another layer I have to get through to access the lists from other parts of my application.

Thanks
0
minnirok
Asked:
minnirok
1 Solution
 
AlexFMCommented:
Try to override WM_ERASEBKGND for both tab pages and redraw all background except area of listboxes. This will make tho holes in the tab control, possibly solving repainting problems.
0
 
DanRollinsCommented:
I can reproduce the problem as described and it appears to be be related to the tab order of the controls.

In the dialog editor, use the menu command:
     Layout>TabOrder
(or press Ctrl+D).   Look at the little squares that appear on the dialog box.  Make sure that the ones on the List controls (or any controls that should appear "above/on top of" the Tab control) have higher numbers than the one on the Tab control itself.  

To change the numbers, just click on the square tags one at a time, starting with the item you want to get the focus when the dialog box first appears.  Click on the List controls last.

(you can also control-click on any number and then the next numbers you click will be set sequentially higher than that one)

-- Dan
0
 
minnirokAuthor Commented:
Ahhhh jeez unbelievable. I'll give it a try when I get back to the office on monday. It would be wonderful if that's all that's needed to fix it!

Thanks
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
AndyAinscowCommented:
< it's another layer I have to get through to access the lists from other parts of my application.>

pView->m_lstCtrl1.XYZ();
instead of
m_lstCtrl1.XYZ();


For me that isn't a great deal more work.
0
 
mahesh1402Commented:
minnirok
Its not similar question? : http://www.experts-exchange.com/Programming/Programming_Languages/MFC/Q_21827049.html

Have you tried suggestions given on that ? also like issue RedrawWindow() instead of issuing an Invalidate in the OnPaint.

myCListCtrl.RedrawWindow(NULL,NULL,RDW_FRAME | RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW);

-MAHESH
0
 
AndyAinscowCommented:
Also if you have code like
((CMainFrame*)AfxGetMainWnd())->m_lstCtrl1->XYZ();
then you can patch it up easily by creating the list controls in the OnCreate of the view then setting the value in the main frame to point to the list control in the view

pseudo code
CMyView::OnCreate(...)
{
  CView::OnCreate(...)

create list control
then
((CMainFrame*)AfxGetMainWnd())->m_lstCtrl1 = m_lstCtrl1;

}
0
 
DanRollinsCommented:
Thanks for the points and the grade.  Sometimes the simplest answer is the best.
-- Dan
0
 
AndyAinscowCommented:
I think it is now clearer for me as to what you meant with your app.
Do you know about property sheets and pages ?  (That is a dialog with tabs on it - even simpler than coding it yourself)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now