Using MFC with an SDL window?

I am sure this has been asked before many times, but I am unable to download
87 megs of past postings - so here goes :wink:

Can I use SDL to give me a hardware accelerated window within a conventional
MFC / VB or WIN32 application. I am planning on using SDL for raster map
loading and display from within a GIS application - I need the look and feel
of a native Win32 application with the benefits of SDL.

PS.

Does anyone know if someone has implemented something similar to a cross
platform GDI+ using OpenGl ?

Thanks

Hello Steve,

Friday, January 10, 2003, 7:10:32 PM, you wrote:

CS> I am sure this has been asked before many times, but I am unable to download
CS> 87 megs of past postings - so here goes :wink:

CS> Can I use SDL to give me a hardware accelerated window within a conventional
CS> MFC / VB or WIN32 application. I am planning on using SDL for raster map
CS> loading and display from within a GIS application - I need the look and feel
CS> of a native Win32 application with the benefits of SDL.

Ehm, http://www.maccormack.net/~djm/sdl_win32_demo/ .

And a question to everybody else:

This demo tries to create 640x480 window.
It creates window with height 480 + title bar height but SDL only
shows 480 - menu bar height. Is it possible to adjust creation
settings in some way, so we’ll see all 480 pixels on the screen
instead of 480 - menu bar height? I’m using WinAPI in my old branch of
game and I’ve started major rewrite of the code leaving old branch to
die but I want to fix such bug since I’m initing 320x240 window and
SDL output window (which is only 218-222 pixels instead of 240) looks
very bad - my 18 lines are not visible!

Look here:
correct:

incorrect:

You can see bottom ~18 lines missing in 021218_2.png image.

If I will initialise window in resolution like 320x260 that problem
will be solved, but anyway, it’s not the solution, since I will have
to handle 2 different resolutions - windoed (240+~20) and
fullscreen (240). If I’ll try to make screenshots in
windowed mode they will be 320x260… Too much problems.

I need a solution, thanks.–
Lynx,
http://dotNet.lv mailto:@Anatoly_R

Anatoly,

This proved to be an interesting one to track down :). In
./src/video/wincommon/SDL_systevents.c, in the code that handles
WM_GETMINMAXINFO, you’ll see the following:

AdjustWindowRect(&size, GetWindowLong(hwnd, GWL_STYLE), FALSE);

That ``FALSE’’ basically says “I don’t have a menu” (which may or may not
be true, depending on how you create the window). The attached patch
should do the trick.

DaveOn Fri, 10 Jan 2003, Anatoly R. wrote:

And a question to everybody else:

This demo tries to create 640x480 window.
It creates window with height 480 + title bar height but SDL only
shows 480 - menu bar height. Is it possible to adjust creation
settings in some way, so we’ll see all 480 pixels on the screen
instead of 480 - menu bar height? I’m using WinAPI in my old branch of
game and I’ve started major rewrite of the code leaving old branch to
die but I want to fix such bug since I’m initing 320x240 window and
SDL output window (which is only 218-222 pixels instead of 240) looks
very bad - my 18 lines are not visible!

Look here:
correct:
http://bgs.sourceforge.net/screens-0.7-rc1/warsaw_0_0_1900_65984.png
incorrect:
http://bgs.sourceforge.net/screens/021218_2.png

You can see bottom ~18 lines missing in 021218_2.png image.

If I will initialise window in resolution like 320x260 that problem
will be solved, but anyway, it’s not the solution, since I will have
to handle 2 different resolutions - windoed (240+~20) and
fullscreen (240). If I’ll try to make screenshots in
windowed mode they will be 320x260… Too much problems.

I need a solution, thanks.


David MacCormack
@David_MacCormack

:wq
damn!

-------------- next part --------------
*** src/video/wincommon/SDL_sysevents.c 2002/08/20 05:59:31 1.22
— src/video/wincommon/SDL_sysevents.c 2003/01/12 03:30:32


*** 396,401 ****
— 396,402 ----
MINMAXINFO *info;
RECT size;
int x, y;

  •   	int style;
      	int width;
      	int height;
    

*** 424,431 ****
size.bottom = 0;
size.right = 0;
}
! AdjustWindowRect(&size, GetWindowLong(hwnd, GWL_STYLE),
! FALSE);
width = size.right - size.left;
height = size.bottom - size.top;

— 425,443 ----
size.bottom = 0;
size.right = 0;
}
!
! /* DJM - according to the docs for GetMenu(), the
! return value is undefined if hwnd is a child window.
! Aparently it’s too difficult for MS to check
! inside their function, so I have to do it here.
! */
! style = GetWindowLong(hwnd, GWL_STYLE);
! AdjustWindowRect(
! &size,
! style,
! style & WS_CHILDWINDOW ? FALSE
! : GetMenu(hwnd) != NULL);
!
width = size.right - size.left;
height = size.bottom - size.top;

Anatoly,

This proved to be an interesting one to track down :). In
./src/video/wincommon/SDL_systevents.c, in the code that handles
WM_GETMINMAXINFO, you’ll see the following:

AdjustWindowRect(&size, GetWindowLong(hwnd, GWL_STYLE), FALSE);

That ``FALSE’’ basically says “I don’t have a menu” (which may or may not
be true, depending on how you create the window). The attached patch
should do the trick.

Thanks! I’ve applied your patch to CVS.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment