Link to home
Start Free TrialLog in
Avatar of sjm
sjm

asked on

CListCtrl Problem

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.
Avatar of RONSLOW
RONSLOW

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?

Avatar of sjm

ASKER

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.
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

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
Avatar of sjm

ASKER

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.
Avatar of sjm

ASKER

Sorry RONSLOW,  I waited a week for a responce.  I realy need an answer to this problem!!:<
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.
I haven't seen your code since you made the changes - please send.

It is interesting that only the BUTTONS show through.

Avatar of sjm

ASKER

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.
My address is av@protec.kiev.ua
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.
Avatar of sjm

ASKER

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.
Avatar of sjm

ASKER

Adjusted points to 100
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.
Avatar of sjm

ASKER

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.
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.
Avatar of sjm

ASKER

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.
Avatar of sjm

ASKER

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?
This was my idea. If you agree with this let me leave you empty answer for evaluation.
Avatar of sjm

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of AVaulin
AVaulin
Flag of Ukraine image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial