Question

I have a massive function (1500 lines of code) that I need to debug. I'll try and eventually break it down, but the tools available are not up to the task.

So, what I need in the meantime is to be able to disable caching of the DC's writing to the display to be able to debug this quickly. Is there some flag that I can set to accomplish this?

Was it helpful?

Solution

As a performance optimization the GDI performs batching. When you ask GDI to perform an operation it doesn't always execute it immediately. Instead, it stores it in a buffer and once that buffer gets full the batch gets flushed and the operations get sent to kernel mode for execution. This is what GDI does by default and there is usually no reason to change this mode of operation.

Occasionally you need control over how much batching GDI performs or when flushing occurs, either because you are rendering to an offscreen DC and need to read that information back from memory, or for debugging purposes.

There are 2 API calls you can use to control batching. To initiate a flush of the batched up operations you can call GdiFlush. Once this API returns you are guaranteed that all GDI operations have run to completion. If you want to control the amount of batching performed you can use GdiSetBatchLimit. To disable batching altogether simply call GdiSetBatchLimit(1).

OTHER TIPS

The way I do it:

  1. The easiest way is havong two monitors.
  2. Remote Debugging is also perfect, much better than Debugging on the same machine. You may do this also with a virtual machine.

You have to disable double buffering (usage of CMemDC).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top