Click here to Skip to main content
15,912,504 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a tab control. In one of the dialogs of tab control, there is a number of buttons. For each of these button's press, an action has to be done. Similarly on each of the button's release, another action needs to be done. The actions are different for all buttons.

i made a derived class of CButton, and handled the OnLButtonDown and OnLButtonUp events. But i am not able to get the Control ID for the button. I tried like below:-
C++
void CCustomButton::OnLButtonDown(UINT uInt, CPoint point)
{
    CString csCmd;
    int nID = GetFocus()->GetDlgCtrlID();
    switch(nID)
    {
    case IDC_PLAY: // Button ID
        csCmd.Format("BT_AUDIO_BTNPLAY %d", NMP_BTN_ST_PRESS);
        break;
    case IDC_PAUSE:// Button ID
        csCmd.Format("BT_AUDIO_BTNPAUSE %d", NMP_BTN_ST_PRESS);
        break;
   default:
        break;
    }
}
The GetFocus()->GetDlgCtrlID() returns the ID of the control i last clicked on the Dialog. How can i get the control ID of the button which i clicked?
Posted
Updated 9-Sep-10 3:21am
v2
Comments
Sandeep Mewara 9-Sep-10 9:21am    
Use PRE tags to format your code part. It makes the question readable.

1 solution

If you are in the actual button can you call

this->GetDlgCtrlID()
 
Share this answer
 
Comments
reshmi2000 9-Sep-10 21:43pm    
Thanks. It is working now.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900