Solved

CListCtrl Problem

Posted on 1997-05-25
21
229 Views
Last Modified: 2013-11-19
I have created several buttons in my Main Window that I use to select CListControls.  When I select a button a list control is created.  The control is sizeable. When I attempt to resize the control my buttons become visible through the  list control.  Also if the mouse is pressed within the list control in an area where a button is being covered the button is selected.  How can I stop this from happening.  I've tried several styles but nothing worked.
0
Comment
Question by:sjm
  • 10
  • 5
  • 4
  • +1
21 Comments
 
LVL 10

Expert Comment

by:RONSLOW
ID: 1301769
You need to change the Z ordering of the list control (probably in its WM_CREATE handler).

It is being created UNDER the buttons (but ON TOP OF the window background).  Use SetWindowPos to move it to the front of the Z order.

PS: Where are you creating the List Control - in a CFormView? or in a CDialog?

0
 

Author Comment

by:sjm
ID: 1301770
RONSLOW,
                    Both the buttons and  CList controls are being created in my CView.  How does the Z order affect the way the other controls bleed through the list control?  The list control is being created over the buttons in my view.  When I try to move or resize the list control the buttons below the list control are  showing through and they are being enabled when I try to select an item in the list control that is ontop of a button.
0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 1301771
The only way they would be showing through and responding to mouse actions is if they are on TOP of the List Control.

Can you e-mail me a screen-shot of this?  And some code.  I am at mailto:Roger_Onslow@compsys.com.au

0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 1301772
Sean

The problem is that you are creating your buttons etc in OnShowWindow - that means every time the view is covered or exposed, you'll create ANOTHER copy of the button.  That includes when you resize you list control.  In otherwords, its not the original buttons showing through, but NEW buttons being created on top !!

I'd move the creation of your buttons etc from OnShowWindow to your OnCreate or OnInitialUpdate handler.  That way, they'll just get created when the view is first created, and not re-created everytime something covers or exposes your view (you'll end up with LOTS of overlaid buttons that way).

Good luck !!!

Roger
0
 

Author Comment

by:sjm
ID: 1301773
Roger,

     I moved all my buttons to OnInitialUpdate and my problem as not changed.  I am e-mailing you several screen shots to show you the problem.
0
 

Author Comment

by:sjm
ID: 1301774
Sorry RONSLOW,  I waited a week for a responce.  I realy need an answer to this problem!!:<
0
 
LVL 4

Expert Comment

by:AVaulin
ID: 1301775
I had problem like your and solved it by calling EnableWindow(FALSE) for each control (in your case buttons). To return normal button work call EnableWindow(TRUE).
Good luck.
0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 1301776
I haven't seen your code since you made the changes - please send.

It is interesting that only the BUTTONS show through.

0
 

Author Comment

by:sjm
ID: 1301777
Avaulin

     Using EnableWindow(FALSE) did not work.  The disabled button still appeared through the list control.  Give me your E-Mail address and I will send you a copy of my code and  screen shots of the problem.

RONSLOW,

     I am sending the revised code I tried. and a screen shot of the above.
0
 
LVL 4

Expert Comment

by:AVaulin
ID: 1301778
My address is av@protec.kiev.ua
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 4

Expert Comment

by:AVaulin
ID: 1301779
This is really interest problem. I can't find it solving. But I can propose you another way: you can create non-modal dialog and place only one ListCtrl control in it. I hope it must help.
0
 

Author Comment

by:sjm
ID: 1301780
Sorry AVaulin, I need this Control to work outside a dialog.  And I've increased the points to 100 so I hope some one can help me solve this problem.
0
 

Author Comment

by:sjm
ID: 1301781
Adjusted points to 100
0
 
LVL 1

Expert Comment

by:mrosen
ID: 1301782
I have this problem too. I assume you're handling the sizing in OnSize. You are probably then recalculating the size with GetDlgItem()->MoveWindow, too. If not, this is definately a good way to go about it. You should then call the InvalidateRect() command for the window or dialog that holds all of your controls. This will eliminate the problem.
0
 

Author Comment

by:sjm
ID: 1301783
mrosen,
      I have been trying to create the CList controls as child windows with out having to create a window inclosing the controls.  This hasn't worked as you can tell by the comments above.  If I have to create the control inside a window and have that window work as a popup window could you please provide the correct code.  I've tried to use CreateEx but I can't get a handle to the frame window client area and I get an assertion error for not having WS_CHILD as a style in my CView. When I try to use a new CView class I get an error saying can't access protected constructor.  I'm sure I'm not doing it correctly.
0
 
LVL 1

Expert Comment

by:mrosen
ID: 1301784
Ok. I'm a bit unclear about what's going on. Here are the two possible things I think you're doing:

Two or more listctrl at a time:
Here you should cheat and make a dialog box. In your dialog box properties, second tab, choose the border as resizing. Then create the basic format of your dialog box. In OnSize, you should call GetClientRect to figure out the new size and resize all of the dialog controls using MoveWindow (with a final InvalidateRect), like I said in my proposed answer.

Using buttons to toggle between listctrls:
This is a lot of explanation. Please tell me if this is what you want to do. I have a project that does this, and I can send it to you ant explain this to you if you want.
0
 

Author Comment

by:sjm
ID: 1301785
mrosen,
     Here is what i'm trying to do.  I have seven CButton controls that are created in my CView class and appear in the main view.  Each of these buttons control a CListControl.  A user should be able to select any or all of these buttons and any or all of the CListControls should be visible.  The user should be able to tab through the CListControls and be able to minimize or maximize an individual ClistControl.  The problem I'm getting is that when a button is selected and a CListControl appears, any attemp to use this control such as resizing or moving this control causes the CButtons behind the control to appear through the control.  Any attempt to click inside the control does the same thing.  It would seem to me that the only solution is to create multiple CView windows for each control and add the controls to each window.  But I don't quite know how to do this and I was trying to find out if some one has some code that will do this.  The problem with using a non-modal dialog is the amount of overhead, the calls to movewindow and the inability to use all of the dialog for the control.  I would rather use CreateEx if there is no way to just create a ClistControl as a true child window.  If you would like I can send you a screen shot of my app showing you what happens when I try to resize the CListControl.  Just give me your e-mail address.  I can also send you the code of my CView CLass to see what I might be doing wrong.
0
 

Author Comment

by:sjm
ID: 1301786
mrosen,
     I made a big mistake I should have given your ideas a try before grading you.  Using adialog box with the CListCtrl was the right way to go.  Is there any way I can change the grade from F to A?
0
 
LVL 4

Expert Comment

by:AVaulin
ID: 1301787
This was my idea. If you agree with this let me leave you empty answer for evaluation.
0
 

Author Comment

by:sjm
ID: 1301788
I"m sorry Avaulin my mistake. You were the first to come up with the idea and you should be the one who is given the points.  I'm sorry I didn't try this idea before.  But the system won't let me give you a grade.  The question is still listed as unlocked.
0
 
LVL 4

Accepted Solution

by:
AVaulin earned 100 total points
ID: 1301789
(Empty)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now