How to add button in a list control ?

Can somebody help me to create a button in a special subitem of a list control without setting it to Owner Draw style ?
Thanks.
chongpengAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vinayak KumbarSr Program ManagerCommented:
Hi,

Which button u want to create?, push button or the radio button and how it should be placed?. It must be displayed in one of the sub items and covering that rectangle?.

Pls give some details
0
chongpengAuthor Commented:
Actually ,there are 3 things I want to do:
1)To create a push button, which covers the entire rectangle of one of the sub items.
2) To create a radio button in one of the sub items.
3) To create a check box in one of the sub items.

Can all these be done without using an owner drawn list control ?

Thanks
0
bhatCommented:
Which version of VC are u using?
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

bhatCommented:
Which version of VC are u using?
0
Vinayak KumbarSr Program ManagerCommented:
Hi,

Derive Ur own class from CListCtrl say CVinListCtrl. Then in VinListCtrl.h file take three button variables

CButton *m_PushButton, *m_RadioButton, *m_CheckButton;

In the constructor set them to null
      m_PushButton = NULL;
      m_RadioButton = NULL;
      m_CheckButton = NULL;

Then I will create the buttons when U click on the list control Okay?

Then map OnClick function to that and put the following code which gives u the idea about how to create the buttons.

CRect rect;
            ListView_GetSubItemRect(this->GetSafeHwnd(), 1, 1, LVIR_BOUNDS, &rect);
int Width = GetColumnWidth(0);

rect.right = rect.left + Width;

m_PushButton = new CButton;
m_RadioButton = new CButton;
m_CheckButton = new CButton;

m_PushButton->Create("MyButton", BS_PUSHBUTTON, rect, this, 4545);            
m_PushButton->ShowWindow(SW_SHOW);

Width = GetColumnWidth(1);
rect.right += Width;
rect.left += Width;
m_RadioButton->Create("MyButton", BS_RADIOBUTTON   , rect, this, 4546);            
m_RadioButton->ShowWindow(SW_SHOW);
Width = GetColumnWidth(2);
rect.right += Width;
rect.left += Width;
m_CheckButton->Create("MyButton", BS_CHECKBOX   , rect, this, 4547);            
m_CheckButton->ShowWindow(SW_SHOW);

Now try clicking on the list control area, U will get the three differrent buttons.

Hope this helps.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
chongpengAuthor Commented:
I am using VC++ 6.0
0
Vinayak KumbarSr Program ManagerCommented:
Hi,

For handling those buttons, again u have to map those IDs explicitly and do the checking and unchecking operations etc.

If u want I can send u the sample code in VC++ 5.0

Try it out.
0
chongpengAuthor Commented:
Yes, please send me a sample to try out. Thanks a lot.
0
Vinayak KumbarSr Program ManagerCommented:
Hi,

:-( ! ?#$^%&^&*
Where to send? Give me Ur mail ID :-).
Okay.

Cheers,
0
chongpengAuthor Commented:
My email: Pang@easymultimedia.com
0
Vinayak KumbarSr Program ManagerCommented:
Hi,

I have sent u the code in VC++ 5.0.

Take a look.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.