SOL9 2.0 Class: AppEntry

 SOL9 C++ Class Library  SOL9 Samples  SOL9 Tutorial  SOL9 FAQ  SOL9 ClassTree 

Source code

/*
 * AppEntry.h 
 * Copyright (c) 2009 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. 
 */


//SOL9
// 2009/11/04 Modified to define AppEntry c++ class and use it in _tWinMain. 

#pragma once

#include <sol\Application.h>
#include <sol\CommandLine.h>
#define _MAX_ARG  100

#include <tchar.h>
//2009/11/04
#include <vfw.h>
#pragma comment(lib, "vfw32.lib")

namespace SOL {

class AppEntry {

private:
    HINSTANCE  richEdit;

public:
    AppEntry(HINSTANCE progIns)
    :richEdit(NULL)
    {
        //1 Load RichEdit dll
        richEdit = ::LoadLibrary(_T("RICHED32.DLL"));

        //2 Initialize CommonControl
        InitCommonControls();    
        
        INITCOMMONCONTROLSEX ic;
        memset(&ic, 0, sizeof(ic));
        ic.dwSize = sizeof(ic);
        ic.dwICC  =
        ICC_LISTVIEW_CLASSES| // listview, header
        ICC_TREEVIEW_CLASSES| // treeview, tooltips
        ICC_BAR_CLASSES     | // toolbar, statusbar, trackbar, tooltips
        ICC_TAB_CLASSES     | // tab, tooltips
        ICC_UPDOWN_CLASS    | // updown
        ICC_PROGRESS_CLASS  | // progress
        ICC_HOTKEY_CLASS    | // hotkey
        ICC_ANIMATE_CLASS   | // animate
        ICC_WIN95_CLASSES   | 
        ICC_DATE_CLASSES    | // month picker, date picker, time picker, updown
        ICC_USEREX_CLASSES  | // comboex
        ICC_INTERNET_CLASSES| // IP address field  1999.08.14
        ICC_COOL_CLASSES    |     // rebar (coolbar) control
        ICC_PAGESCROLLER_CLASS|     // PageScroller 
        ICC_NATIVEFNTCTL_CLASS|     //   NativeFon
        ICC_STANDARD_CLASSES|         //   Standard  
        ICC_LINK_CLASS;            //Link

        //3 Initialize Extended CommonControl

        InitCommonControlsEx(&ic);    

        // For socket library
        WSADATA wsaData;
        //4 Initialize Socket module
        if (WSAStartup(MAKEWORD(2, 2), &wsaData)) {
            MessageBox(NULL, _T("Could not load Windows Sockets DLL."), 
                    _T("SOL9"), MB_OK|MB_ICONSTOP);
        }            
        //4 Initialize(register) MCI(Media Control Interface) window class
        MCIWndRegisterClass(); //
    }
public:
    ~AppEntry()
    {
        FreeLibrary(richEdit);
        WSACleanup();
    }
};

}

//////////////////////////////////////////////////////////
//
// WinMain
int WINAPI _tWinMain(HINSTANCE progIns, HINSTANCE prevIns, 
            LPTSTR cmdLine, int cmdShow)
{
    AppEntry appEntry(progIns);
    {
        int argc = 0;
        TCHAR* argv[_MAX_ARG];
        TCHAR module[_MAX_PATH];
        CommandLine commandLine(cmdLine);

        GetModuleFileName(progIns, module, SizeOf(module));
        argv[argc++] = module;
        argc +=  commandLine.getArgv(&argv[argc], _MAX_ARG);

        //Call Main function of SOL9 Windows Application
        Main(argc, argv);
    }

    return TRUE;
}

//void    Main(int argc, TCHAR** argv);

Last modified: 19 Dec 2009

Copyright (c) 2009 Antillia.com ALL RIGHTS RESERVED.