Is there a way to define and send custom message types in Win32, to be caught by your Main message handler? For example, my main message handler captures messages such as WM_PAI
Yes. Just declare a constant in the WM_USER range e.g.
#define WM_RETICULATE_SPLINES (WM_USER + 0x0001)
You can also register a message by name using the RegisterWindowMessage API.
You can then send these messages using SendMessage, PostMessage or any of their variants.