A measurement of CP-violating observables is performed using the decays B-+/- -> DK +/- and B-+/- -> D pi(+/-), where the D meson is reconstructed in one of the self-conjugate three-body final states K-S(0)pi(+)pi(-) and (KSK+K-)-K-0 (commonly denoted K(S)(0)h(+)h(-)). The decays are analysed in bins of the D-decay phase space, leading to a measurement that is independent of the modelling of the D-decay amplitude. The observables are inter- preted in terms of the CKM angle gamma. Using a data sample corresponding to an integrated luminosity of 9 fb(-1) collected in proton-proton collisions at centre-of mass energies of 7, 8, and 13 TeV with the LHCb experiment, gamma is measured to be (68.7(-5.1)(+5.2))degrees. The hadronic parameters r(B)(DK), r(B)(D pi), delta(DK)(B), and delta(D pi)(B), which are the ratios and strong-phase differences of the suppressed and favoured B-+/- decays, are also reported.