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?
 
Vinayak KumbarConnect With a Mentor Sr 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
 
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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
bhatCommented:
Which version of VC are u using?
0
 
bhatCommented:
Which version of VC are u using?
0
 
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
All Courses

From novice to tech pro — start learning today.