// Creates the application window, the d3d device and DirectComposition device and visual tree // before entering the message loop. HRESULT CApplication::BeforeEnteringMessageLoop() { HRESULT hr = CreateApplicationWindow(); if (SUCCEEDED(hr)) { hr = CreateD3D11Device(); } if (SUCCEEDED(hr)) { hr = CreateD2D1Factory(); } if (SUCCEEDED(hr)) { hr = CreateD2D1Device(); } if (SUCCEEDED(hr)) { hr = CreateDCompositionDevice(); } if (SUCCEEDED(hr)) { hr = CreateDCompositionVisualTree(); } return hr; }
static void OpenCommand (void) { int error; FILE *stream; SFReply reply; Point where; char prompt[32]; SFTypeList typeList; if (globalState==OPENED) return; /* get file name */ strcpy(prompt,"choose metafile:"); where.h = 20; where.v = 40; SFGetFile(where,c2pstr(prompt),NULL,-1,typeList,NULL,&reply); if (!reply.good) { return; } /* save name and path */ vRefNum = reply.vRefNum; strcpy(fileName,p2cstr(reply.fName)); /* set volume */ error = SetVol(NULL,vRefNum); if (((int)error)!=0) { OneButtonBox("Could not set volume","OK"); return; } stream = fopen(fileName,"rb"); if (stream==NULL) { OneButtonBox("Could not open file","OK"); return; } GetFileScreen(stream,&fx,&fy); /* open a window */ error = CreateApplicationWindow(&myWindow,fileName,20,40,fx,fy); fclose(stream); SetState(OPENED); RefreshCommand(); return; }
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpszCmdLine, int nCmdShow) { MSG Msg; int Ret = 1; INITCOMMONCONTROLSEX Controls; UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpszCmdLine); UNREFERENCED_PARAMETER(nCmdShow); hAppInstance = hInstance; hAppHeap = GetProcessHeap(); if (InitAppConfig()) { /* load the application title */ if (!AllocAndLoadString(&lpAppTitle, hAppInstance, IDS_SNDVOL32)) { lpAppTitle = NULL; } Controls.dwSize = sizeof(INITCOMMONCONTROLSEX); Controls.dwICC = ICC_BAR_CLASSES | ICC_STANDARD_CLASSES; InitCommonControlsEx(&Controls); if (RegisterApplicationClasses()) { hMainWnd = CreateApplicationWindow(); if (hMainWnd != NULL) { BOOL bRet; while ((bRet =GetMessage(&Msg, NULL, 0, 0)) != 0) { if (bRet != -1) { TranslateMessage(&Msg); DispatchMessage(&Msg); } } DestroyWindow(hMainWnd); Ret = 0; } else { DPRINT("Failed to create application window (LastError: %d)!\n", GetLastError()); } UnregisterApplicationClasses(); } else { DPRINT("Failed to register application classes (LastError: %d)!\n", GetLastError()); } if (lpAppTitle != NULL) { LocalFree(lpAppTitle); } CloseAppConfig(); } else { DPRINT("Unable to open the Volume Control registry key!\n"); } return Ret; }
HRESULT CApplication::BeforeEnteringMessageLoop() { HRESULT hr = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); if (SUCCEEDED(hr)) { hr = CreateApplicationWindow(); } if (SUCCEEDED(hr)) { hr = CreateD3D11Device(); } if (SUCCEEDED(hr)) { hr = CreateD2D1Factory(); } if (SUCCEEDED(hr)) { hr = CreateD2D1Device(); } if (SUCCEEDED(hr)) { hr = CreateWICFactory(); } if (SUCCEEDED(hr)) { hr = CreateAnimationManager(); } if (SUCCEEDED(hr)) { hr = CreateAnimationTransitionLibrary(); } if (SUCCEEDED(hr)) { hr = CreateAnimationVariables(); } if (SUCCEEDED(hr)) { hr = CreateDCompositionDevice(); } if (SUCCEEDED(hr)) { hr = CreateDCompositionRenderTarget(); } if (SUCCEEDED(hr)) { hr = CreateDCompositionVisualTree(); } if (SUCCEEDED(hr)) { hr = AttachDCompositionVisualTreeToRenderTarget(); } if (SUCCEEDED(hr)) { hr = _device->Commit(); } return hr; }