Most likely the host window is getting recreated when you change the border style. This most likely leads to a GL window not having a parent to get it's specs from.
Technically a GL window does not need a form in real life but I suppose it still needs one as a measure to know where to show.
If this is the case then you could in windows try using the SETWINDOWLONG to enable or disable the border, this way the handle will remain the same.
Or, you could close the GL window, change your size then reopen the GL window. This way it will now have the new handle..
Report back if that leads you anywhere cause I don't feel like loading up to app you posted to most likely find what I already think.