I'm guessing here at what the problem is, and that it's related to "used successfully in many places in the program".
;==============================================================================
; Build as a console app.
;==============================================================================
include \masm32\include\masm32rt.inc
;==============================================================================
.data
.code
;==============================================================================
DlgProc proc uses ebx hwndDlg:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
LOCAL ps:PAINTSTRUCT, rc:RECT, hdc:HDC
SWITCH uMsg
CASE WM_PAINT
invoke BeginPaint, hwndDlg, ADDR ps
mov hdc, eax
;invoke FillRect, hdc, ADDR ps.rcPaint, COLOR_HOTLIGHT+1
invoke CreateSolidBrush, 0ff00ffh
invoke FillRect, hdc, ADDR ps.rcPaint, eax
.IF eax == 0
printf("%s\n",LastError$())
.ENDIF
invoke EndPaint, hwndDlg, ADDR ps
;-----------------------------------------------
; The HDC returned by BeginPaint is apparently
; invalid after EndPaint executes.
;-----------------------------------------------
invoke GetClientRect, hwndDlg, ADDR rc
invoke FillRect, hdc, ADDR rc, COLOR_HOTLIGHT+1
.IF eax == 0
printf("After EndPaint: %s\n",LastError$())
.ENDIF
CASE WM_COMMAND
SWITCH wParam
CASE IDCANCEL
invoke EndDialog, hwndDlg, 0
ENDSW
CASE WM_CLOSE
invoke EndDialog, hwndDlg, 0
ENDSW
return 0
DlgProc endp
;==============================================================================
start:
;==============================================================================
Dialog "Test", "MS Sans Serif",10, \
WS_OVERLAPPED or WS_SYSMENU or DS_CENTER, \
0,0,0,200,150,1024
CallModalDialog 0,0,DlgProc,0
exit
;==============================================================================
end start