views:

393

answers:

1

I'm building a Delphi component to embed an SDL rendering surface on a VCL form. It works just fine as long as the form is on-screen at the moment that the SDL surface is created. Otherwise, it's not able to create any rendering textures.

I traced into the SDL code and ended up with the following function call, which fails (returns NULL):

data->hbm = CreateDIBSection(renderdata->memory_hdc, bmi, DIB_RGB_COLORS, &data->pixels, NULL, 0);

The HDC is a valid handle to the drawing context owned by a control that has its own HWND window handle, that's been set up properly. But when the control is created offscreen, which commonly happens in Delphi, (all forms, with their controls, are created in a hidden state until it's time to display them,) the CreateDIBSection call will fail until the control is actually visible.

Also, if it's created onscreen, then hidden and re-shown (if it's on a tab sheet and I switch tabs, for example,) any textures I create get blanked during this process.

This is driving me nuts. Anyone know what's going on and how I can work around it?

A: 

Just an idea.... Have you watched the window Handle? Isn't it butchered and recreated?

François
Nope. DestroyWnd never gets called.
Mason Wheeler