wxHyperTextWindow::RestoreSection

void RestoreSection(void)

When a call is made to Compile, the current pointer to the current section becomes invalid, since all sections are recalculated. You need to SaveSection before Compile, followed by RestoreSection after the Compile, in order to restore the display to the previous state.