An approach to all-optical windowed binary phase-coded microwave waveform generation is proposed and demonstrated. An optical double sideband plus carrier (DSB+C) signal with the carrier and the two sidebands being orthogonally polarized is generated by a dual-polarization quadrature phase shift keying (DP-QPSK) modulator, with the generated signal sent to a phase modulator (PM). The PM can support phase modulation in two orthogonal polarization directions. The phase-modulated signals are projected to one polarization direction and detected at a photodetector (PD). Switching the polarity of the coding signal, a π phase shift is introduced. In addition, the amplitude of the generated signal is dependent on the amplitude of the input coding signal. Thus, a windowing function can be applied to the generated waveform by using a windowed input phase coding signal, to suppress the sidelobes in the spectrum of the generated microwave signal. The key features of the proposed waveform generator include all-optical generation without the need of electrical components and optical filters, thus ensuring a wide operating frequency range. Experimental results show that, using a Gaussian windowed 64-bit pseudorandom binary sequence (PRBS) coding signal, a microwave phase-coded microwave waveform is generated with the sidelobes of the spectrum largely suppressed to below the system noise floor and a pulse compression ratio (PCR) as large as 133.