- DEVICE_MSWINDOWS_HORZRES(d) = LOWORD (lParam);
- DEVICE_MSWINDOWS_VERTRES(d) = HIWORD (lParam);
- DEVICE_MSWINDOWS_BITSPIXEL(d) = wParam;
- break;
+ /* Do this only once per message. XEmacs can receive this message
+ through as many frames as it currently has open. Message time
+ will be the same for all these messages. Despite extreme
+ efficiency, the code below has about one in 4 billion
+ probability that the HDC is not recreated, provided that
+ XEmacs is running sufficiently longer than 52 days. */
+ if (DEVICE_MSWINDOWS_UPDATE_TICK(d) != message_tick)
+ {
+ DEVICE_MSWINDOWS_UPDATE_TICK(d) = message_tick;
+ DeleteDC (DEVICE_MSWINDOWS_HCDC(d));
+ DEVICE_MSWINDOWS_HCDC(d) = CreateCompatibleDC (NULL);
+ }