yueyue:
这里是MSDN里关于
CreateCompatibleDC的说明
The CreateCompatibleDC function creates a memory device context (DC) compatible with the specified device.
HDC CreateCompatibleDC(
HDC hdc // handle to DC
);
A memory DC exists only in memory. When the memory DC is created, its display surface is exactly one monochrome pixel wide and one monochrome pixel high. Before an application can use a memory DC for drawing operations, it must select a bitmap of the correct width and height into the DC. To select a bitmap into a DC, use the CreateCompatibleBitmap function, specifying the height, width, and color organization required.
仔细看一下就说明你发生的现象是很正常的了
用CreateCompatibleDC建立内存DC后
必须用CreateCompatibleBitmap建立一个与这个DC兼容的Bitmap
你另外建一个Bitmap,然后SelectObject当然不对了。
另外CreateCompatibleDC创建的位图是单色的是很正常的
文档不是里清清楚楚的写着么。 :)
When the memory DC is created, its display surface is exactly one monochrome pixel wide and one monochrome pixel high.
To jally:
请看我的上一贴;
To Kenny:
看来我还得声明一下(可惜不能用软驱,否则我一定将源程序贴上):
1。你不认为选入DC时的返回值有用吗?最起码它表明了你的程序执行正确与否。
2。选出的指针pOldBitmap,最终要选入,如果它选出的时候为空,那么选入后返
回的pBitmap必然为空,而我正要用到这个指针pBitmap。你说我能不担心吗?程序正是在这里出错。