REALGraphicsDC - Hi-DPI issue

I don’t know how to show this yet but I thought to post here if it rings a bell since I have seen posts on the forum where things go strange if changing resolution while app is running.

So my case is…

  1. I create picture with BitmapForCaching
  2. I get its Graphics, I draw with Xojo
  3. I get the DC with REALGraphicsDC
  4. I draw with native Win32 and Windows theme drawing
  5. I return the DC with the new SDK command.

Everything is fine 100%, 125%, 150% etc.

Now Application is running and user changes from 100% to say 125%

I can never again draw into the DC of a picture created with BitmapForCaching with native commands. So Xojo drawing commands work (at least DrawString I have not tried them all), but when I try to draw into the DC with same code as above then I have no chance to get it to work.

So I am guessing BitmapForCaching is doing something strange if a Window has changed DPI while running ?

It also happens I guess if just making new picture not with BitmapForCaching, so I guess BitmapForCaching is not at fault why Graphics getting HDC on image buffer get hosed after DPI switch.

You are sure that under these conditions your DC with the old resolution is returned properly? It might be a timing issue: at the moment the screen resolution changed your plugins scaleChanged function might be used to release it immediately.

Yes I see it get returned in the debugger

And I don’t keep long time reference to it I just get it draw and return it in next line.

I imagine this may be why some users are complaining that their apps and even Xojo it self goes bad if changing resolution while running. I tested this a lot last night making OffScreen buffers with new Picture, BitmapForCaching no luck it always goes bad if screen DPI is changed, the new buffers created after that are always bad.

And there seems to be more to it not related to the DPI at all, but more related to their new Windows Graphics system.

If I draw nothing at all with Xojo graphics calls and only into the HDC (which I do return properly) then nothing at all is drawn into the off screen buffer. Seems to be all just messed up in every way.

Added bug report on this and gave up on the matter:
47422 - Drawing into DC of OffScreen buffers causes problems on new draw system

There is just no way I can continue to actively support 2016r4 in Windows plugin controls, no matter where we go we hit complete showstoppers with the drawing system.

I don’t think that the Xojo-IDE is well equipped to handle such instantaneous DPI changes either. Its fonts are not dynamically adjusted, The MsgBox is not adjusted, as is the OpenDialog call, to name a few. I see this with the LexingControl plugin, which is currently fully scale-change aware and does not suffer. Unfortunately, this plugin does not use the redraw behavior function, so I cannot provide more specifics to the issue you raise, but I think it all is related. Perhaps I should attach this plugin to your report?