iBinx Corp.
contact usshisen-sho

Source listing: shisen.cpp. Return to the main page

/* -*- C++ -*-
 *******************************************************************
 *
 *
 * Shisen-Sho for Windows
 *
 * shisen.cpp - Entry point for the application
 *
 *
 *******************************************************************
 *
 * A japanese game similar to mahjongg
 *
 *******************************************************************
 *
 * Created 2000-12-28 by Jim Mason <jmason@sirius.com>
 *
 * Game engine ported from Mario Weilguni's <mweilguni@sime.com>
 * original game for KDE, KSHISEN.  If you are interested in the
 * KDE version of the game, see http://www.kde.org/kdegames/
 *
 *******************************************************************
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; see the file COPYING.  If not, write to
 * the Free Software Foundation, 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 *
 *******************************************************************
 */

#include "stdafx.h"
#include "shisen.h"

Frame App::m_frame;
Registry App::m_profile;
HINSTANCE App::m_hInst;
CStdString App::m_szTitle;

// Mainline
int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow) {
    MSG msg;
    HACCEL hAccelTable;

    // Perform application initialisation
    if(!App::InitInstance(hInstance, nCmdShow)) {
        return FALSE;
    }

    // Load accelerator table
    hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDR_MAINFRAME);

    // Main message loop:
    while(GetMessage(&msg, NULL, 0, 0)) {
        if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { 
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }

    return msg.wParam;
}

BOOL App::InitInstance(HINSTANCE hInstance, int nCmdShow) {
    // Initialize title bar text
    m_szTitle.LoadString(IDR_MAINFRAME);

    // Store application instance
    m_hInst = hInstance;

    // Setup registry access
    m_profile.SetRegistryKey(m_szTitle, _T("Games"));

    // Create the frame
    RECT rc;
    SetRect(&rc, CW_USEDEFAULT, 0, 0, 0);
    m_frame.Create(0, m_szTitle, m_szTitle, WS_OVERLAPPEDWINDOW &
                    ~(WS_MAXIMIZEBOX | WS_THICKFRAME),
                    rc, NULL, 0);

    // Call MoveWindow to force WM_GETMINMAXINFO.  This will resize the
    // frame to the correct size for the board.
    RECT rcWnd;
    m_frame.GetWindowRect(&rcWnd);
    m_frame.MoveWindow(rcWnd, TRUE);

    // Realise the frame
    m_frame.ShowWindow(nCmdShow);
    m_frame.UpdateWindow();

    return TRUE;
}
<< Back to Shisen-Sho