// HelloWordMenuEntryPoint.cpp : CHelloWordMenuEntryPoint 
#include <iostream>
#include <fstream>

#include "stdafx.h"
#include "resource.h"
#include "crxutcds.h"
#include "CrxCusUI.h"
#include "IroncadCrxSampleCppMain.h"

//-----------------------------------------------------------------------------
#define szRDS _RXST("")
#pragma comment(lib,"CrxUi.lib")
#pragma comment(lib,"Crx.lib")
#pragma comment(lib,"CrxDb.lib")
#pragma comment(lib,"CrxEdApi.lib")
#pragma comment(lib,"CrxGe.lib")
#pragma comment(lib,"CrxGi.lib")
#pragma comment(lib,"CrxSpt.lib")

HINSTANCE g_hdllInstance;
void InitCmdIroncadCrxSampleCpp();

//-----------------------------------------------------------------------------
//----- CIroncadCrxSampleCsEntryPoint
class CIroncadCrxSampleCppApp:public AcRxArxApp
{
public:

	/// <summary>
	/// コンストラクタ
	/// </summary>
	CIroncadCrxSampleCppApp():AcRxArxApp()
	{
	}

	/// <summary>
	/// 初期化処理
	/// </summary>
	/// <param name="pkt"></param>
	/// <returns></returns>
	virtual AcRx::AppRetCode On_kInitAppMsg(void *pkt) 
	{
		// TODO: Load dependencies here

		// You *must* call On_kInitAppMsg here
		AcRx::AppRetCode retCode =AcRxArxApp::On_kInitAppMsg(pkt);

		// コマンドを追加する
		g_hdllInstance = m_hdllInstance;
		crxedRegCmds->addCommand(_T("SampleCommand1"), _T("GSampleCommand1"), _T("サンプルコマンド1"), ACRX_CMD_MODAL, &IroncadCrxSampleCppCommand1);		// TODO: Add your initialization code here
		crxedRegCmds->addCommand(_T("SampleCommand2"), _T("GSampleCommand2"), _T("サンプルコマンド2"), ACRX_CMD_MODAL, &IroncadCrxSampleCppCommand2);		// TODO: Add your initialization code here
		InitCmdIroncadCrxSampleCpp();
		return (retCode) ;
	}

	/// <summary>
	/// アンロード処理
	/// </summary>
	/// <param name="pkt"></param>
	/// <returns></returns>
	virtual AcRx::AppRetCode On_kUnloadAppMsg(void *pkt)
	{
		// TODO: Add your code here

		// You *must* call On_kUnloadAppMsg here
		AcRx::AppRetCode retCode =AcRxArxApp::On_kUnloadAppMsg(pkt);		


		crxedRegCmds->removeGroup(_T("IroncadCrxSampleCpp"));

		// TODO: Unload dependencies here
		return (retCode);
	}

	virtual void RegisterServerComponents()
	{

	}

	/// <summary>
/// リボンタブを作成・初期化する
/// </summary>
	void InitCmdIroncadCrxSampleCpp()
	{
		CRxUIManager* CrxUI = crxUIManager;
		CRxRibbonTab* pRibbonTab = NULL;
		CRxRibbonPanel* pRibbonPanel = NULL;

		HBITMAP hBitmap1 = (HBITMAP)::LoadImage(g_hdllInstance, MAKEINTRESOURCE(IDB_ICON1), IMAGE_BITMAP, 0, 0, LR_COPYFROMRESOURCE | LR_CREATEDIBSECTION);
		HBITMAP hBitmapLarge1 = (HBITMAP)::LoadImage(g_hdllInstance, MAKEINTRESOURCE(IDB_ICON1), IMAGE_BITMAP, 0, 0, LR_COPYFROMRESOURCE | LR_CREATEDIBSECTION);
		HBITMAP hBitmap2 = (HBITMAP)::LoadImage(g_hdllInstance, MAKEINTRESOURCE(IDB_ICON2), IMAGE_BITMAP, 0, 0, LR_COPYFROMRESOURCE | LR_CREATEDIBSECTION);
		HBITMAP hBitmapLarge2 = (HBITMAP)::LoadImage(g_hdllInstance, MAKEINTRESOURCE(IDB_ICON2), IMAGE_BITMAP, 0, 0, LR_COPYFROMRESOURCE | LR_CREATEDIBSECTION);


		/* リボンバーを取得する */
		CRxRibbonBar* pRibbonBar = CrxUI->getCRxRibbonBar();
		if (pRibbonBar != NULL)
		{
			/* リボンタブを作成する */
			pRibbonTab = pRibbonBar->AppendRibbonTab(_T("IroncadCrxSampleCpp"), _T("IroncadCrxSampleCpp"), TRUE);

			if (pRibbonTab != NULL)
			{
				/* パネルを作成する */
				pRibbonPanel = pRibbonTab->AppendRibbonPanel(_T("IroncadCrxSampleCpp"), _T("IroncadCrxSampleCpp"), (ULONG_PTR)pRibbonBar);
				if (pRibbonPanel != NULL)
				{
					/* ボタンを作成する */
					CRxRibbonButton* pBtn1 = pRibbonPanel->AppendRibbonButton(_T("Sample Command1"), _T("SampleCommand1"), hBitmap1, hBitmapLarge1, (ULONG_PTR)pRibbonPanel, _T("GSampleCommand1"), _T("サンプルコマンド1"));
					CRxRibbonButton* pBtn2 = pRibbonPanel->AppendRibbonButton(_T("Sample Command2"), _T("SampleCommand2"), hBitmap1, hBitmapLarge2, (ULONG_PTR)pRibbonPanel, _T("GSampleCommand2"), _T("サンプルコマンド2"));
				}
			}

		}
	}
};

IMPLEMENT_ARX_ENTRYPOINT(CIroncadCrxSampleCppApp)