[comp.windows.ms] Create-In-CompatibleDC?

mms00786@uxa.cso.uiuc.edu (05/09/90)

I have a probably trivial question. I need to do the following:
     1) Register a Window Class with the CS_OWNDC style.
     2) Set the mapping mode etc during the WM_CREATE processing.

     3) Then, on a timer event, I want to create a compatibleDC, select a
        compatible bitmap into it, do some drawing, bitblt to the real DC
        and get out.

What I find is that when I call CreateCompatibleDC(hDC), the memory device
context does not have any of the mapping mode information at all! The memory
device context returns essentially a DC with the default settings! The end
result is that I still have to set mapping mode etc on every timer event.
So, what am I doing wrong? Of course, I have checked and double checked that
hDC passed to createcompatibledc is the correct one, and still has the mapping
info etc (verified by directly drawing to hDC).

Secondly, if I am able to create a compatible bitmap and keep the returned
handle around for the life of the program instance, why is it that I am not
allowed to create a compatible DC and keep it around? I think you can't do this
because if I try, my program dies.

In essence, I have to draw on a bitmap and do a bitblt on a timer event. Given
this, I want to minimize processing during WM_TIMER. Ideally, I would have the
DC etc already setup. So how can I do this? Assuming that I can't keep a DC
around for very long, why won't CreateCompatibleDC create a compatible DC?

BTW, I called Microsloth, and the person who answered told me that there is not
support anymore for the SDK tech questions except through Online. Moreover, he
said I cannot (repeat cannot) even write a letter to tech support and expect a
reply at their leisure! Well, I guess my check for the SDK must have cleared,
eh? End of transaction. So, I turn to the collective expertise of net-x-perts!
Please help.

Thanks,

Milan.

bturner@hpcvlx.cv.hp.com (Bill Turner) (05/10/90)

> I have a probably trivial question. I need to do the following:
>
>     3) Then, on a timer event, I want to create a compatibleDC, select a
>        compatible bitmap into it, do some drawing, bitblt to the real DC
>        and get out.
>
>What I find is that when I call CreateCompatibleDC(hDC), the memory device
>context does not have any of the mapping mode information at all! The memory
>device context returns essentially a DC with the default settings!

The problem is your assumption about what a compatible DC is.  It is compatible
to the physical characteristics of a device specified by an existing DC (such
as pixels per inch, aspect ratio, number of colors, etc.), but not to the
currently selected attributes (which are changeable).

What you can do is, after creating the compatible DC, query the existing DC and
use those attributes to set the compatible DC state (or if the attributes are
constant, just set them).  Any time you create a DC, it comes up with the
default attributes (documented).

--Bill Turner (bturner@hp-pcd.hp.com)
HP Interface Technology Operation