用GetFocus()->GetDlgCtrlID();或 GetFocus()->getParent()->GetDlgCtrlID();
得到的ID根本就不是。 而且得到的ID号 和所有的控件ID都不一样请教高人解答

解决方案 »

  1.   

    而且得到的ID号 和所有的控件ID都不一样
    ---
    什么意思?
    你得到的是一个数字,比如12345,控件的ID使用的是宏IDC_BUTTON1,本质上还是数字
    直接比较就可以了
    if(GetFocus()->GetDlgCtrlID() == IDC_BUTTON1)
    {
    }
      

  2.   

    GetFocus returns the window with the keyboard focus for the current thread's message queue. If GetFocus returns NULL, another thread's queue may be attached to a window that has the keyboard focus. Use the GetForegroundWindow function to retrieve the handle to the window with which the user is currently working. You can associate your thread's message queue with the windows owned by another thread by using the AttachThreadInput function. Windows 98/Me and Windows NT 4.0 SP3 and later:To get the window with the keyboard focus on the foreground queue or the queue of another thread, use the GetGUIThreadInfo function.For an example, see "Creating a Combo Box Toolbar" in Using Combo Boxes.看看这个最标准
      

  3.   

    一般很少获取ID的,获取句柄就行了GetDlgItem