Crear una ventana dentro de un cuadro de dialogo

yolanda
28 de Mayo del 2004
Como crear una ventana para dibujar una grafica, dentro de un cuadro de dialogo, al pulsar un control buttom en visual c++

Mariano Ventaja
28 de Mayo del 2004
El chiste esta en crear un DC para hacer double buffer, entonces vas pintando todo lo necesario en ese DC y despues haces un BitBlt en el DC del Dialogo (lo podes obtener haciendo GetDC(HWND). Con esto logras que no se pinten diferentes objetos en diferentes momentos, osea todo se va pintar al mismo tiempo porque vos vas usando un buffer que despues volcas en la pantalla real.

Este es un ejemplo de la MSDN:
// Create a normal DC and a memory DC for the entire screen. The
// normal DC provides a "snapshot" of the screen contents. The
// memory DC keeps a copy of this "snapshot" in the associated
// bitmap.

hdcScreen = CreateDC("DISPLAY", NULL, NULL, NULL);
hdcCompatible = CreateCompatibleDC(hdcScreen);

// Create a compatible bitmap for hdcScreen.

hbmScreen = CreateCompatibleBitmap(hdcScreen,
GetDeviceCaps(hdcScreen, HORZRES),
GetDeviceCaps(hdcScreen, VERTRES));

if (hbmScreen == 0)
errhandler("hbmScreen", hwnd);

// Select the bitmaps into the compatible DC.

if (!SelectObject(hdcCompatible, hbmScreen))
errhandler("Compatible Bitmap Selection", hwnd);

// Hide the application window.

ShowWindow(hwnd, SW_HIDE);

//Copy color data for the entire display into a
//bitmap that is selected into a compatible DC.

if (!BitBlt(hdcCompatible,
0,0,
bmp.bmWidth, bmp.bmHeight,
hdcScreen,
0,0,
SRCCOPY))

errhandler("Screen to Compat Blt Failed", hwnd);

// Redraw the application window.

ShowWindow(hwnd, SW_SHOW);

Saludos,
Mariano http://www.c0d3rz.com.ar