Well, I came across that code I'd found earlier. It looks like unit creation should fail once you hit 1023 units.
Mind you, due to the way units are created, this depends on how that particular unit is created. But from what I've seen, they all seem to call the common function which has the 1023 limit. The function is called from quite a few points (although, it didn't look like there were quite enough calls for every possible unit). I checked out a few such as CommandCenters, Beacons, and Vortexes. They all used the same function.
Mind you, that doesn't deal with the buttons getting disabled in the UI. That's just failure when you actually try to create the unit. That shouldn't happen until after the factory has finished building the unit, and the button gets disabled so you can't even start building it.
As for editing the above code, it doesn't look like it'd be too hard to increase that internal limit to 2047 units. It'd need a few slight changes to a few locations, but they all seem to be contained in that one function. The only problem is, this wouldn't appear to address the UI issue, so it'd probably be a useless edit until that is figured out.