MFC OnUpdateUI called before WM_CREATE

drjackool 956 Reputation points
2023-06-08T20:48:56.8633333+00:00

hi in my mfc app i creates a clistctrl object in OnCreate message of main frame and in some OnUpdateUI fnctions i used that list ctrl.GetItemCount() for example to enable or disable a menu item. but today i runned app in debug mode the OnUpdateUI function asserted by debuger and the list ctrl wnd handle was NULL! i think onupdateui called before OnCreate so this is normal or it is mfc bug? how this possible?! thanks

Developer technologies | C++
0 comments No comments
{count} votes

Accepted answer
  1. David Lowndes 2,640 Reputation points MVP
    2023-06-08T21:26:25.3066667+00:00

    If I remember correctly the update handlers are called from OnIdle, so I'd assume it is possible and you should check the handle before trying to use it.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.