在OnLButtonDown和OnLButtonUp中获取按钮的控件ID [英] Getting control ID of the button in OnLButtonDown and OnLButtonUp

查看:480
本文介绍了在OnLButtonDown和OnLButtonUp中获取按钮的控件ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个选项卡控件.在选项卡控件的对话框之一中,有许多按钮.对于这些按钮的每一次按下,都必须执行一个操作.同样,在每个按钮的释放上,都需要执行另一项操作.所有按钮的操作都不同.

我制作了CButton的派生类,并处理了OnLButtonDown和OnLButtonUp事件.但是我无法获取按钮的控件ID.我尝试如下:-

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

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;
    }
}

GetFocus()-> GetDlgCtrlID() 返回我上一次在对话框中单击的控件的ID.如何获得我单击的按钮的控件ID?

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?

推荐答案

如果您位于实际按钮中,可以调用

If you are in the actual button can you call

this->GetDlgCtrlID()


这篇关于在OnLButtonDown和OnLButtonUp中获取按钮的控件ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆