Steps to create a window using API
NOTE on WNDPROC:
WndProc is a pain to use in a
class. It has to be defined as static so that a this* is not passed to
it, since its supposed to be a C function. Unlike TimerEvents which allow
a user to pass a custom variable as an added argument. TimerEvents will
be discussed later. This extra argument can be used as a ptr to the functions
owning class. Many different ways of getting around WndProc's problems
have been discussed on Dejanews and
your welcome to look there for more info. One way is to have a global ptr
to the class, which your WndProc can use to access public variables. Private
var access is another matter though and much more of a hassle, though.
It should be defined something like the following
static long WINAPI WindowProc(HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam )
To Register Window:
simply call RegisterClass( &your_wndclass );
To Create Window:
call CreateWindowEx( ); you should capture the returned HWND and save
it because DirectX needs it to initialize the DirectDraw Object. I perfer
to keep the window creation as simple as possible, so I create a popup
the size of the screen. I get the screen size using GetSystemMetrics( );
lookup these functions for more info
Showing and Updating Window:
very easy simply call
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
Thats all there is to it and it is easy to build a class around this
from which your individual programs can inherit from. If you need help
on this email me, but you shouldn't need any.