Another link to the Microsoft documentation might also be helpful.
Using Dialog Boxes - Win32 apps | Microsoft Docs[
^]
Since a dialog is derived from CWnd one could probably also use these messages. BeginPaint is probably also involved in displaying the dialog.
if ((hwndOwner = GetParent(hwndDlg)) == NULL) {
hwndOwner = GetDesktopWindow();
}