Once you have created the window, but before displaying it, get its dimensions. Get also the dimensions of the working area with SystemParametersInfo. If the window is bigger that the working area, shrink the size of the main window and make it scrollable using the CScrollWindow class.
Of course, if you have scrollable controls that also exceed the limits, such a ListBox, you may need to do further adjustments.
Another possibility is to calculate the DPI at which the window will fit, and set it with the pWindow.DPI property before creating the window and controls. This is equivalent to doing a limited scaling.