7. A bag contains $m$ red balls and $n$ white balls $(m > n \geqslant 4)$. Now, two balls are drawn at random. If the probability of drawing two balls of the same color is equal to the probability of drawing two balls of different colors, then the number of arrays $(m, n)$ that satisfy the relation $m+n \leqslant 40$ is ( ).
(A) 3
(B) 4
(C) 5
(D) 6
7.A.

Let “drawing two red balls” be event $A$, “drawing two white balls” be event $B$, and “drawing one red and one white ball” be event $C$, then
$$
P(A)=\frac{\mathrm{C}_{m}^{2}}{\mathrm{C}_{m+n}^{2}}, P(B)=\frac{\mathrm{C}_{n}^{2}}{\mathrm{C}_{m+n}^{2}}, P(C)=\frac{\mathrm{C}_{m}^{1} \cdot C_{n}^{1}}{\mathrm{C}_{m+n}^{2}} .
$$

According to the problem, $P(A)+P(B)=P(C)$, that is
$$
\mathrm{C}_{m}^{2}+\mathrm{C}_{n}^{2}=\mathrm{C}_{m}^{1} \mathrm{C}_{n}^{1} \text {. }
$$

Therefore, $m+n=(m-n)^{2}$.
Thus, $m+n$ is a perfect square.
Given $m>n \geqslant 4$ and $m+n \leqslant 40$, we have
$$
9 \leqslant m+n \leqslant 40 \text {. }
$$

So, $\left\{\begin{array}{l}m+n=9, \\ m-n=3\end{array}\right.$ or $\left\{\begin{array}{l}m+n=16 \text {. } \\ m-n=4\end{array}\right.$
$$
\text { or }\left\{\begin{array} { l } 
{ m + n = 2 5 , } \\
{ m - n = 5 }
\end{array} \text { or } \left\{\begin{array}{l}
m+n=36, \\
m-n=6 .
\end{array}\right.\right.
$$

Solving these, we get $(m, n)=(6,3)$ (discard) or $(10,6)$ or $(15,10)$ or $(21,15)$.
Therefore, there are 3 pairs $(m, n)$ that satisfy the conditions.