If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

afxwin2.inl line 265

I have an MDI, where I have an dialog bar. There, I have an extended ComboBox. On OnCloseUpCombo event, I want to display something on CDialog ... but soon as CDialog is close up, I have ASSERT error: afxwin2.inl line 265, which tell me:

Re: afxwin2.inl line 265

1) PreTranslateMessage() is not the ideal place to handle/process messages.
it's purpose is to 'modify' or 'transform' messages.

One of the common uses is to translate keyboard shortcuts (accelerators) into WM_COMMAND messages via the TranslateAccelerator() API.
But you can use it to do your own transformations.

You do this by changing the contents of the pMsg structure.

2) Showing/forcing a dropdown in PreTranslateMessage is as a result a bad idea.
Changing this to a PostMessage() will "apparently" make the problem go away, but not for the reason you think

3) Your real issue is that if you have processed a message and don't need it to do anything else, you need to return TRUE from the function.
if you don',t then MFC will continue processing the message in the normal way.

Your Original function failed because:
YOu are forcing a dropdown
you are probably not returning TRUE
The DropDown is forced, and the VK_RETURN continues on to execute the default button click (OK or Cancel probably) and terminate the dialog at a moment it's unsafe to do so (the combo is pulled open)

Your 2nd attemt seems to work (but is equally wrong, and could subtly fail in some cases) because:
You are posting a message
You are probably still not returning TRUE
A message is posted
THe VK_RETURN is passed on, and executes the default button click
The dropdown posted message is (usually) never processed. because the dialog terminates at which point no code will process the posted message.

If you are doing something OTHER than transforming the message but "have to" to some sort of actual processing in PreTranslateMessage (not ideal, but it happens) then return TRUE right after your processing, don't call the parent implementation.