/*
|
/*
|
Copyright (C) Chris Johns (ccj@acm.org)
|
Copyright (C) Chris Johns (ccj@acm.org)
|
|
|
Microwindows C++ Wrappers.
|
Microwindows C++ Wrappers.
|
|
|
*/
|
*/
|
|
|
#include <algorithm>
|
#include <algorithm>
|
#include <stdarg.h>
|
#include <stdarg.h>
|
#include <stdio.h>
|
#include <stdio.h>
|
#include <mwobjects.h>
|
#include <mwobjects.h>
|
|
|
namespace MicroWindowsObjects
|
namespace MicroWindowsObjects
|
{
|
{
|
|
|
static Application *the_application = 0;
|
static Application *the_application = 0;
|
|
|
WindowClass::WindowClass ()
|
WindowClass::WindowClass ()
|
{
|
{
|
wclass.style = CS_DBLCLKS | CS_VREDRAW | CS_HREDRAW;
|
wclass.style = CS_DBLCLKS | CS_VREDRAW | CS_HREDRAW;
|
wclass.lpfnWndProc = 0;
|
wclass.lpfnWndProc = 0;
|
wclass.lpfnWndProc = 0;
|
wclass.lpfnWndProc = 0;
|
wclass.cbClsExtra = 0;
|
wclass.cbClsExtra = 0;
|
wclass.cbWndExtra = 0;
|
wclass.cbWndExtra = 0;
|
wclass.hInstance = 0;
|
wclass.hInstance = 0;
|
wclass.hIcon = 0;
|
wclass.hIcon = 0;
|
wclass.hCursor = 0;
|
wclass.hCursor = 0;
|
wclass.hbrBackground = 0;
|
wclass.hbrBackground = 0;
|
wclass.lpszMenuName = 0;
|
wclass.lpszMenuName = 0;
|
wclass.lpszClassName = 0;
|
wclass.lpszClassName = 0;
|
}
|
}
|
|
|
WindowClass::WindowClass (LPCSTR lpszClassName,
|
WindowClass::WindowClass (LPCSTR lpszClassName,
|
UINT style,
|
UINT style,
|
int cbClsExtra,
|
int cbClsExtra,
|
int cbWndExtra,
|
int cbWndExtra,
|
HINSTANCE hInstance,
|
HINSTANCE hInstance,
|
HICON hIcon,
|
HICON hIcon,
|
HCURSOR hCursor,
|
HCURSOR hCursor,
|
HBRUSH hbrBackground,
|
HBRUSH hbrBackground,
|
LPCSTR lpszMenuName)
|
LPCSTR lpszMenuName)
|
{
|
{
|
wclass.style = style;
|
wclass.style = style;
|
wclass.lpfnWndProc = (WNDPROC) Window::WndProc;
|
wclass.lpfnWndProc = (WNDPROC) Window::WndProc;
|
wclass.cbClsExtra = cbClsExtra;
|
wclass.cbClsExtra = cbClsExtra;
|
wclass.cbWndExtra = cbWndExtra + sizeof (Window *);
|
wclass.cbWndExtra = cbWndExtra + sizeof (Window *);
|
wclass.hInstance = hInstance;
|
wclass.hInstance = hInstance;
|
wclass.hIcon = hIcon;
|
wclass.hIcon = hIcon;
|
wclass.hCursor = hCursor;
|
wclass.hCursor = hCursor;
|
wclass.hbrBackground = hbrBackground;
|
wclass.hbrBackground = hbrBackground;
|
wclass.lpszMenuName = lpszMenuName;
|
wclass.lpszMenuName = lpszMenuName;
|
wclass.lpszClassName = lpszClassName;
|
wclass.lpszClassName = lpszClassName;
|
}
|
}
|
|
|
ATOM WindowClass::register_class ()
|
ATOM WindowClass::register_class ()
|
{
|
{
|
return RegisterClass (&wclass);
|
return RegisterClass (&wclass);
|
}
|
}
|
|
|
Window::Window ()
|
Window::Window ()
|
: hwnd (0)
|
: hwnd (0)
|
{
|
{
|
}
|
}
|
|
|
Window::Window (DWORD dwExStyle,
|
Window::Window (DWORD dwExStyle,
|
LPCSTR lpClassName,
|
LPCSTR lpClassName,
|
LPCSTR lpWindowName,
|
LPCSTR lpWindowName,
|
DWORD dwStyle,
|
DWORD dwStyle,
|
int x,
|
int x,
|
int y,
|
int y,
|
int nWidth,
|
int nWidth,
|
int nHeight,
|
int nHeight,
|
HWND hwndParent,
|
HWND hwndParent,
|
HMENU hMenu,
|
HMENU hMenu,
|
HINSTANCE hInstance,
|
HINSTANCE hInstance,
|
LPVOID lpParam)
|
LPVOID lpParam)
|
: hwnd (0)
|
: hwnd (0)
|
{
|
{
|
create (dwExStyle,
|
create (dwExStyle,
|
lpClassName,
|
lpClassName,
|
lpWindowName,
|
lpWindowName,
|
dwStyle,
|
dwStyle,
|
x, y, nWidth, nHeight,
|
x, y, nWidth, nHeight,
|
hwndParent,
|
hwndParent,
|
hMenu,
|
hMenu,
|
hInstance,
|
hInstance,
|
lpParam);
|
lpParam);
|
}
|
}
|
|
|
Window::~Window ()
|
Window::~Window ()
|
{
|
{
|
destory ();
|
destory ();
|
}
|
}
|
|
|
HWND
|
HWND
|
Window::create (DWORD dwExStyle,
|
Window::create (DWORD dwExStyle,
|
LPCSTR lpClassName,
|
LPCSTR lpClassName,
|
LPCSTR lpWindowName,
|
LPCSTR lpWindowName,
|
DWORD dwStyle,
|
DWORD dwStyle,
|
int x,
|
int x,
|
int y,
|
int y,
|
int nWidth,
|
int nWidth,
|
int nHeight,
|
int nHeight,
|
HWND hwndParent,
|
HWND hwndParent,
|
HMENU hMenu,
|
HMENU hMenu,
|
HINSTANCE hInstance,
|
HINSTANCE hInstance,
|
LPVOID lpParam)
|
LPVOID lpParam)
|
{
|
{
|
lpCreateParams = lpParam;
|
lpCreateParams = lpParam;
|
|
|
lpParam = (LPVOID) this;
|
lpParam = (LPVOID) this;
|
|
|
hwnd = ::CreateWindowEx (dwExStyle,
|
hwnd = ::CreateWindowEx (dwExStyle,
|
lpClassName,
|
lpClassName,
|
lpWindowName,
|
lpWindowName,
|
dwStyle,
|
dwStyle,
|
x, y, nWidth, nHeight,
|
x, y, nWidth, nHeight,
|
hwndParent,
|
hwndParent,
|
hMenu,
|
hMenu,
|
hInstance,
|
hInstance,
|
lpParam);
|
lpParam);
|
return hwnd;
|
return hwnd;
|
}
|
}
|
|
|
BOOL
|
BOOL
|
Window::destory ()
|
Window::destory ()
|
{
|
{
|
if (hwnd)
|
if (hwnd)
|
{
|
{
|
HWND old_hwnd = hwnd;
|
HWND old_hwnd = hwnd;
|
hwnd = 0;
|
hwnd = 0;
|
return ::DestroyWindow (old_hwnd);
|
return ::DestroyWindow (old_hwnd);
|
}
|
}
|
return 0;
|
return 0;
|
}
|
}
|
|
|
bool
|
bool
|
Window::attach (const int fd, FileDescriptor& file_descriptor)
|
Window::attach (const int fd, FileDescriptor& file_descriptor)
|
{
|
{
|
//
|
//
|
// The user must set the fd before being added to the set.
|
// The user must set the fd before being added to the set.
|
//
|
//
|
|
|
if ((fd < 0) || (fd >= FD_SETSIZE) || (file_descriptor.file_desc != -1))
|
if ((fd < 0) || (fd >= FD_SETSIZE) || (file_descriptor.file_desc != -1))
|
return false;
|
return false;
|
|
|
//
|
//
|
// If this fd is already taken do not add another.
|
// If this fd is already taken do not add another.
|
//
|
//
|
|
|
file_descriptor.file_desc = fd;
|
file_descriptor.file_desc = fd;
|
file_descriptor.window = this;
|
file_descriptor.window = this;
|
|
|
if (file_descriptors.find (&file_descriptor) != file_descriptors.end ())
|
if (file_descriptors.find (&file_descriptor) != file_descriptors.end ())
|
{
|
{
|
file_descriptor.file_desc = -1;
|
file_descriptor.file_desc = -1;
|
file_descriptor.window = 0;
|
file_descriptor.window = 0;
|
return false;
|
return false;
|
}
|
}
|
|
|
file_descriptors.insert (&file_descriptor);
|
file_descriptors.insert (&file_descriptor);
|
|
|
return true;
|
return true;
|
}
|
}
|
|
|
bool
|
bool
|
Window::detach (FileDescriptor& file_descriptor)
|
Window::detach (FileDescriptor& file_descriptor)
|
{
|
{
|
//
|
//
|
// The user must set the fd before being added to the set.
|
// The user must set the fd before being added to the set.
|
//
|
//
|
|
|
if ((file_descriptor.fd () < 0) || (file_descriptor.fd () >= FD_SETSIZE))
|
if ((file_descriptor.fd () < 0) || (file_descriptor.fd () >= FD_SETSIZE))
|
return false;
|
return false;
|
|
|
//
|
//
|
// If this fd is already taken do not add another.
|
// If this fd is already taken do not add another.
|
//
|
//
|
|
|
if (file_descriptors.find (&file_descriptor) == file_descriptors.end ())
|
if (file_descriptors.find (&file_descriptor) == file_descriptors.end ())
|
return false;
|
return false;
|
|
|
file_descriptor.disable_read ();
|
file_descriptor.disable_read ();
|
file_descriptor.disable_write ();
|
file_descriptor.disable_write ();
|
file_descriptor.disable_except ();
|
file_descriptor.disable_except ();
|
|
|
file_descriptors.erase (&file_descriptor);
|
file_descriptors.erase (&file_descriptor);
|
|
|
file_descriptor.file_desc = -1;
|
file_descriptor.file_desc = -1;
|
file_descriptor.window = 0;
|
file_descriptor.window = 0;
|
|
|
return true;
|
return true;
|
}
|
}
|
|
|
struct eq_fd
|
struct eq_fd
|
{
|
{
|
const int fd;
|
const int fd;
|
eq_fd (const int fd) : fd (fd) {}
|
eq_fd (const int fd) : fd (fd) {}
|
bool operator() (const FileDescriptor* f1) const
|
bool operator() (const FileDescriptor* f1) const
|
{ return (f1->fd () == fd); }
|
{ return (f1->fd () == fd); }
|
};
|
};
|
|
|
LRESULT
|
LRESULT
|
Window::message_handler (UINT msg,
|
Window::message_handler (UINT msg,
|
WPARAM wp,
|
WPARAM wp,
|
LPARAM lp)
|
LPARAM lp)
|
{
|
{
|
switch (msg)
|
switch (msg)
|
{
|
{
|
case WM_FDINPUT:
|
case WM_FDINPUT:
|
case WM_FDOUTPUT:
|
case WM_FDOUTPUT:
|
case WM_FDEXCEPT:
|
case WM_FDEXCEPT:
|
|
|
{
|
{
|
//
|
//
|
// The iterator provides a reference to the object pointer
|
// The iterator provides a reference to the object pointer
|
// as the set contains pointers.
|
// as the set contains pointers.
|
//
|
//
|
|
|
set<FileDescriptor*>::iterator file_descriptor;
|
set<FileDescriptor*>::iterator file_descriptor;
|
|
|
file_descriptor = find_if (file_descriptors.begin (),
|
file_descriptor = find_if (file_descriptors.begin (),
|
file_descriptors.end (),
|
file_descriptors.end (),
|
eq_fd ((int) wp));
|
eq_fd ((int) wp));
|
|
|
if (file_descriptor != file_descriptors.end ())
|
if (file_descriptor != file_descriptors.end ())
|
{
|
{
|
switch (msg)
|
switch (msg)
|
{
|
{
|
case WM_FDINPUT:
|
case WM_FDINPUT:
|
return (*file_descriptor)->read ();
|
return (*file_descriptor)->read ();
|
|
|
case WM_FDOUTPUT:
|
case WM_FDOUTPUT:
|
return (*file_descriptor)->write ();
|
return (*file_descriptor)->write ();
|
|
|
case WM_FDEXCEPT:
|
case WM_FDEXCEPT:
|
return (*file_descriptor)->except ();
|
return (*file_descriptor)->except ();
|
}
|
}
|
}
|
}
|
}
|
}
|
break;
|
break;
|
|
|
default:
|
default:
|
break;
|
break;
|
}
|
}
|
|
|
return ::DefWindowProc (hwnd, msg, wp, lp);
|
return ::DefWindowProc (hwnd, msg, wp, lp);
|
}
|
}
|
|
|
bool
|
bool
|
Window::ltint::operator () (const FileDescriptor* f1,
|
Window::ltint::operator () (const FileDescriptor* f1,
|
const FileDescriptor* f2) const
|
const FileDescriptor* f2) const
|
{
|
{
|
return f1->fd () < f2->fd ();
|
return f1->fd () < f2->fd ();
|
}
|
}
|
|
|
LRESULT CALLBACK
|
LRESULT CALLBACK
|
Window::WndProc (HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
|
Window::WndProc (HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
|
{
|
{
|
int offset = GetClassLong (hwnd, GCL_CBWNDEXTRA) - sizeof (Window *);
|
int offset = GetClassLong (hwnd, GCL_CBWNDEXTRA) - sizeof (Window *);
|
Window *window = 0;
|
Window *window = 0;
|
|
|
if (msg == WM_CREATE)
|
if (msg == WM_CREATE)
|
{
|
{
|
LPCREATESTRUCT cs = (LPCREATESTRUCT) lp;
|
LPCREATESTRUCT cs = (LPCREATESTRUCT) lp;
|
|
|
window = dynamic_cast<Window*>((Window*) cs->lpCreateParams);
|
window = dynamic_cast<Window*>((Window*) cs->lpCreateParams);
|
|
|
if (window)
|
if (window)
|
{
|
{
|
window->hwnd = hwnd;
|
window->hwnd = hwnd;
|
SetWindowLong (hwnd, offset, (DWORD) window);
|
SetWindowLong (hwnd, offset, (DWORD) window);
|
cs->lpCreateParams = window->lpCreateParams;
|
cs->lpCreateParams = window->lpCreateParams;
|
}
|
}
|
}
|
}
|
else
|
else
|
{
|
{
|
window = dynamic_cast<Window*>((Window*) GetWindowLong (hwnd, offset));
|
window = dynamic_cast<Window*>((Window*) GetWindowLong (hwnd, offset));
|
}
|
}
|
|
|
if (window)
|
if (window)
|
return window->message_handler (msg, wp, lp);
|
return window->message_handler (msg, wp, lp);
|
|
|
return ::DefWindowProc (hwnd, msg, wp, lp);
|
return ::DefWindowProc (hwnd, msg, wp, lp);
|
}
|
}
|
|
|
Paint::Paint (HWND hwnd)
|
Paint::Paint (HWND hwnd)
|
: hwnd (hwnd),
|
: hwnd (hwnd),
|
draw_3d (false),
|
draw_3d (false),
|
drawing (false),
|
drawing (false),
|
r (0, 0, 0, 0),
|
r (0, 0, 0, 0),
|
text_format (0)
|
text_format (0)
|
{
|
{
|
}
|
}
|
|
|
Paint::Paint (HWND hwnd, LPARAM lpParam)
|
Paint::Paint (HWND hwnd, LPARAM lpParam)
|
: hwnd (hwnd),
|
: hwnd (hwnd),
|
draw_3d (false),
|
draw_3d (false),
|
drawing (false),
|
drawing (false),
|
r (0, 0, 0, 0),
|
r (0, 0, 0, 0),
|
text_format (0)
|
text_format (0)
|
{
|
{
|
POINTSTOPOINT (pt, lpParam);
|
POINTSTOPOINT (pt, lpParam);
|
}
|
}
|
|
|
Paint::~Paint ()
|
Paint::~Paint ()
|
{
|
{
|
end ();
|
end ();
|
}
|
}
|
|
|
void
|
void
|
Paint::begin (bool init_3d, bool draw_3d_in_mem)
|
Paint::begin (bool init_3d, bool draw_3d_in_mem)
|
{
|
{
|
if (!drawing && hwnd)
|
if (!drawing && hwnd)
|
{
|
{
|
hdc = ::BeginPaint (hwnd, &ps);
|
hdc = ::BeginPaint (hwnd, &ps);
|
|
|
r.get_client (hwnd);
|
r.get_client (hwnd);
|
|
|
if (init_3d)
|
if (init_3d)
|
initialise_3d (draw_3d_in_mem);
|
initialise_3d (draw_3d_in_mem);
|
|
|
drawing = true;
|
drawing = true;
|
}
|
}
|
}
|
}
|
|
|
void
|
void
|
Paint::end ()
|
Paint::end ()
|
{
|
{
|
if (drawing)
|
if (drawing)
|
{
|
{
|
paint_3d ();
|
paint_3d ();
|
|
|
::EndPaint (hwnd, &ps);
|
::EndPaint (hwnd, &ps);
|
|
|
drawing = false;
|
drawing = false;
|
}
|
}
|
}
|
}
|
|
|
int
|
int
|
Paint::text_out (int x, int y, const char *format, ...)
|
Paint::text_out (int x, int y, const char *format, ...)
|
{
|
{
|
Rect rect (x, y, x + 100, y + 100);
|
Rect rect (x, y, x + 100, y + 100);
|
va_list arg;
|
va_list arg;
|
|
|
va_start (arg, format);
|
va_start (arg, format);
|
vsnprintf (format_buf, TEXT_BUF_SIZE, format, arg);
|
vsnprintf (format_buf, TEXT_BUF_SIZE, format, arg);
|
format_buf[TEXT_BUF_SIZE - 1] = '\0';
|
format_buf[TEXT_BUF_SIZE - 1] = '\0';
|
|
|
return ::DrawText (hdc, format_buf, -1, rect, text_format);
|
return ::DrawText (hdc, format_buf, -1, rect, text_format);
|
}
|
}
|
|
|
FileDescriptor::FileDescriptor ()
|
FileDescriptor::FileDescriptor ()
|
: file_desc (-1),
|
: file_desc (-1),
|
window (0)
|
window (0)
|
{
|
{
|
}
|
}
|
|
|
FileDescriptor::~FileDescriptor ()
|
FileDescriptor::~FileDescriptor ()
|
{
|
{
|
if (window)
|
if (window)
|
window->detach (*this);
|
window->detach (*this);
|
}
|
}
|
|
|
bool
|
bool
|
FileDescriptor::enable_read ()
|
FileDescriptor::enable_read ()
|
{
|
{
|
if (!read_is_enabled && window && (file_desc != -1))
|
if (!read_is_enabled && window && (file_desc != -1))
|
{
|
{
|
::MwRegisterFdInput (*window, file_desc);
|
::MwRegisterFdInput (*window, file_desc);
|
read_is_enabled = true;
|
read_is_enabled = true;
|
return true;
|
return true;
|
}
|
}
|
return false;
|
return false;
|
}
|
}
|
|
|
bool
|
bool
|
FileDescriptor::disable_read ()
|
FileDescriptor::disable_read ()
|
{
|
{
|
if (read_is_enabled && window && (file_desc != -1))
|
if (read_is_enabled && window && (file_desc != -1))
|
{
|
{
|
::MwUnregisterFdInput (*window, file_desc);
|
::MwUnregisterFdInput (*window, file_desc);
|
read_is_enabled = false;
|
read_is_enabled = false;
|
return true;
|
return true;
|
}
|
}
|
return false;
|
return false;
|
}
|
}
|
|
|
|
|
bool
|
bool
|
FileDescriptor::enable_write ()
|
FileDescriptor::enable_write ()
|
{
|
{
|
if (!write_is_enabled && window && (file_desc != -1))
|
if (!write_is_enabled && window && (file_desc != -1))
|
{
|
{
|
::MwRegisterFdOutput (*window, file_desc);
|
::MwRegisterFdOutput (*window, file_desc);
|
write_is_enabled = true;
|
write_is_enabled = true;
|
return true;
|
return true;
|
}
|
}
|
return false;
|
return false;
|
}
|
}
|
|
|
bool
|
bool
|
FileDescriptor::disable_write ()
|
FileDescriptor::disable_write ()
|
{
|
{
|
if (write_is_enabled && window && (file_desc != -1))
|
if (write_is_enabled && window && (file_desc != -1))
|
{
|
{
|
::MwUnregisterFdOutput (*window, file_desc);
|
::MwUnregisterFdOutput (*window, file_desc);
|
write_is_enabled = false;
|
write_is_enabled = false;
|
return true;
|
return true;
|
}
|
}
|
return false;
|
return false;
|
}
|
}
|
|
|
bool
|
bool
|
FileDescriptor::enable_except ()
|
FileDescriptor::enable_except ()
|
{
|
{
|
if (!except_is_enabled && window && (file_desc != -1))
|
if (!except_is_enabled && window && (file_desc != -1))
|
{
|
{
|
::MwRegisterFdExcept (*window, file_desc);
|
::MwRegisterFdExcept (*window, file_desc);
|
except_is_enabled = true;
|
except_is_enabled = true;
|
return true;
|
return true;
|
}
|
}
|
return false;
|
return false;
|
}
|
}
|
|
|
bool
|
bool
|
FileDescriptor::disable_except ()
|
FileDescriptor::disable_except ()
|
{
|
{
|
if (except_is_enabled && window && (file_desc != -1))
|
if (except_is_enabled && window && (file_desc != -1))
|
{
|
{
|
::MwUnregisterFdExcept (*window, file_desc);
|
::MwUnregisterFdExcept (*window, file_desc);
|
except_is_enabled = false;
|
except_is_enabled = false;
|
return true;
|
return true;
|
}
|
}
|
return false;
|
return false;
|
}
|
}
|
|
|
LRESULT
|
LRESULT
|
FileDescriptor::read ()
|
FileDescriptor::read ()
|
{
|
{
|
return 0;
|
return 0;
|
}
|
}
|
|
|
LRESULT
|
LRESULT
|
FileDescriptor::write ()
|
FileDescriptor::write ()
|
{
|
{
|
return 0;
|
return 0;
|
}
|
}
|
|
|
LRESULT
|
LRESULT
|
FileDescriptor::except ()
|
FileDescriptor::except ()
|
{
|
{
|
return 0;
|
return 0;
|
}
|
}
|
|
|
Application::Application ()
|
Application::Application ()
|
: background (0)
|
: background (0)
|
{
|
{
|
if (!the_application)
|
if (!the_application)
|
the_application = this;
|
the_application = this;
|
}
|
}
|
|
|
Application::Application (MWIMAGEHDR& background)
|
Application::Application (MWIMAGEHDR& background)
|
: background (&background)
|
: background (&background)
|
{
|
{
|
if (!the_application)
|
if (!the_application)
|
the_application = this;
|
the_application = this;
|
}
|
}
|
|
|
Application::~Application ()
|
Application::~Application ()
|
{
|
{
|
}
|
}
|
|
|
int
|
int
|
Application::initialise ()
|
Application::initialise ()
|
{
|
{
|
return 0;
|
return 0;
|
}
|
}
|
|
|
int
|
int
|
Application::shutdown ()
|
Application::shutdown ()
|
{
|
{
|
return 0;
|
return 0;
|
}
|
}
|
|
|
int WINAPI
|
int WINAPI
|
Application::WinMain (HINSTANCE hInstance,
|
Application::WinMain (HINSTANCE hInstance,
|
HINSTANCE hPrevInstance,
|
HINSTANCE hPrevInstance,
|
LPSTR lpCmdLine,
|
LPSTR lpCmdLine,
|
int nShowCmd)
|
int nShowCmd)
|
{
|
{
|
if (the_application)
|
if (the_application)
|
{
|
{
|
int result;
|
int result;
|
|
|
MwRegisterButtonControl (0);
|
MwRegisterButtonControl (0);
|
|
|
result = the_application->initialise ();
|
result = the_application->initialise ();
|
|
|
if (result)
|
if (result)
|
return result;
|
return result;
|
|
|
//
|
//
|
// Set background wallpaper
|
// Set background wallpaper
|
//
|
//
|
|
|
if (the_application->background)
|
if (the_application->background)
|
MwSetDesktopWallpaper (the_application->background);
|
MwSetDesktopWallpaper (the_application->background);
|
|
|
MSG msg;
|
MSG msg;
|
|
|
//
|
//
|
// type ESC to quit...
|
// type ESC to quit...
|
//
|
//
|
|
|
while (GetMessage (&msg, 0, 0, 0))
|
while (GetMessage (&msg, 0, 0, 0))
|
{
|
{
|
TranslateMessage (&msg);
|
TranslateMessage (&msg);
|
DispatchMessage (&msg);
|
DispatchMessage (&msg);
|
}
|
}
|
|
|
result = the_application->shutdown ();
|
result = the_application->shutdown ();
|
|
|
if (result)
|
if (result)
|
return result;
|
return result;
|
|
|
return 0;
|
return 0;
|
}
|
}
|
|
|
return 1;
|
return 1;
|
}
|
}
|
|
|
};
|
};
|
|
|
//
|
//
|
// Global Microwindows WinMain () routine with "C" linkage
|
// Global Microwindows WinMain () routine with "C" linkage
|
//
|
//
|
|
|
extern "C"
|
extern "C"
|
{
|
{
|
int WinMain (HINSTANCE hInstance,
|
int WinMain (HINSTANCE hInstance,
|
HINSTANCE hPrevInstance,
|
HINSTANCE hPrevInstance,
|
LPSTR lpCmdLine,
|
LPSTR lpCmdLine,
|
int nShowCmd)
|
int nShowCmd)
|
{
|
{
|
return MicroWindowsObjects::Application::WinMain (hInstance,
|
return MicroWindowsObjects::Application::WinMain (hInstance,
|
hPrevInstance,
|
hPrevInstance,
|
lpCmdLine,
|
lpCmdLine,
|
nShowCmd);
|
nShowCmd);
|
}
|
}
|
};
|
};
|
|
|