[SDL] How to integrate SDL as a child Window
L-28C
kixdemp at gmail.com
Sat Nov 17 06:08:23 PST 2007
I found this too:
http://www.geocities.com/egon_rath/sdl_inside_winform.html
I'll try to translate it into C and see how it works out... :P
Edward Byard wrote:
> Well found! I will have a play with this later, but not sure how it'll
> do with Vista :-)
>
>
>
> ----- Original Message ----
> From: L-28C <kixdemp at gmail.com>
> To: sdl at libsdl.org
> Sent: Thursday, 15 November, 2007 12:07:09 PM
> Subject: Re: [SDL] How to integrate SDL as a child Window
>
> 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/
> <http://www.polplex.co.uk/%7Etigger/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)
>
> ----------<code/>---------
> 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;
> ---------</code>----------
>
> 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 <mine260309 at gmail.com <mailto:mine260309 at gmail.com>>
> > To: A list for developers using the SDL library. (includes SDL-announce)
> > <sdl at lists.libsdl.org <mailto:sdl at lists.libsdl.org>>
> > Sent: Thursday, 15 November, 2007 7:35:30 AM
> > Subject: [SDL] How to integrate SDL as a child Window
> >
> > Hi 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 <mailto:SDL at lists.libsdl.org>
> > http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org <mailto:SDL at lists.libsdl.org>
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>
>
> ------------------------------------------------------------------------
> Yahoo! Answers - Get better answers from someone who knows. Try it now
> <http://uk.answers.yahoo.com/;_ylc=X3oDMTEydmViNG02BF9TAzIxMTQ3MTcxOTAEc2VjA21haWwEc2xrA3RhZ2xpbmU>.
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
More information about the SDL
mailing list