#include <windows.h>
//////////
//
// DX8 dx8 + fmod + cfl tutorial
// Jari Komppa 2001
char progname[]="DX8+FMOD+CFL tutorial - Sol";
// Window procedure.. this function gets all the window messages.
// (note that clicking on the top left corner 'x' may go directly here
// and skip winmain() loop completely!)
LRESULT CALLBACK WindowProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
switch (uMsg) {
case WM_KEYDOWN:
switch( wParam ) {
case VK_ESCAPE:
case VK_F12:
// if escape or f12 is pressed, post kill message to us.
PostMessage(hWnd, WM_CLOSE, 0, 0);
break;
}
case WM_DESTROY:
// kill message received, post quit one, clean up and quit.
PostQuitMessage(0);
exit(wParam);
break;
default:
// rest of the messages may do whatever they do by default.
return DefWindowProc (hWnd, uMsg, wParam, lParam) ;
break;
}
return 0;
}
// Windows main function. Set up window, set up dx, call setup to set up the rest
// and finally do the rendering loop.
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpszCmdLine, int nCmdShow)
{
WNDCLASSEX winclass;
HWND hWnd;
MSG msg;
// Create window class
winclass.cbSize=sizeof(WNDCLASSEX);
winclass.style=CS_DBLCLKS;
winclass.lpfnWndProc=&WindowProc;
winclass.cbClsExtra=0;
winclass.cbWndExtra=0;
winclass.hInstance=hInst;
winclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
winclass.hCursor=LoadCursor(NULL,IDC_ARROW);
winclass.hbrBackground=GetSysColorBrush(COLOR_APPWORKSPACE);
winclass.lpszMenuName=NULL;
winclass.lpszClassName=progname;
winclass.hIconSm=NULL;
// I don't know if this can ever fail, really:
if (!RegisterClassEx(&winclass)) return 0;
// Create a 640 by 480 window (note that the client area will be somewhat smaller!)
hWnd=CreateWindow(progname,progname,WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,0,640,480,NULL,NULL,hInst,NULL);
// Show the window
ShowWindow(hWnd,nCmdShow);
// Main rendering loop.
while (1) {
// Check the windows messages and process them.
if(PeekMessage(&msg,hWnd,0,0,PM_REMOVE)) {
WindowProc(hWnd,msg.message,msg.wParam,msg.lParam);
}
}
// This line is never reached:
return 0;
}