I program using Win32 API's. I compile with Borland or Microsoft "CL".
I am on an XP machine. I use .cpp extensions to compile so C++ rules apply.

I'm trying to get the bytes from my screen and send them to a disk file.
I get a handle I call "MemDC" from the CreateCompatibleDC, use it in
a CreateDIBSection. I select the DIB into the "MemDC, then blit the
screenDC to MemDC. That works fine. I can blit it to hDC and repaint
it back to my screen as a test. No problem, that works.

My problem begins because the system sends the bytes to memory that I
can't seem to get to. I GlobalAlloc for "MyBits" with "ppvBits" pointing
to "MyBits" in DIBSection. I believe this is right. The blit "on my
machine" sends the bytes to 0x008F0020. "MyBits" on the heap starts
at 0x00820020 waiting for the bytes to come in. The bytes go to where
the system wants to send them. I accept that, but need them in "MyBits".

1. I don't know why DIBSection doesn't get "MyBits" filled in.

2. I can't memcpy from MemDC(0x008F0020) to MyBits(0x00800020)
because I don't know how to use the assigned DC handle to "MemDC" in
memcpy, as the memcpy source. Sorry, if I should know, I don't. I
thought I did, but nothing worked.

3. I tried to GlobalAlloc memory with "MemDC" as the pointer. I get
a DWORD pointer assigned to "MemDC" on GlobalLock but when
CreateCompatibleDC gets its handle, the handle does all the
work, not the pointer to the heap that I assigned. My heap section
with the DWORD pointer "MemDC" pointing to the assigned heap area
just sits there just like the area where "MyBits" points. The
blit ignores the "MemDC" pointer and plops the bytes where it
wants them.

I'll take any of three solutions. Since I have the bytes, memcpy
seems like a good way if I can find out how to use the handle to
"MemDC" as a source. I don't know why when blitting, DIB doesn't
get "MyBits" filled in. That would do the trick too. Lastly, I
considered using a Union but I'll bet I'd have trouble getting
the bytes into the Union. There must be an easy way to do this
but I'm having trouble seeing the trees because the forest
keeps getting in the way.

Thanks for the thread. It looks interesting. I have only given it a quick scan so far. I will carefully look it over in the next day or so and see if it solves the problem.

This question has already been answered. Start a new discussion instead.