Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
VC++ MFC ダイアログ アプリケーションがあり、OnTimer 関数で、ダイアログのどのボタンに現在フォーカスがあるかを判断しようとしています。
ここに私が達成しようとしていることのいくつかの疑似コードがあります....
CDialog::OnTimer() { CButton *btn = GetButtonOnFocus(); int btnID = btn->GetDlgCtrlID(); }
私はそれを試していませんが、これはうまくいくはずです:
CWnd * pFocus = GetFocus(); int btnID = 0; if (pFocus != NULL && pDialog->IsChild(pFocus)) btnID = pFocus->GetDlgCtrlID();
これにより、結果がボタンのみに制限されることはありません。そのためには、GetClassNameを使用して、「ボタン」と比較する必要があります。