Wow… I came here to ask that same question, and this was at the top of
the list… What a coincidence. O_O
Anyway, Mr. Byard, you might be wrong:
http://www.polplex.co.uk/~tigger/sdl/
And I say “might” because I tried a modified (non-C++) version and it
crashes after the first call to SDL_BlitSurface… Here’s my code:
(Note that I did put error checks on stuff like SDL_CreateRGBSurface, I
just removed it to make the code shorter)
-------------------
int bmsize;
HDC dc = GetDC(g_WindowHandle);
BITMAPINFO *bmi;
BITMAPINFOHEADER bh;
WNDCLASSEX wc;
/* Create the window */
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = a_hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wc.lpszMenuName = NULL;
wc.lpszClassName = "scorchWindowClass";
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
g_WindowHandle = CreateWindowEx(
WS_EX_CLIENTEDGE,
"scorchWindowclass",
"YASEC = Yet Another Scorched Earth Clone",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, a_Width, a_Height,
NULL, NULL, a_hInstance, NULL);
ShowWindow(g_WindowHandle, a_CmdShow);
UpdateWindow(g_WindowHandle);
/* Create the surface */
g_Screen =
SDL_CreateRGBSurface(SDL_SWSURFACE, a_Width, a_Height, SCR_DEPTH, 0,
0, 0, 0);
/* Get width and height */
g_ScreenWidth = g_Screen->w;
g_ScreenHeight = g_Screen->h;
bmsize = sizeof(BITMAPINFO);
if(g_Screen->format->palette)
{
bmsize += g_Screen->format->palette->ncolors *
sizeof(RGBQUAD);
}
else
{
bmsize += 3*sizeof(DWORD);
}
bmi = (BITMAPINFO*)malloc(bmsize);
/* Clear struct */
memset((void*)&bh, 0, sizeof(BITMAPINFOHEADER));
/* Initialize struct */
bh.biSize = sizeof(BITMAPINFOHEADER);
bh.biWidth = g_Screen->w;
bh.biHeight = -g_Screen->h; /* -ve for topdown bitmap */
bh.biPlanes = 1;
bh.biSizeImage = g_Screen->h * g_Screen->pitch;
bh.biXPelsPerMeter = 0;
bh.biYPelsPerMeter = 0;
bh.biClrUsed = 0;
bh.biClrImportant = 0;
bh.biBitCount = g_Screen->format->BitsPerPixel;
bh.biCompression = BI_BITFIELDS;
bmi->bmiHeader=bh;
((Uint32*)bmi->bmiColors)[0] = g_Screen->format->Rmask;
((Uint32*)bmi->bmiColors)[1] = g_Screen->format->Gmask;
((Uint32*)bmi->bmiColors)[2] = g_Screen->format->Bmask;
g_WindowBitmap = CreateDIBSection(dc, bmi, DIB_RGB_COLORS,
(void **)(&g_Screen->pixels), NULL, 0);
/* Free memory */
free(bmi);
ReleaseDC(g_WindowHandle, dc);
return 0;
-------------------
Any ideas? Thanks!
Edward Byard wrote:> Short answer is; no.
It would be very useful but SDL 1.2 can’t do this; fingers crossed for
1.3…----- Original Message ----
From: Mine
To: A list for developers using the SDL library. (includes SDL-announce)
Sent: Thursday, 15 November, 2007 7:35:30 AM
Subject: [SDL] How to integrate SDL as a child WindowHi All,
I’m using SDL on Windows XP. And I want to use it as a child window
in my application.
There is a new window created by SetVideoMode, is there any way to
set it as my application’s child window instead of a stand alone window?
That is to say, I want it to have no task bar, no title bar (this is OK
by SDL_NOFRAME), when the focus is in SDL window, the application’s main
windows is also focused.
Is there a way to implement that?Mine
For ideas on reducing your carbon footprint visit Yahoo! For Good
http://uk.promotions.yahoo.com/forgood/environment.html this month.
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org