/* * CSite::Create * * Purpose: * Asks the site to instantiate the MSHTML.DLL object. * * * Parameters: * pIStorage IStorage * of the parent storage in which we're * to create an IStorage for the new object. * pchPath Path of what to load.. * * Return Value: * BOOL Result of the creation. */ BOOL CSite::Create(LPCTSTR pchPath) { HRESULT hr; // Create the site's interface implementations which MSHTML.DLL will call m_pImpIOleClientSite = new CImpIOleClientSite( this, this ); m_pImpIAdviseSink = new CImpIAdviseSink( this, this ); m_pImpIOleIPSite = new CImpIOleInPlaceSite( this, this ); m_pImpIOleDocumentSite = new CImpIOleDocumentSite( this, this ); m_pImpIDocHostUIHandler = new CImpIDocHostUIHandler( this, this ); m_pImpIDocHostShowUI = new CImpIDocHostShowUI( this, this ); m_pImpAmbientIDispatch = new CImpAmbientIDispatch( this, this ); if ( NULL == m_pImpIOleClientSite || NULL == m_pImpIAdviseSink || NULL == m_pImpIOleIPSite || NULL == m_pImpIOleDocumentSite || NULL == m_pImpIDocHostUIHandler ) { ASSERT(FALSE); return FALSE; } hr = CoCreateInstance( CLSID_TriEditDocument, NULL, CLSCTX_INPROC_SERVER, IID_IUnknown, (void **)&m_pObj ); //If creation didn't work, then clean up. //hr = E_FAIL; if ( FAILED( hr ) ) { LPVOID lpMsgBuf; FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, hr, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language (LPTSTR) &lpMsgBuf, 0,NULL ); // Process any inserts in lpMsgBuf. CString strMessage; strMessage.Format(GetString(IDS_DHTML_CREATE_ERROR_MGS), hr,(LPCTSTR)lpMsgBuf); if(IDYES ==::MessageBox(NULL,strMessage,GetString(IDS_ERROR_TITLE),MB_YESNO|MB_ICONERROR)) { NavigateNewWindow(NULL, _T("http://www.microsoft.com/downloads/details.aspx?familyid=b769a4b8-48ed-41a1-8095-5a086d1937cb&displaylang=en")); } ASSERT(FALSE); return FALSE; } // Initialize the object we just created. Set ClientSite, the AdviseSink, etc. return ObjectInitialize( pchPath ); }
INT CGpApp::Init() { TLC_ARGS args; INT hr = 0; LOGI("CGpApp::Init::Begin\n"); //////////////////////////////////////////////////////////////////////////// // Create Texture from File: Mipmap Level = 0, Color Key = 0x0 UINT colorKey= 0x0; UINT use16 = 0x0; INT mip = 1; MAKE_ARG4(args, (char*)"data/atx_background.bmp", use16, colorKey, mip); if(LC_FAILED(LcDev_CreateTextureFromFile(NULL, &m_pTex[0], &args))) return LC_EFAIL; MAKE_ARG4(args, (char*)"data/atx_ship.png", use16, colorKey, mip); if(LC_FAILED(LcDev_CreateTextureFromFile(NULL, &m_pTex[1], &args))) return LC_EFAIL; MAKE_ARG4(args, (char*)"data/atx_photon.png", use16, colorKey, mip); if(LC_FAILED(LcDev_CreateTextureFromFile(NULL, &m_pTex[2], &args))) return LC_EFAIL; MAKE_ARG4(args, (char*)"data/atx_villain.png", use16, colorKey, mip); if(LC_FAILED(LcDev_CreateTextureFromFile(NULL, &m_pTex[3], &args))) return LC_EFAIL; MAKE_ARG4(args, (char*)"data/atx_shield.png", use16, colorKey, mip); if(LC_FAILED(LcDev_CreateTextureFromFile(NULL, &m_pTex[4], &args))) return LC_EFAIL; MAKE_ARG4(args, (char*)"data/atx_bar.png", use16, colorKey, mip); if(LC_FAILED(LcDev_CreateTextureFromFile(NULL, &m_pTex[5], &args))) return LC_EFAIL; //////////////////////////////////////////////////////////////////////////// // Create Background, Effect Sound Instance. // (Default- 22050 Hz, 16 bit stereo) MAKE_ARG2(args, (UINT)LC_SRC_T_FILE, (char*)"data/asm_bgm.wav"); if(LC_FAILED(LcxSmd_CreateSound(NULL, &m_pSnd[0], &args))) return LC_EFAIL; MAKE_ARG2(args, (UINT)LC_SRC_T_FILE, (char*)"data/asm_fire.wav"); if(LC_FAILED(LcxSmd_CreateSound(NULL, &m_pSnd[1], &args))) return LC_EFAIL; MAKE_ARG2(args, (UINT)LC_SRC_T_FILE, (char*)"data/asm_explosion.wav"); if(LC_FAILED(LcxSmd_CreateSound(NULL, &m_pSnd[2], &args))) return LC_EFAIL; //////////////////////////////////////////////////////////////////////////// // Create Font Instance with Sprite TLC_FONT tFont("data/mwg_b.otf", LC_FONT_AN_INTERNAL, 14); // font name: 문화고딕, Height: 14 MAKE_ARG2(args, (LC_HANDLE)&tFont, (LC_HANDLE)m_pSpt); if(LC_FAILED(LcDev_CreateFont(NULL, &m_pFontScore, &args))) return LC_EFAIL; m_pSnd[0]->SetRepeat(); m_pSnd[0]->Play(); LoadHighScore(); ObjectInitialize(); DrawScore(); LOGI("CGpApp::Init::End\n"); return LC_OK; }
UINT tOleHandler::Create(LPVOID pvType) { HRESULT hr; LPUNKNOWN pObj; UINT uRet=CREATE_GRAPHICONLY; DWORD dwMode=STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_DELETEONRELEASE; IPersistStorage *persist_storage = NULL; StgCreateDocfile(NULL, dwMode, 0, &m_pIStorage); if(m_pIStorage == NULL) return CREATE_FAILED; if (NULL==pvType) return CREATE_FAILED; hr=ResultFromScode(E_FAIL); Open(NULL); //CHAPTER24MOD /* * The OLE Control specifications mention that a * a control might implement IPersistStream[Init] * instead of IPersistStorage. In that case you * cannot use OleCreate on a control but must rather * use CoCreateInstance since OleCreate assumes * that IPersistStorage is available. With a control, * you would have to create the object first, then * check if OLEMISC_SETCLIENTSITEFIRST is set, then * send it your IOleClientSite first. Then you check * for IPersistStorage and failing that, try * IPersistStream[Init]. * * For simplicity we'll assume storage-based * controls in this sample. */ //End CHAPTER24MOD hr = CoCreateInstance(*((LPCLSID)pvType), NULL, CLSCTX_ALL, IID_IUnknown, (LPVOID *)&pObj); if(FAILED(hr)) return CREATE_FAILED; if(pObj->QueryInterface(IID_IPersistStorage, (void **) &persist_storage) != S_OK) return CREATE_FAILED; //We need an IOleObject most of the time, so get one here. m_pIOleObject=NULL; hr = pObj->QueryInterface(IID_IOleObject, (LPVOID*)&m_pIOleObject); if(FAILED(hr)) return CREATE_FAILED; // seta o client site m_pIOleObject->SetClientSite(m_pImpIOleClientSite); // inicializa o objeto hr = persist_storage->InitNew(m_pIStorage); if(FAILED(hr)) return CREATE_FAILED; //We don't get the size if PatronObject data was seen already. if (!ObjectInitialize(pObj)) { return CREATE_FAILED; } SIZEL szl; hr=ResultFromScode(E_FAIL); CalcNaturalSize(); //CHAPTER24MOD //Make sure this happens /*if ((OLEMISC_ACTIVATEWHENVISIBLE & m_grfMisc)) Activate(OLEIVERB_INPLACEACTIVATE, NULL);*/ //End CHAPTER24MOD return uRet; }