//---------------------------------------------------------------------
// Function:	Initialize
// Description:	Initialization like InitInstace
// Parameters:	.
// Returns:		TRUE, if successful
//---------------------------------------------------------------------
BOOL CObjectTexture::Initialize()
{
	CString tName;
	HINSTANCE appInst;
	CMDIFrameWnd *mainWnd;
		
	// Register the doc templates we provide to the app
	CWinApp* pApp = AfxGetApp();
	ASSERT(pApp != NULL);
    if (pApp == NULL)
    {
        return FALSE;
    }

	mainWnd = DYNAMIC_DOWNCAST(CMDIFrameWnd, pApp->m_pMainWnd);

	// get the apps instance handle for loading resources
	appInst = AfxGetResourceHandle();
	// now tell the application to look in dll for resources
	AfxSetResourceHandle(ObjectTextureDLL.hModule);

	// use my string / icon resources
	// *** note IDR_TEXTURE type needs to be unique ID even between
	// dlls
	m_DocTemplate = new CMultiDocTemplate(IDR_TEXTURETYPE,
			RUNTIME_CLASS(CTextureDoc),
			RUNTIME_CLASS(CMDIChildWnd),
			RUNTIME_CLASS(CTextureView));

	pApp->AddDocTemplate(m_DocTemplate);

	VERIFY(MergeMenus(&m_DocTemplate->m_hMenuShared, *(m_ProgramInfo->curMenu), _T("&Window")));	
	VERIFY(MergeAccelerators(&m_DocTemplate->m_hAccelTable, *(m_ProgramInfo->curAccel)));

	// Initialze the image library
	ilInit();
	iluInit();
	ilutInit();

	// construct resource info
	m_ObjInfo.name.LoadString(IDS_OBJECT_NAME);
	m_ObjInfo.pageIndex = &m_PageIndex;

	m_ObjInfo.icon = (HICON)LoadImage(ObjectTextureDLL.hModule, MAKEINTRESOURCE(IDR_TEXTURETYPE), 
		IMAGE_ICON, 0, 0, LR_CREATEDIBSECTION);
	VERIFY(m_ObjInfo.icon != NULL);

	// value should be 1 - 1000
	m_ObjInfo.priority = IDR_TEXTURETYPE;
	m_ObjInfo.objFlags = OBJFLAGS_EXPORTABLE |
		OBJFLAGS_IMPORTABLE | OBJFLAGS_THUMBNAIL;

	AfxSetResourceHandle(appInst);

    return TRUE;

}
//---------------------------------------------------------------------
// Function:	OnCreate
// Description:	Called from the main windows create function
// Parameters:	CMDIFrameWnd *mainWnd = main frames CMDIFrameWnd pointer
// Returns:		.
//---------------------------------------------------------------------
void CModelViewEditor::OnCreate(CMDIFrameWnd *mainWnd)
{
	MENUINFOMESSAGE mim;
	CBitmap menuBitmap;
	HINSTANCE appInst;

	static DWORD msgHash_GetMenuInfo = CHashString(_T("GetMenuInfo")).GetUniqueID();
	m_ToolBox->SendMessage(msgHash_GetMenuInfo, sizeof(MENUINFOMESSAGE), &mim);

	// get the apps instance handle for loading resources
	appInst = AfxGetResourceHandle();
	// now tell the application to look in dll for resources
	AfxSetResourceHandle(ModelViewEditorDLL.hModule);

	// we need to mergeMenus
	VERIFY(MergeMenus(&m_DocTemplate->m_hMenuShared, mim.m_hMenu, _T("&Window")));	
	// and accelerators
	VERIFY(MergeAccelerators(&m_DocTemplate->m_hAccelTable, mim.m_hAccel));

	mim.m_hAccel = NULL;
	mim.m_hMenu = NULL;
	// load up hi-res toolbar icon
	menuBitmap.LoadBitmap(IDB_TOOLBAR);
	// we don't really have to have to toolbar visible do we?
	mim.m_MenuRsrc = IDR_MODELVIEWTYPE;
	mim.m_MenuBitmap = &menuBitmap;

	static DWORD msgHash_SetMenuInfo = CHashString(_T("SetMenuInfo")).GetUniqueID();
	m_ToolBox->SendMessage(msgHash_SetMenuInfo, sizeof(MENUINFOMESSAGE), &mim);

	static DWORD msgHash_RegisterResourceCollection = CHashString(_T("RegisterResourceCollection")).GetUniqueID();
	DWORD result = m_ToolBox->SendMessage(msgHash_RegisterResourceCollection, sizeof(RESOURCECOLLECTION), &m_ObjCollection);

	if (result != MSG_HANDLED)
	{
		assert(0);
	}

	// We do not need to create Cal3D objects. Opening them seems to be enough

	//FILETYPECREATIONINFO fileInfo; 
	//fileInfo.m_Description = MODELVIEW_EXTENSION_DESCRIPTION; 
	//fileInfo.m_CreationCallback = CModelViewEditor::ModelViewEditorCreationCallback; 
	//static DWORD msgHash_RegisterFileTypeCreationInfo = CHashString(_T("RegisterFileTypeCreationInfo")).GetUniqueID();
	//result = m_ToolBox->SendMessage(msgHash_RegisterFileTypeCreationInfo, sizeof( FILETYPECREATIONINFO ), &fileInfo, NULL, NULL );

	//if (result != MSG_HANDLED)
	//{
	//	assert(0);
	//}

	AfxSetResourceHandle(appInst);
}
//---------------------------------------------------------------------
// Function:	OnCreate
// Description:	Called from the main windows create function
// Parameters:	CMDIFrameWnd *mainWnd = main frames CMDIFrameWnd pointer
// Returns:		.
//---------------------------------------------------------------------
void CGUIEditor::OnCreate(CMDIFrameWnd *mainWnd)
{
	MENUINFOMESSAGE mim;
	CBitmap menuBitmap;
	HINSTANCE appInst;

	static DWORD msgHash_GetMenuInfo = CHashString(_T("GetMenuInfo")).GetUniqueID();
	m_ToolBox->SendMessage(msgHash_GetMenuInfo, sizeof(MENUINFOMESSAGE),&mim);

	// get the apps instance handle for loading resources
	appInst = AfxGetResourceHandle();
	// now tell the application to look in dll for resources
	AfxSetResourceHandle(GUIEditorDLL.hModule);

	// we need to mergeMenus
	VERIFY(MergeMenus(&m_DocTemplate->m_hMenuShared, mim.m_hMenu, _T("&Window")));	
	// and acclerators
	VERIFY(MergeAccelerators(&m_DocTemplate->m_hAccelTable, mim.m_hAccel));

	mim.m_hAccel = NULL;
	mim.m_hMenu = NULL;
	// load up hi-res toolbar icon
	menuBitmap.LoadBitmap(IDB_TOOLBAR);
	// we don't really have to have to toolbar visible do we?
	mim.m_MenuRsrc = IDR_EXAMPLETYPE;
	mim.m_MenuBitmap = &menuBitmap;

	static DWORD msgHash_SetMenuInfo = CHashString(_T("SetMenuInfo")).GetUniqueID();
	m_ToolBox->SendMessage(msgHash_SetMenuInfo, sizeof(MENUINFOMESSAGE),&mim);

	static DWORD msgHash_RegisterResourceCollection = CHashString(_T("RegisterResourceCollection")).GetUniqueID();
	m_ToolBox->SendMessage(msgHash_RegisterResourceCollection, sizeof(RESOURCECOLLECTION),&m_ObjCollection);

	FILETYPECREATIONINFO fileInfo;
	fileInfo.m_Description = GUIEditor_FILE_DESCRIPTION;
	fileInfo.m_CreationCallback = CGUIEditor::GUIEditorCreationCallback;
	static DWORD msgHash_RegisterFileTypeCreationInfo = CHashString(_T("RegisterFileTypeCreationInfo")).GetUniqueID();
	m_ToolBox->SendMessage(msgHash_RegisterFileTypeCreationInfo, sizeof( FILETYPECREATIONINFO ),&fileInfo);

	m_ResBox.SetEditorParent(this);

	m_ResBox.Create(IDD_RESBOX, AfxGetApp()->GetMainWnd());

	AfxSetResourceHandle(appInst);	

}
Beispiel #4
0
    // Purpose: called by the default context menu. Gives an option to merge
    //          extra commands into the menu.
    HRESULT OnDfmMergeContextMenu(IDataObject* pdataobject, UINT /*uFlags*/, QCMINFO& qcminfo)
    {
        CCfShellIdList itemlist(pdataobject);

        if (itemlist.GetItemCount() == 1 && !CVVVItem(itemlist.GetItem(0)).IsFolder())
        {
            // Add 'open' if only 1 item is selected.
            CMenu menu(true);
            menu.AddDefaultItem(ID_DFM_CMD_OPEN, L"&Open");
            MergeMenus(qcminfo, menu);

            // Note: XP will automatic make first menu item the default.
            //       Win98, ME and 2k don't do this, so must add as default item.
        }

        return S_OK;
    }