Off-axis aberrations in a beam-scanning multiphoton confocal microscope are corrected with a deformable mirror. The optimal mirror shape for each pixel is determined by a genetic learning algorithm, in which the second-harmonic or two-photon fluorescence signal from a reference sample is maximized. The speed of the convergence is improved by use of a Zernike polynomial basis for the deformable mirror shape. This adaptive optical correction scheme is implemented in an all-reflective system by use of extremely short (10-fs) optical pulses, and it is shown that the scanning area of an f:1 off-axis parabola can be increased by nine times with this technique.