I am passing a pointer to a string to a DialogProc via CreateDialogParam. This pointer points to dynamically allocated memory which is released immediately after CreateDialogParam returns. Is WM_INITDIALOG processed before CreateDialogParam returns?
For example:
LPWSTR lpStr = malloc( some_size )
CreateDialogParam( ... lpStr );
free( lpStr );
In DialogProc:
case WM_INITDIALOG:
... do something with lParam
Yes. According to the documentation for CreateDialogParam,
The operative word here is that it sends a message (as opposed to posting one). SendMessage just calls the dialog procedure directly. PostMessage would put the message in the queue.
So, yes, the WM_INITDIALOG should complete before CreateDialogParam returns. You can verify this yourself relatively trivially using a debugger and some breakpoints.