Invalid pixelformat?

I have simple program that has one window using OpenGL context. Then I do a Modal dialog box that has another OpenGL context. Then I leave the dialog. But, when I call wglMakeCurrent for the main context, it returns “invalid pixelformat” - error.
BUT this happens only if I touch a edit control in the dialog. If I don’t edit text, it works well.
What am I doing wrong? I couldn’t even imagine for such an error!