[SDL] Re: stdout.txt and stderr.txt

Kelly Ashe kashe at tbcdsb.on.ca
Wed Apr 5 20:25:53 PDT 2000

Actually, all you need is the hInstance that used to be passed in
WinMain, and save the HWND where DX functions can read it. The relevant
parts of the code to create a window in a console app follow.

// Global
HWND gWinHandle; // DX functions will need this

BOOL InitOS(CHAR * appName)
  HANDLE hInstance;
  WNDCLASS wndClass;

// hInstance usually passed into WinMain  

  wndClass.style = CS_DBLCLKS;
  wndClass.lpfnWndProc = WindowProc;
  wndClass.cbClsExtra = 0;
  wndClass.cbWndExtra = 0;
  wndClass.hInstance = hInstance;
  wndClass.hIcon = LoadIcon(hInstance, IDI_APPLICATION);
  wndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
  wndClass.hbrBackground = NULL;
  wndClass.lpszMenuName = appName;
  wndClass.lpszClassName = appName;

// Create the window like you normally would:
  gWinHandle=CreateWindowEx(WS_EX_TOPMOST, appName, appName,
                            NULL, NULL, hInstance, NULL);

// Set focus and show window like usual.....

} // InitOS


vining at pacificcoast.net wrote:
> >I used to develop all my Win32/DX applications as console applications to
> >get quick and dirty stderr messages while debugging. Another benefit is
> >that you also can get rid of WinMain() and just use main(). I don't know
> >what is the difference really is between a Console/Win32 app, but had
> >absolutely no problems compiling/running DX apps as a console app. As far
> >as I can remember (have been using SDL and not Win32/DX directly for quite
> >a while now), you just have to retrieve a couple values (HWND is one I
> >think) with calls to the Windows API since these values are not passed to
> >WinMain anymore. I can post the code if anyone is interested.
> Go for it. This calls for further experimentation.
> >Kelly
> Nicholas

More information about the SDL mailing list