int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); // TODO: Place code here. MSG msg; HACCEL hAccelTable; // value= 10; GdiplusStartupInput gdiplusStartupInput; ULONG_PTR gdiplusToken; GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); // Initialize global strings LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); LoadString(hInstance, IDC_DRAW, szWindowClass, MAX_LOADSTRING); MyRegisterClass(hInstance); // Perform application initialization: if (!InitInstance (hInstance, nCmdShow)) { return FALSE; } hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_DRAW)); // Main message loop: while (GetMessage(&msg, NULL, 0, 0)) { if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } GdiplusShutdown(gdiplusToken); return (int) msg.wParam; }
kExitCode GraphicalInterfaceInit(Arguments* args, GraphicalInterfaceState* p_if_gui_state/*InterfaceState* p_if_state*/) { // typedef struct { // ULONG_PTR gdi_plus_token; // HRSRC splash_jpg; // HBITMAP splash_jpg_bitmap; // } GraphicalInterfaceState; /* http://www.codeproject.com/Articles/3537/Loading-JPG-PNG-resources-using-GDI http://stackoverflow.com/questions/9240188/how-to-load-a-custom-binary-resource-in-a-vc-static-library-as-part-of-a-dll http://www.codeproject.com/Articles/15523/Own-thread-Win-splash-screen .. http://www.codeproject.com/Messages/3913756/Added-code-to-getImage-from-resource.aspx */ // GraphicalInterfaceState* p_if_gui_state = &p_if_state->gui; (void)args; GdiplusStartupInput gdi_plus_statup_input; gdi_plus_statup_input.GdiplusVersion = 1; gdi_plus_statup_input.DebugEventCallback = NULL; /* http://msdn.microsoft.com/en-us/library/windows/desktop/ms534067(v=vs.85).aspx Boolean value that specifies whether to suppress the GDI+ background thread. If you set this member to TRUE, GdiplusStartup returns (in its output parameter) a pointer to a hook function and a pointer to an unhook function. You must call those functions appropriately to replace the background thread. If you do not want to be responsible for calling the hook and unhook functions, set this member to FALSE. The default value is FALSE. .. SINCE I'LL IMPLEMENT MY OWN THREAD I PROBABLY WANT SuppressBackgroundThread = TRUE FINALLY. */ gdi_plus_statup_input.SuppressBackgroundThread = FALSE; gdi_plus_statup_input.SuppressExternalCodecs = TRUE; GpStatus status = GdiplusStartup(&p_if_gui_state->gdi_plus_token, &gdi_plus_statup_input, NULL); if (status != Ok) { dbg_printf("Error: GdiplusStatup status %d", status); return (kFailGdiplusStartup); } for (size_t i = 0; i < IDC_SPLASH_COUNT; ++i) { kExitCode load_bitmap_exitcode = LoadBitmapFromResource (&p_if_gui_state->splash_jpg_hrsrcs[i], &p_if_gui_state->splash_jpg_bufs[i], &p_if_gui_state->splash_jpg_bitmaps[i], IDC_SPLASH_START + i); if (load_bitmap_exitcode != kSuccess) { return (load_bitmap_exitcode); } dbg_printf("splash_jpg[%02zd] = hrsrc=%p, buf=%p, bitmap=%p\n", i, p_if_gui_state->splash_jpg_hrsrcs[i], p_if_gui_state->splash_jpg_bufs[i], p_if_gui_state->splash_jpg_bitmaps[i]); } return (kSuccess); }
BOOL CVidCapApp::InitInstance() { // InitCommonControlsEx() is required on Windows XP if an application // manifest specifies use of ComCtl32.dll version 6 or later to enable // visual styles. Otherwise, any window creation will fail. INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // Set this to include all the common control classes you want to use // in your application. InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinApp::InitInstance(); // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need // Change the registry key under which our settings are stored // TODO: You should modify this string to be something appropriate // such as the name of your company or organization //SetRegistryKey(_T("Local AppWizard-Generated Applications")); Gdiplus::GdiplusStartupInput gdiplusStartupInput; ULONG_PTR gdiplusToken; GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); CVidCapDlg dlg; m_pMainWnd = &dlg; INT_PTR nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: Place code here to handle when the dialog is // dismissed with OK } else if (nResponse == IDCANCEL) { // TODO: Place code here to handle when the dialog is // dismissed with Cancel } Gdiplus::GdiplusShutdown(gdiplusToken); // Since the dialog has been closed, return FALSE so that we exit the // application, rather than start the application's message pump. return FALSE; }
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); // TODO: разместите код здесь. MSG msg; HACCEL hAccelTable; GdiplusStartupInput gdiplusStartupInput; ULONG_PTR gdiplusToken; GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); // »нициализаци¤ глобальных строк LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); LoadString(hInstance, IDC_WINAPP, szWindowClass, MAX_LOADSTRING); MyRegisterClass(hInstance); // ¬ыполнить инициализацию приложени¤: if (!InitInstance (hInstance, nCmdShow)) { return FALSE; } hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_WINAPP)); // ÷икл основного сообщени¤: while (GetMessage(&msg, NULL, 0, 0)) { if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } GdiplusShutdown(gdiplusToken); return (int) msg.wParam; }
GF_FontReader *gdip_new_font_driver() { GdiplusStartupInput startupInput; GF_FontReader *dr; FontPriv *ctx; SAFEALLOC(ctx, FontPriv); SAFEALLOC(dr, GF_FontReader); GdiplusStartup(&ctx->gdiToken, &startupInput, NULL); GF_REGISTER_MODULE_INTERFACE(dr, GF_FONT_READER_INTERFACE, "GDIplus Font Reader", "gpac distribution") dr->init_font_engine = gdip_init_font_engine; dr->shutdown_font_engine = gdip_shutdown_font_engine; dr->set_font = gdip_set_font; dr->get_font_info = gdip_get_font_info; dr->get_glyphs = gdip_get_glyphs; dr->load_glyph = gdip_load_glyph; dr->udta = ctx; return dr; }
FontRaster *gdip_new_font_driver() { GdiplusStartupInput startupInput; FontRaster *dr; FontPriv *ctx; GP_SAFEALLOC(ctx, FontPriv); GP_SAFEALLOC(dr, FontRaster); GdiplusStartup(&ctx->gdiToken, &startupInput, NULL); M4_REG_PLUG(dr, M4_FONT_RASTER_INTERFACE, "GDIplus Font Engine", "gpac distribution", 0) dr->add_text_to_path = gdip_add_text_to_path; dr->get_font_metrics = gdip_get_font_metrics; dr->get_text_size = gdip_get_text_size; dr->init_font_engine = gdip_init_font_engine; dr->set_font = gdip_set_font; dr->set_font_size = gdip_set_font_size; dr->shutdown_font_engine = gdip_shutdown_font_engine; dr->priv = ctx; return dr; }
void CSurface::Init(char* filename) { Gdiplus::GdiplusStartupInput startupInput; ULONG_PTR token; GdiplusStartup(&token, &startupInput, NULL); int len = strlen(filename); wchar_t* temp = new wchar_t[len + 1]; for (int i = 0; i < len; i++) { temp[i] = filename[i]; } temp[len] = '\0'; Gdiplus::Bitmap bitmap(temp); Gdiplus::Color pixel; if (bitmap.GetWidth() <= 0) return; if (bitmap.GetHeight() <= 0) return; m_width = bitmap.GetWidth(); m_height = bitmap.GetHeight(); m_pPixels = new CVector4[m_width * m_height]; for (int x = 0; x < m_width; x++) { for (int y = 0; y < m_height; y++) { bitmap.GetPixel(x, y, &pixel); m_pPixels[x + y * m_width] = CVector4(pixel.GetR(), pixel.GetG(), pixel.GetB(), pixel.GetA()); } } if (!m_pPixels) return; STRING::Copy(m_pFilename, filename); }
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, PSTR, INT iCmdShow) { MSG msg; GdiplusStartupInput gdiplusStartupInput; ULONG_PTR gdiplusToken; GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); CEyepatch *wnd = new CEyepatch(); wnd->m_hInstance = hInstance; wnd->Create(NULL, CRect(0,0,WINDOW_X,WINDOW_Y), APP_CLASS, WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_VISIBLE); while( GetMessage( &msg, NULL, 0, 0 ) ){ TranslateMessage( &msg ); DispatchMessage( &msg ); } delete wnd; GdiplusShutdown(gdiplusToken); return (int)msg.wParam; }
BOOL CLibElcBaseUIApp::InitInstance() { CWinApp::InitInstance(); m_hResource = LoadResourceLibrary(_T("LibElcBaseUIRes.dll")); if (m_hResource) { AfxSetResourceHandle(m_hResource); } GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); CString strSkinPath; GetL10NDirectory(strSkinPath); strSkinPath += _T("Skins\\SkinUI.xml"); if (!theSkin.LoadFile(strSkinPath)) { //ElcMessageBox(IDS_ERROR_LOAD_SKIN, MB_OK|MB_ICONERROR); //return FALSE; } return TRUE; }
////////////////////////////////////////////////////////////////////////// // Constructor/Distructor duWindowManager::duWindowManager() : m_pDocXml(NULL) ,m_pResManager(NULL) ,m_fZip(FALSE) ,m_hZip(NULL) ,m_pTrialImage(NULL) { ZeroMemory(m_szSkinPath, MAX_PATH * sizeof(TCHAR)); m_mapCtrlManager.clear(); g_hInstance = GetInstanceModule(NULL); g_pTypeLib = new duTypeLib; g_pTypeLib->InitTypeInfo((HMODULE)g_hInstance); InitCommonControls(); g_setValid = new set<duPlugin *>; g_setValid->clear(); GdiplusStartup(&g_gdiplusToken, &g_gdiplusStartupInput, NULL); }
BOOL CPuzzleGameApp::InitInstance() { // InitCommonControls() is required on Windows XP if an application // manifest specifies use of ComCtl32.dll version 6 or later to enable // visual styles. Otherwise, any window creation will fail. InitCommonControls(); CWinApp::InitInstance(); AfxEnableControlContainer(); globalData.SetDPIAware (); CBCGPVisualManager::SetDefaultManager (RUNTIME_CLASS (CBCGPVisualManager2007)); GdiplusStartupInput gdiplusStartupInput; GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL); CPuzzleGameDlg dlg; m_pMainWnd = &dlg; INT_PTR nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: Place code here to handle when the dialog is // dismissed with OK } else if (nResponse == IDCANCEL) { // TODO: Place code here to handle when the dialog is // dismissed with Cancel } BCGCBProCleanUp (); // Since the dialog has been closed, return FALSE so that we exit the // application, rather than start the application's message pump. return FALSE; }
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdParam, int nCmdShow) { MSG Message; GdiplusStartupInput gdiplusStartupInput; /* FOR GDI*/ ULONG_PTR gdiplusToken; /* GOR GDI*/ g_hInst = hInstance; /*for progress bar*/ // Initialize GDI+. GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); WndClass.style = CS_HREDRAW | CS_VREDRAW; WndClass.lpfnWndProc = WndProc; WndClass.cbClsExtra = 0; WndClass.cbWndExtra = 0; WndClass.hInstance = hInstance; WndClass.hCursor = LoadCursor(NULL, IDC_ARROW); WndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION); WndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); WndClass.lpszMenuName = NULL; WndClass.lpszClassName = lpszClass; RegisterClass(&WndClass); // WS_HSCROLL , WS_VSCROLL 스크롤바 추가 Main_hWnd = CreateWindow(lpszClass, lpszClass, WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL , CW_USEDEFAULT, CW_USEDEFAULT, 1000, 1000, NULL, (HMENU)NULL, hInstance, NULL); ShowWindow(Main_hWnd, nCmdShow); UpdateWindow(Main_hWnd); while (GetMessage(&Message, NULL, 0, 0)) { TranslateMessage(&Message); DispatchMessage(&Message); } GdiplusShutdown(gdiplusToken); return Message.wParam; } // WinMain
int Application::Run(HINSTANCE hInstance) const { HANDLE mutex = CreateMutex(nullptr, FALSE, _T("Selected text translate")); if (GetLastError() == ERROR_ALREADY_EXISTS) { FatalAppExit(0, TEXT("SelectedTextTranslate already started!")); } Gdiplus::GdiplusStartupInput gdiplusStartupInput; ULONG_PTR gdiplusToken; GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, nullptr); ServiceRegistry* serviceRegistry = ApplicationServiceRegistry::GetServiceRegistry(); Logger* logger = serviceRegistry->Get<Logger>(); logger->Log(LogLevels::Trace, L"Application start."); int result; try { ExceptionHelper::SetupStructuredExceptionsTranslation(); result = BootstrapApplication(serviceRegistry); delete serviceRegistry; } catch (...) { ExceptionHelper::TerminateOnException(logger); return -1; } ReleaseMutex(mutex); CloseHandle(mutex); Gdiplus::GdiplusShutdown(gdiplusToken); return result; }
static void test_startup(void) { GpPen *pen = NULL; Status status; struct GdiplusStartupInput gdiplusStartupInput; ULONG_PTR gdiplusToken; int gpversion; gdiplusStartupInput.DebugEventCallback = NULL; gdiplusStartupInput.SuppressBackgroundThread = 0; gdiplusStartupInput.SuppressExternalCodecs = 0; for (gpversion=1; gpversion<256; gpversion++) { gdiplusStartupInput.GdiplusVersion = gpversion; status = GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); ok(status == Ok || status == UnsupportedGdiplusVersion, "GdiplusStartup returned %x\n", status); GdiplusShutdown(gdiplusToken); if (status != Ok) { gpversion--; break; } } ok(gpversion > 0 && gpversion <= 2, "unexpected gdiplus version %i\n", gpversion); trace("gdiplus version is %i\n", gpversion); status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen); todo_wine expect(GdiplusNotInitialized, status); GdipDeletePen(pen); }
BOOL CDataLoggerApp::InitInstance() { AfxEnableControlContainer(); // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need. #ifdef _AFXDLL Enable3dControls(); // Call this when using MFC in a shared DLL #else Enable3dControlsStatic(); // Call this when linking to MFC statically #endif GdiplusStartup(&m_pGdiToken,&m_gdiplusStartupInput,NULL); CDataLoggerDlg dlg; m_pMainWnd = &dlg; int nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: Place code here to handle when the dialog is // dismissed with OK } else if (nResponse == IDCANCEL) { // TODO: Place code here to handle when the dialog is // dismissed with Cancel } // Since the dialog has been closed, return FALSE so that we exit the // application, rather than start the application's message pump. return FALSE; }
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow) { HRESULT hRes = ::CoInitialize(NULL); // If you are running on NT 4.0 or higher you can use the following call instead to // make the EXE free threaded. This means that calls come in on a random RPC thread. // HRESULT hRes = ::CoInitializeEx(NULL, COINIT_MULTITHREADED); ATLASSERT(SUCCEEDED(hRes)); // this resolves ATL window thunking problem when Microsoft Layer for Unicode (MSLU) is used ::DefWindowProc(NULL, 0, 0, 0L); HMODULE hInstRichEdit = ::LoadLibrary(_T("Msftedit.dll")); AtlInitCommonControls(ICC_BAR_CLASSES); // add flags to support other controls GdiplusStartupInput m_gdiplusStartupInput; ULONG_PTR m_gdiplusToken; Status sta = GdiplusStartup(&m_gdiplusToken, &m_gdiplusStartupInput, NULL); //GDI+³õʼ»¯ hRes = _Module.Init(NULL, hInstance); ATLASSERT(SUCCEEDED(hRes)); int nRet = Run(lpstrCmdLine, nCmdShow); GdiplusShutdown(m_gdiplusToken); if( hInstRichEdit != NULL ) { FreeLibrary( hInstRichEdit ); } _Module.Term(); ::CoUninitialize(); return nRet; }
OrGate::OrGate(CPoint point) { this->point = point; GdiplusStartupInput GdiplusStartupInput; GdiplusStartup(&g_GdiPlusTokenBoxData_OR, &GdiplusStartupInput, NULL); }
int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPTSTR lpCmdLine, _In_ int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); beats = new bool[bd.length()]; int ttt = 0; while (bd.hasNext()) { double t = bd.next(); //std::wstringstream wss; //wss << t; //MessageBox(0, wss.str().c_str(), _T(""), 0); beats[ttt++] = t; //beats[ttt++] = bd.next(); } //int count = 0; //for (int i = 0; i < bd.length(); i++) //{ // if (beats[i]) count++; // else if (count > 0) // { // if (count % 2 == 0) count--; // if (count == 0) continue; // for (int j = i - count; j < i; j++) // { // if (i - j == count / 2) beats[j] = true; // else beats[j] = false; // } // count = 0; // } // else count = 0; //} std::ofstream out("sound.wav.analyze", std::ios::out); for (int i = 0; i < bd.length(); i++) { out << i * bd.getPrecision() << "\t" << beats[i] << std::endl; } out.close(); bd.release(); w.reset(); FILE *f = fopen("sound.wav", "rb"); fseek(f, 0, SEEK_END); long fsize = ftell(f); fseek(f, 0, SEEK_SET); BYTE* raw = new BYTE[fsize]; fread(raw, 1, fsize, f); fclose(f); Wave tmp(std::string((char*)raw, fsize), Wave::RAW); // TODO: Place code here. MSG msg; HACCEL hAccelTable; GdiplusStartupInput gdiplusStartupInput; ULONG_PTR gdiplusToken; // Initialize GDI+. GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); // Initialize global strings LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); LoadString(hInstance, IDC_LIBWAV_TEST, szWindowClass, MAX_LOADSTRING); MyRegisterClass(hInstance); // Perform application initialization: if (!InitInstance (hInstance, nCmdShow)) { return FALSE; } hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_LIBWAV_TEST)); // Main message loop: while (GetMessage(&msg, NULL, 0, 0)) { if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } GdiplusShutdown(gdiplusToken); return (int) msg.wParam; }
int main (int argc, char **argv) { GpImage *img; gunichar2 *unis; GpBitmap *bitmap; GpStatus status; int original_palette_size; int reloaded_palette_size; ColorPalette *original_palette; ColorPalette *reloaded_palette; GdiplusStartupInput gdiplusStartupInput; ULONG_PTR gdiplusToken; PixelFormat pixel_format; ARGB color; GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); // PNG resave should preserve the palette transparency. Let's test it // by loading a PNG file and its palette, then resaving it and loading // it again for comparison. unis = g_utf8_to_utf16 ("test-trns.png", -1, NULL, NULL, NULL); status = GdipLoadImageFromFile (unis, &img); CHECK_STATUS(1); g_free (unis); status = GdipGetImagePaletteSize (img, &original_palette_size); CHECK_STATUS(1); CHECK_ASSERT(original_palette_size > 0); original_palette = malloc (original_palette_size); GdipGetImagePalette (img, original_palette, original_palette_size); CHECK_STATUS(1); unis = g_utf8_to_utf16 ("test-trns-resave.png", -1, NULL, NULL, NULL); status = GdipSaveImageToFile (img, unis, &png_clsid, NULL); CHECK_STATUS(1); GdipDisposeImage (img); status = GdipLoadImageFromFile (unis, &img); CHECK_STATUS(1); g_free (unis); status = GdipGetImagePaletteSize (img, &reloaded_palette_size); CHECK_STATUS(1); CHECK_ASSERT(reloaded_palette_size > 0); CHECK_ASSERT(reloaded_palette_size == original_palette_size); reloaded_palette = malloc (reloaded_palette_size); GdipGetImagePalette (img, reloaded_palette, reloaded_palette_size); CHECK_STATUS(1); CHECK_ASSERT(memcmp (original_palette, reloaded_palette, original_palette_size) == 0); GdipDisposeImage (img); img = NULL; unlink ("test-trns-resave.png"); free (original_palette); free (reloaded_palette); // Test grayscale image with alpha channel. The image should be converted // into 32-bit ARGB format and the alpha channel should be preserved. unis = g_utf8_to_utf16 ("test-gsa.png", -1, NULL, NULL, NULL); status = GdipCreateBitmapFromFile (unis, &bitmap); CHECK_STATUS(1); g_free (unis); status = GdipGetImagePixelFormat (bitmap, &pixel_format); CHECK_STATUS(1); CHECK_ASSERT(pixel_format == PixelFormat32bppARGB); status = GdipBitmapGetPixel (bitmap, 0, 0, &color); CHECK_STATUS(1); CHECK_ASSERT(color == 0xffffff); status = GdipBitmapGetPixel (bitmap, 1, 7, &color); CHECK_STATUS(1); CHECK_ASSERT(color == 0xe8b3b3b3); GdipDisposeImage (bitmap); return 0; }
BOOL CDiskInfoApp::InitInstance() { BOOL flagEarthlight = FALSE; BOOL flagStartupExit = FALSE; m_FlagCopyExit = FALSE; int defaultDisk = -1; HANDLE hMutex = NULL; INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinApp::InitInstance(); GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); // IE Version Check. /* if(GetFileVersion(_T("Shdocvw.dll")) < 471) { AfxMessageBox(_T("CrystalDiskInfo is required IE 6.0 or later.")); } */ // CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); // for WMI error SetErrorMode(SEM_FAILCRITICALERRORS); // Init m_Ini TCHAR *ptrEnd; TCHAR ini[MAX_PATH]; ::GetModuleFileName(NULL, ini, MAX_PATH); if((ptrEnd = _tcsrchr(ini, '.')) != NULL) { *ptrEnd = '\0'; _tcscat_s(ini, MAX_PATH, _T(".ini")); } m_Ini = ini; #ifdef SUISHO_SHIZUKU_SUPPORT m_Ini.Replace(_T("DiskInfoS.ini"), _T("DiskInfo.ini")); m_Ini.Replace(_T("DiskInfoSx64.ini"), _T("DiskInfoX64.ini")); #endif CString cstr; DWORD debugMode = GetPrivateProfileInt(_T("Setting"), _T("DebugMode"), 0, m_Ini); SetDebugMode(debugMode); cstr.Format(_T("%d"), debugMode); WritePrivateProfileString(_T("Setting"), _T("DebugMode"), cstr, m_Ini); int argc = 0; int index = 0; LPWSTR *argv = CommandLineToArgvW(GetCommandLineW(), &argc); if(argc > 1) { CString cstr; cstr = argv[1]; if(cstr.CompareNoCase(_T("/Earthlight")) == 0) { flagEarthlight = TRUE; if(argc > 2) { defaultDisk = _tstoi(argv[2]); } } if(cstr.CompareNoCase(_T("/Startup")) == 0) { int time = 0; time = GetPrivateProfileInt(_T("Setting"), _T("StartupWaitTime"), 30, m_Ini); if(time >= 0) { Sleep(time * 1000); } TCHAR str[MAX_PATH]; ::GetModuleFileName(NULL, str, MAX_PATH); ShellExecute(NULL, NULL, str, NULL, NULL, SW_SHOWNORMAL); return FALSE; } if(cstr.CompareNoCase(_T("/Exit")) == 0) { flagStartupExit = TRUE; } if(cstr.CompareNoCase(_T("/Copy")) == 0) { m_SaveAsText = m_Ini; m_SaveAsText.Replace(_T("ini"), _T("txt")); } if(cstr.CompareNoCase(_T("/CopyExit")) == 0) { m_SaveAsText = m_Ini; m_SaveAsText.Replace(_T("ini"), _T("txt")); m_FlagCopyExit = TRUE; } } // DEBUG // flagEarthlight = TRUE; if(! flagEarthlight) { DebugPrint(_T("CreateMutex")); hMutex = ::CreateMutex(NULL, FALSE, PROJECT_NAME); if(GetLastError() == ERROR_ALREADY_EXISTS) { DebugPrint(_T("ERROR_ALREADY_EXISTS")); return FALSE; } } CString DefaultTheme; CString DefaultLanguage; TCHAR tmp[MAX_PATH]; GetModuleFileName(NULL, tmp, MAX_PATH); if((ptrEnd = _tcsrchr(tmp, '\\')) != NULL) { *ptrEnd = '\0'; } m_ExeDir.Format(_T("%s\\"), tmp); m_ThemeDir.Format(_T("%s\\%s"), tmp, THEME_DIR); m_LangDir.Format(_T("%s\\%s"), tmp, LANGUAGE_DIR); m_SmartDir.Format(_T("%s\\%s"), tmp, SMART_DIR); m_GadgetDir.Format(_T("%s\\%s"), tmp, GADGET_DIR); if(IsDotNet4()) { m_AlertMailPath.Format(_T("%s\\%s"), tmp, ALERT_MAIL_4_PATH); } else if(IsDotNet2()) { m_AlertMailPath.Format(_T("%s\\%s"), tmp, ALERT_MAIL_PATH); } else { m_AlertMailPath = _T(""); } m_OpusDecPath.Format(_T("%s\\%s"), tmp, OPUS_DEC_PATH); #ifdef SUISHO_SHIZUKU_SUPPORT m_ShizukuVoicePath.Format(_T("%s\\%s"), tmp, SHIZUKU_VOICE_PATH); #endif m_ThemeIndex = MENU_THEME_INDEX; m_LangIndex = MENU_LANG_INDEX; DefaultTheme.Format(_T("%s\\%s"), tmp, DEFAULT_THEME); DefaultLanguage.Format(_T("%s\\%s"), tmp, DEFAULT_LANGUAGE); OSVERSIONINFOEX osvi; BOOL bosVersionInfoEx; ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); if(!(bosVersionInfoEx = GetVersionEx((OSVERSIONINFO *)&osvi))) { osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx((OSVERSIONINFO *)&osvi); } if((BOOL)GetPrivateProfileInt(_T("Workaround"), _T("IE8MODE"), 0, m_Ini)) { m_GraphDlgPath.Format(_T("%s\\") DIALOG_DIR GRAPH_DIALOG_IE8, tmp); if(! IsFileExistEx(m_GraphDlgPath, GRAPH_DIALOG_IE8)) { return FALSE; } } else { m_GraphDlgPath.Format(_T("%s\\") DIALOG_DIR GRAPH_DIALOG, tmp); if(! IsFileExistEx(m_GraphDlgPath, GRAPH_DIALOG)) { return FALSE; } } m_OptionDlgPath.Format(_T("%s\\") DIALOG_DIR OPTION_DIALOG, tmp); // if(! IsFileExistEx(DefaultTheme, DEFAULT_THEME)) { return FALSE; } if(! IsFileExistEx(DefaultLanguage, DEFAULT_LANGUAGE)) { return FALSE; } // for Windows NT family #ifdef _UNICODE if(! IsCurrentUserLocalAdministrator()) { if(osvi.dwMajorVersion < 6) { AfxMessageBox(_T("CrystalDiskInfo is required Administrator Privileges.")); } RunAsRestart(); return FALSE; } #endif BOOL flagAfxOleInit = FALSE; if(flagEarthlight) { CGraphDlg dlg(NULL, defaultDisk); m_pMainWnd = &dlg; INT_PTR nResponse = dlg.DoModal(); } else { // No Server Busy Dialog!! DebugPrint(_T("AfxOleInit()")); if(AfxOleInit()) { flagAfxOleInit = TRUE; DebugPrint(_T("AfxOleGetMessageFilter()->SetMessagePendingDelay")); AfxOleGetMessageFilter()->SetMessagePendingDelay(60 * 1000); DebugPrint(_T("AfxOleGetMessageFilter()->EnableNotRespondingDialog(FALSE)")); AfxOleGetMessageFilter()->EnableNotRespondingDialog(FALSE); DebugPrint(_T("AfxOleGetMessageFilter()->EnableBusyDialog(FALSE)")); AfxOleGetMessageFilter()->EnableBusyDialog(FALSE); } else { DebugPrint(_T("CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);")); CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); } CDiskInfoDlg dlg(NULL, flagStartupExit); m_pMainWnd = &dlg; BOOL flagReExec = FALSE; DebugPrint(_T("dlg.DoModal()")); if(dlg.DoModal() == RE_EXEC) { flagReExec = TRUE; } ::ReleaseMutex(hMutex); ::CloseHandle(hMutex); if(flagReExec) { TCHAR str[MAX_PATH]; ::GetModuleFileName(NULL, str, MAX_PATH); ShellExecute(NULL, NULL, str, NULL, NULL, SW_SHOWNORMAL); } } if(! flagAfxOleInit) { DebugPrint(_T("CoUninitialize();")); CoUninitialize(); } return FALSE; }
BOOL CBaikuDemoApp::InitInstance() { // InitCommonControlsEx() is required on Windows XP if an application // manifest specifies use of ComCtl32.dll version 6 or later to enable // visual styles. Otherwise, any window creation will fail. INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // Set this to include all the common control classes you want to use // in your application. InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); // Gdiplus initialize: GdiplusStartupInput gdiplusStartupInput; GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL); CWinAppEx::InitInstance(); // Initialize OLE libraries if (!AfxOleInit()) { AfxMessageBox(IDP_OLE_INIT_FAILED); return FALSE; } AfxEnableControlContainer(); EnableTaskbarInteraction(FALSE); // AfxInitRichEdit2() is required to use RichEdit control // AfxInitRichEdit2(); // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need // Change the registry key under which our settings are stored // TODO: You should modify this string to be something appropriate // such as the name of your company or organization SetRegistryKey(_T("Local AppWizard-Generated Applications")); LoadStdProfileSettings(4); // Load standard INI file options (including MRU) InitContextMenuManager(); InitKeyboardManager(); InitTooltipManager(); CMFCToolTipInfo ttParams; ttParams.m_bVislManagerTheme = TRUE; theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL, RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams); TRACE(_T("start load theme here.")); LoadTheme(); CLoginDlg dlg; dlg.DoModal(); if (!dlg.IsLogin()) { TRACE(_T("Don't login!!!")); return FALSE; } return TRUE; // Register the application's document templates. Document templates // serve as the connection between documents, frame windows and views CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CBaikuDemoDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CBaikuDemoView)); if (!pDocTemplate) return FALSE; AddDocTemplate(pDocTemplate); // Parse command line for standard shell commands, DDE, file open CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // Dispatch commands specified on the command line. Will return FALSE if // app was launched with /RegServer, /Register, /Unregserver or /Unregister. if (!ProcessShellCommand(cmdInfo)) return FALSE; // The one and only window has been initialized, so show and update it m_pMainWnd->ShowWindow(SW_SHOW); m_pMainWnd->UpdateWindow(); // call DragAcceptFiles only if there's a suffix // In an SDI app, this should occur after ProcessShellCommand return TRUE; }
BOOL CChatClientApp::InitInstance() { AfxInitRichEdit(); //TODO: call AfxInitRichEdit2() to initialize richedit2 library. // 응용 프로그램 매니페스트가 ComCtl32.dll 버전 6 이상을 사용하여 비주얼 스타일을 // 사용하도록 지정하는 경우, Windows XP 상에서 반드시 InitCommonControlsEx()가 필요합니다. // InitCommonControlsEx()를 사용하지 않으면 창을 만들 수 없습니다. INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // 응용 프로그램에서 사용할 모든 공용 컨트롤 클래스를 포함하도록 // 이 항목을 설정하십시오. InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinApp::InitInstance(); if (!AfxSocketInit()) { AfxMessageBox(IDP_SOCKETS_INIT_FAILED); return FALSE; } GdiplusStartupInput gidplusStartInput; GdiplusStartup(&m_gidplusToken, &gidplusStartInput, NULL); AfxEnableControlContainer(); // 대화 상자에 셸 트리 뷰 또는 // 셸 목록 뷰 컨트롤이 포함되어 있는 경우 셸 관리자를 만듭니다. CShellManager *pShellManager = new CShellManager; // 표준 초기화 // 이들 기능을 사용하지 않고 최종 실행 파일의 크기를 줄이려면 // 아래에서 필요 없는 특정 초기화 // 루틴을 제거해야 합니다. // 해당 설정이 저장된 레지스트리 키를 변경하십시오. // TODO: 이 문자열을 회사 또는 조직의 이름과 같은 // 적절한 내용으로 수정해야 합니다. SetRegistryKey(_T("로컬 응용 프로그램 마법사에서 생성된 응용 프로그램")); CClientSocket *p_client_socket = new CClientSocket(); CImageSocket *p_image_socket = new CImageSocket(); TCHAR id[20] = {0}; CChatConnector cdlg(p_client_socket, p_image_socket, id); if(IDOK == cdlg.DoModal()){ CChatClientDlg dlg(p_client_socket, p_image_socket, id); m_pMainWnd = &dlg; INT_PTR nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: 여기에 [확인]을 클릭하여 대화 상자가 없어질 때 처리할 // 코드를 배치합니다. } else if (nResponse == IDCANCEL) { // TODO: 여기에 [취소]를 클릭하여 대화 상자가 없어질 때 처리할 // 코드를 배치합니다. } } // 위에서 만든 셸 관리자를 삭제합니다. if (pShellManager != NULL) { delete pShellManager; } // 대화 상자가 닫혔으므로 응용 프로그램의 메시지 펌프를 시작하지 않고 응용 프로그램을 끝낼 수 있도록 FALSE를 // 반환합니다. return FALSE; }
PictureManager::PictureManager(void) { GdiplusStartupInput input; GdiplusStartup(&gdiToken_, &input, nullptr); }
LONG WINAPI ImageView_CreateWindow(HWND hwnd, LPWSTR szFileName) { struct GdiplusStartupInput gdiplusStartupInput; ULONG_PTR gdiplusToken; WNDCLASS WndClass = {0}; TCHAR szBuf[512]; WCHAR szInitialFile[MAX_PATH]; HWND hMainWnd; MSG msg; if (!ImageView_LoadSettings()) { shiSettings.Maximized = FALSE; shiSettings.Left = 0; shiSettings.Top = 0; shiSettings.Right = 520; shiSettings.Bottom = 400; } // Initialize GDI+ gdiplusStartupInput.GdiplusVersion = 1; gdiplusStartupInput.DebugEventCallback = NULL; gdiplusStartupInput.SuppressBackgroundThread = FALSE; gdiplusStartupInput.SuppressExternalCodecs = FALSE; GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); pLoadImage(szFileName); // Create the window WndClass.lpszClassName = _T("shimgvw_window"); WndClass.lpfnWndProc = ImageView_WndProc; WndClass.hInstance = hInstance; WndClass.style = CS_HREDRAW | CS_VREDRAW; WndClass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APPICON)); WndClass.hCursor = LoadCursor(hInstance, IDC_ARROW); WndClass.hbrBackground = (HBRUSH)COLOR_WINDOW; if (!RegisterClass(&WndClass)) return -1; LoadString(hInstance, IDS_APPTITLE, szBuf, sizeof(szBuf) / sizeof(TCHAR)); hMainWnd = CreateWindow(_T("shimgvw_window"), szBuf, WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_CAPTION, CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, NULL, NULL, hInstance, NULL); // make sure the path has no quotes on it wcscpy(szInitialFile, szFileName); PathUnquoteSpacesW(szInitialFile); currentFile = pBuildFileList(szInitialFile); if (currentFile) { pLoadImageFromNode(currentFile, hMainWnd); } // Show it ShowWindow(hMainWnd, SW_SHOW); UpdateWindow(hMainWnd); // Message Loop while(GetMessage(&msg,NULL,0,0)) { TranslateMessage(&msg); DispatchMessageW(&msg); } pFreeFileList(currentFile); if (image) GdipDisposeImage(image); GdiplusShutdown(gdiplusToken); return -1; }
void SpriteFont::Initialize(const wchar *fontName, float fontSize, UINT fontStyle, bool antiAliased, ID3D11Device *device) { m_size = fontSize; Gdiplus::TextRenderingHint hint = antiAliased ? Gdiplus::TextRenderingHintAntiAliasGridFit : Gdiplus::TextRenderingHintSingleBitPerPixelGridFit; // Init GDI+ ULONG_PTR token = NULL; Gdiplus::GdiplusStartupInput startupInput(NULL, true, true); Gdiplus::GdiplusStartupOutput startupOutput; HR(GdiplusStartup(&token, &startupInput, &startupOutput)); // Create the font Gdiplus::Font font(fontName, fontSize, fontStyle, Gdiplus::UnitPixel, NULL); // Check for error during construction HR(font.GetLastStatus()); // Create a temporary Bitmap and Graphics for figuring out the rough size required // for drawing all of the characters int size = static_cast<int>(fontSize * NumChars * 2) + 1; Gdiplus::Bitmap sizeBitmap(size, size, PixelFormat32bppARGB); HR(sizeBitmap.GetLastStatus()); Gdiplus::Graphics sizeGraphics(&sizeBitmap); HR(sizeGraphics.GetLastStatus()); HR(sizeGraphics.SetTextRenderingHint(hint)); m_charHeight = font.GetHeight(&sizeGraphics) * 1.5f; wchar allChars[NumChars + 1]; for (wchar i = 0; i < NumChars; ++i) { allChars[i] = i + StartChar; } allChars[NumChars] = 0; Gdiplus::RectF sizeRect; HR(sizeGraphics.MeasureString(allChars, NumChars, &font, Gdiplus::PointF(0, 0), &sizeRect)); int numRows = static_cast<int>(sizeRect.Width / TexWidth) + 1; int texHeight = static_cast<int>(numRows * m_charHeight) + 1; // Create a temporary Bitmap and Graphics for drawing the characters one by one int tempSize = static_cast<int>(fontSize * 2); Gdiplus::Bitmap drawBitmap(tempSize, tempSize, PixelFormat32bppARGB); HR(drawBitmap.GetLastStatus()); Gdiplus::Graphics drawGraphics(&drawBitmap); HR(drawGraphics.GetLastStatus()); HR(drawGraphics.SetTextRenderingHint(hint)); // Create a temporary Bitmap + Graphics for creating a full character set Gdiplus::Bitmap textBitmap(TexWidth, texHeight, PixelFormat32bppARGB); HR(textBitmap.GetLastStatus()); Gdiplus::Graphics textGraphics(&textBitmap); HR(textGraphics.GetLastStatus()); HR(textGraphics.Clear(Gdiplus::Color(0, 255, 255, 255))); HR(textGraphics.SetCompositingMode(Gdiplus::CompositingModeSourceCopy)); // Solid brush for text rendering Gdiplus::SolidBrush brush(Gdiplus::Color(255, 255, 255, 255)); HR(brush.GetLastStatus()); // Draw all of the characters, and copy them to the full character set wchar charString [2]; charString[1] = 0; int currentX = 0; int currentY = 0; for (uint64 i = 0; i < NumChars; ++i) { charString[0] = static_cast<wchar>(i + StartChar); // Draw the character HR(drawGraphics.Clear(Gdiplus::Color(0, 255, 255, 255))); HR(drawGraphics.DrawString(charString, 1, &font, Gdiplus::PointF(0, 0), &brush)); // Figure out the amount of blank space before the character int minX = 0; for (int x = 0; x < tempSize; ++x) { for (int y = 0; y < tempSize; ++y) { Gdiplus::Color color; HR(drawBitmap.GetPixel(x, y, &color)); if (color.GetAlpha() > 0) { minX = x; x = tempSize; break; } } } // Figure out the amount of blank space after the character int maxX = tempSize - 1; for (int x = tempSize - 1; x >= 0; --x) { for (int y = 0; y < tempSize; ++y) { Gdiplus::Color color; HR(drawBitmap.GetPixel(x, y, &color)); if (color.GetAlpha() > 0) { maxX = x; x = -1; break; } } } int charWidth = maxX - minX + 1; // Figure out if we need to move to the next row if (currentX + charWidth >= TexWidth) { currentX = 0; currentY += static_cast<int>(m_charHeight) + 1; } // Fill out the structure describing the character position m_charDescs[i].X = static_cast<float>(currentX); m_charDescs[i].Y = static_cast<float>(currentY); m_charDescs[i].Width = static_cast<float>(charWidth); m_charDescs[i].Height = static_cast<float>(m_charHeight); // Copy the character over int height = static_cast<int>(m_charHeight + 1); HR(textGraphics.DrawImage(&drawBitmap, currentX, currentY, minX, 0, charWidth, height, Gdiplus::UnitPixel)); currentX += charWidth + 1; } // Figure out the width of a space character charString[0] = ' '; charString[1] = 0; HR(drawGraphics.MeasureString(charString, 1, &font, Gdiplus::PointF(0, 0), &sizeRect)); m_spaceWidth = sizeRect.Width; // Lock the bitmap for direct memory access Gdiplus::BitmapData bmData; HR(textBitmap.LockBits(&Gdiplus::Rect(0, 0, TexWidth, texHeight), Gdiplus::ImageLockModeRead, PixelFormat32bppARGB, &bmData)); // Create a D3D texture, initalized with the bitmap data D3D11_TEXTURE2D_DESC texDesc; texDesc.Width = TexWidth; texDesc.Height = texHeight; texDesc.MipLevels = 1; texDesc.ArraySize = 1; texDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; texDesc.SampleDesc.Count = 1; texDesc.SampleDesc.Quality = 0; texDesc.Usage = D3D11_USAGE_IMMUTABLE; texDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE; texDesc.CPUAccessFlags = 0; texDesc.MiscFlags = 0; D3D11_SUBRESOURCE_DATA data; data.pSysMem = bmData.Scan0; data.SysMemPitch = TexWidth * 4; data.SysMemSlicePitch = 0; HR(device->CreateTexture2D(&texDesc, &data, &m_texture)); HR(textBitmap.UnlockBits(&bmData)); // Create the shader resource view D3D11_SHADER_RESOURCE_VIEW_DESC srDesc; srDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; srDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; srDesc.Texture2D.MipLevels = 1; srDesc.Texture2D.MostDetailedMip = 0; HR(device->CreateShaderResourceView(m_texture, &srDesc, &m_SRV)); // Shutdown GDI+ //Gdiplus::GdiplusShutdown(token); // TODO: Figure out why this throws exceptions }
BOOL CUltimateK3App::InitInstance() { // 如果一个运行在 Windows XP 上的应用程序清单指定要 // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式, //则需要 InitCommonControlsEx()。 否则,将无法创建窗口。 INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // 将它设置为包括所有要在应用程序中使用的 // 公共控件类。 InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinApp::InitInstance(); GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); AfxEnableControlContainer(); // 创建 shell 管理器,以防对话框包含 // 任何 shell 树视图控件或 shell 列表视图控件。 CShellManager *pShellManager = new CShellManager; // 激活“Windows Native”视觉管理器,以便在 MFC 控件中启用主题 CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows)); // 标准初始化 // 如果未使用这些功能并希望减小 // 最终可执行文件的大小,则应移除下列 // 不需要的特定初始化例程 // 更改用于存储设置的注册表项 // TODO: 应适当修改该字符串, // 例如修改为公司或组织名 SetRegistryKey(_T("应用程序向导生成的本地应用程序")); CUltimateK3Dlg dlg; m_pMainWnd = &dlg; INT_PTR nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: 在此放置处理何时用 // “确定”来关闭对话框的代码 } else if (nResponse == IDCANCEL) { // TODO: 在此放置处理何时用 // “取消”来关闭对话框的代码 } else if (nResponse == -1) { TRACE(traceAppMsg, 0, "警告: 对话框创建失败,应用程序将意外终止。\n"); TRACE(traceAppMsg, 0, "警告: 如果您在对话框上使用 MFC 控件,则无法 #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS。\n"); } // 删除上面创建的 shell 管理器。 if (pShellManager != NULL) { delete pShellManager; } // 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序, // 而不是启动应用程序的消息泵。 return FALSE; }
void init_all(int argc, char **argv) { cpu_info(); char *config = 0, *bpx = 0, *labels = 0; char opt; while ((opt = getopt(argc, argv, "i:l:b:")) != EOF) switch (opt) { case 'i': config = optarg; break; case 'b': bpx = optarg; break; case 'l': labels = optarg; } temp.Minimized = false; init_z80tables(); init_ie_help(); load_config(config); //make_samples(); #ifdef MOD_GS init_gs(); #endif init_leds(); init_tape(); init_hdd_cd(); start_dx(); init_debug(); applyconfig(); main_reset(); autoload(); init_bpx(bpx); init_labels(labels); temp.Gdiplus = GdiplusStartup(); if (!temp.Gdiplus) { color(CONSCLR_WARNING); printf("warning: gdiplus.dll was not loaded, only SCR and BMP screenshots available\n"); } if (comp.ts.vdac2) { if (!vdac2::open_ft8xx()) { color(CONSCLR_WARNING); printf("warning: ft8xx library was not loaded\n"); comp.ts.vdac2 = false; } } load_errors = 0; trd_toload = 0; *(DWORD*)trd_loaded = 0; // clear loaded flags, don't see autoload'ed images for (; optind < argc; optind++) { char fname[0x200], *temp; GetFullPathName(argv[optind], sizeof fname, fname, &temp); trd_toload = DefaultDrive; // auto-select if (!loadsnap(fname)) errmsg("error loading <%s>", argv[optind]), load_errors = 1; } if (load_errors) { int code = MessageBox(wnd, "Some files, specified in\r\ncommand line, failed to load\r\n\r\nContinue emulation?", "File loading error", MB_YESNO | MB_ICONWARNING); if (code != IDYES) exit(); } SetCurrentDirectory(conf.workdir); // timeBeginPeriod(1); InitializeCriticalSection(&tsu_toggle_cr); }
void SetUUIDOverlayIcon( HWND hWnd ) { if (!CRegStdDWORD(_T("Software\\TortoiseGit\\GroupTaskbarIconsPerRepo"), 3)) return; if (!CRegStdDWORD(_T("Software\\TortoiseGit\\GroupTaskbarIconsPerRepoOverlay"), TRUE)) return; std::wstring uuid; std::wstring sicon; bool bRemoveicon = false; #ifdef __AFXWIN_H__ uuid = g_sGroupingUUID; sicon = g_sGroupingIcon; bRemoveicon = g_bGroupingRemoveIcon; #else CCmdLineParser parser(GetCommandLine()); if (parser.HasVal(L"groupuuid")) uuid = parser.GetVal(L"groupuuid"); #endif if (uuid.empty()) return; CComPtr<ITaskbarList3> pTaskbarInterface; if (FAILED(pTaskbarInterface.CoCreateInstance(CLSID_TaskbarList, nullptr, CLSCTX_INPROC_SERVER))) return; int foundUUIDIndex = 0; do { wchar_t buf[MAX_PATH] = { 0 }; swprintf_s(buf, _countof(buf), L"%s%d", L"Software\\TortoiseGit\\LastUsedUUIDsForGrouping\\", foundUUIDIndex); CRegStdString r = CRegStdString(buf); std::wstring sr = r; if (sr.empty()) { r = uuid + (sicon.empty() ? L"" : (L";" + sicon)); break; } size_t sep = sr.find(L';'); std::wstring olduuid = sep != std::wstring::npos ? sr.substr(0, sep) : sr; if (olduuid.compare(uuid) == 0) { if (bRemoveicon) r = uuid; // reset icon path in registry else if (!sicon.empty()) r = uuid + (sicon.empty() ? L"" : (L";" + sicon)); else sicon = sep != std::wstring::npos ? sr.substr(sep + 1) : L""; break; } foundUUIDIndex++; } while (foundUUIDIndex < 20); if (foundUUIDIndex >= 20) { CRegStdString r = CRegStdString(L"Software\\TortoiseGit\\LastUsedUUIDsForGrouping\\1"); r.removeKey(); } HICON icon = nullptr; if (!sicon.empty()) { if (sicon.size() >= 4 && !_wcsicmp(sicon.substr(sicon.size() - 4).c_str(), L".ico")) icon = (HICON)::LoadImage(nullptr, sicon.c_str(), IMAGE_ICON, 16, 16, LR_LOADFROMFILE | LR_SHARED); else { ULONG_PTR gdiplusToken = 0; Gdiplus::GdiplusStartupInput gdiplusStartupInput; GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, nullptr); if (gdiplusToken) { Gdiplus::Bitmap* pBitmap = new Gdiplus::Bitmap(sicon.c_str(), FALSE); if (pBitmap->GetLastStatus() == Gdiplus::Status::Ok) pBitmap->GetHICON(&icon); delete pBitmap; Gdiplus::GdiplusShutdown(gdiplusToken); } } } if (!icon) { DWORD colors[6] = { 0x80FF0000, 0x80FFFF00, 0x8000FF00, 0x800000FF, 0x80000000, 0x8000FFFF }; // AND mask - monochrome - determines which pixels get drawn BYTE AND[32]; for (int i = 0; i<32; i++) { AND[i] = 0xFF; } // XOR mask - 32bpp ARGB - determines the pixel values DWORD XOR[256]; for (int i = 0; i<256; i++) { XOR[i] = colors[foundUUIDIndex % 6]; } icon = ::CreateIcon(nullptr, 16, 16, 1, 32, AND, (BYTE*)XOR); } pTaskbarInterface->SetOverlayIcon(hWnd, icon, uuid.c_str()); DestroyIcon(icon); }
BOOL CXiYuanApp::InitInstance() { // 如果一个运行在 Windows XP 上的应用程序清单指定要 // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式, //则需要 InitCommonControlsEx()。 否则,将无法创建窗口。 INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // 将它设置为包括所有要在应用程序中使用的 // 公共控件类。 InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinAppEx::InitInstance(); if (!AfxSocketInit()) { AfxMessageBox(IDP_SOCKETS_INIT_FAILED); return FALSE; } // 初始化 OLE 库 if (!AfxOleInit()) { AfxMessageBox(IDP_OLE_INIT_FAILED); return FALSE; } AfxEnableControlContainer(); EnableTaskbarInteraction(); // 使用 RichEdit 控件需要 AfxInitRichEdit2() // AfxInitRichEdit2(); // 标准初始化 // 如果未使用这些功能并希望减小 // 最终可执行文件的大小,则应移除下列 // 不需要的特定初始化例程 // 更改用于存储设置的注册表项 // TODO: 应适当修改该字符串, // 例如修改为公司或组织名 SetRegistryKey(_T("应用程序向导生成的本地应用程序")); LoadStdProfileSettings(16); // 加载标准 INI 文件选项(包括 MRU) // GDI+ GdiplusStartupInput gdiplusStartupInput; GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL); InitContextMenuManager(); InitKeyboardManager(); InitTooltipManager(); CMFCToolTipInfo ttParams; ttParams.m_bVislManagerTheme = TRUE; theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL, RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams); // 注册应用程序的文档模板。 文档模板 // 将用作文档、框架窗口和视图之间的连接 CMultiDocTemplate* pDocTemplate; pDocTemplate = new CMultiDocTemplate(IDR_XiYuanTYPE, RUNTIME_CLASS(CXiYuanDoc), RUNTIME_CLASS(CChildFrame), // 自定义 MDI 子框架 RUNTIME_CLASS(CXiYuanView)); if (!pDocTemplate) return FALSE; AddDocTemplate(pDocTemplate); // 将 COleTemplateServer 连接到文档模板 // COleTemplateServer 通过使用 // 文档模板中指定的信息来为请求 OLE 容器 // 创建新文档 m_server.ConnectTemplate(clsid, pDocTemplate, FALSE); // 将所有的 OLE 服务器工厂注册为正在运行。 这将启用 // OLE 库以从其他应用程序中创建对象 COleTemplateServer::RegisterAll(); // 注意: MDI 应用程序将注册所有的服务器对象,而不管 // 命令行上的 /Embedding 或 /Automation // 创建主 MDI 框架窗口 CMainFrame* pMainFrame = new CMainFrame; if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME)) { delete pMainFrame; return FALSE; } m_pMainWnd = pMainFrame; // 分析标准 shell 命令、DDE、打开文件操作的命令行 CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // 应用程序是用 /Embedding 或 /Automation 开关启动的。 //使应用程序作为自动化服务器运行。 if (cmdInfo.m_bRunEmbedded || cmdInfo.m_bRunAutomated) { // 不显示主窗口 return TRUE; } // 使用 /Unregserver 或 /Unregister 开关启动应用程序。 注销 // 类型库。 其他注销操作在 ProcessShellCommand() 中发生。 else if (cmdInfo.m_nShellCommand == CCommandLineInfo::AppUnregister) { m_server.UpdateRegistry(OAT_DISPATCH_OBJECT, NULL, NULL, FALSE); AfxOleUnregisterTypeLib(_tlid, _wVerMajor, _wVerMinor); } // 应用程序是以独立方式或用其他开关(如 /Register // 或 /Regserver)启动的。 更新注册表项,包括类型库。 else { m_server.UpdateRegistry(OAT_DISPATCH_OBJECT); COleObjectFactory::UpdateRegistryAll(); AfxOleRegisterTypeLib(AfxGetInstanceHandle(), _tlid); } // 调度在命令行中指定的命令。 如果 // 用 /RegServer、/Register、/Unregserver 或 /Unregister 启动应用程序,则返回 FALSE。 if (!ProcessShellCommand(cmdInfo)) return FALSE; // 主窗口已初始化,因此显示它并对其进行更新 pMainFrame->ShowWindow(SW_SHOWMAXIMIZED); pMainFrame->UpdateWindow(); return TRUE; }
BOOL CDanmoojiPaintApp::InitInstance() { CWinAppEx::InitInstance(); GdiplusStartupInput gdiplusStartupInput; // GDI+를 위한 환경설정 GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); EnableTaskbarInteraction(); // RichEdit 컨트롤을 사용하려면 AfxInitRichEdipointer_aft()가 있어야 합니다. // AfxInitRichEdipointer_aft(); // RichEdit 컨트롤을 사용하려면 AfxInitRichEdit2()가 있어야 합니다. // AfxInitRichEdit2(); // 표준 초기화 // 이들 기능을 사용하지 않고 최종 실행 파일의 크기를 줄이려면 // 아래에서 필요 없는 특정 초기화 // 루틴을 제거해야 합니다. // 해당 설정이 저장된 레지스트리 키를 변경하십시오. // TODO: 이 문자열을 회사 또는 조직의 이름과 같은 // 적절한 내용으로 수정해야 합니다. SetRegistryKey(_T("로컬 응용 프로그램 마법사에서 생성된 응용 프로그램")); LoadStdProfileSettings(4); // MRU를 포함하여 표준 INI 파일 옵션을 로드합니다. InitContextMenuManager(); InitKeyboardManager(); InitTooltipManager(); CMFCToolTipInfo ttParams; ttParams.m_bVislManagerTheme = TRUE; theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL, RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams); // 응용 프로그램의 문서 템플릿을 등록합니다. 문서 템플릿은 // 문서, 프레임 창 및 뷰 사이의 연결 역할을 합니다. CMultiDocTemplate* pDocTemplate; pDocTemplate = new CMultiDocTemplate(IDR_DanmoojiPaintTYPE, RUNTIME_CLASS(CDanmoojiPaintDoc), RUNTIME_CLASS(CChildFrame), // 사용자 지정 MDI 자식 프레임입니다. RUNTIME_CLASS(CDanmoojiPaintView)); if (!pDocTemplate) return FALSE; AddDocTemplate(pDocTemplate); // 주 MDI 프레임 창을 만듭니다. CMainFrame* pMainFrame = new CMainFrame; if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME)) { delete pMainFrame; return FALSE; } m_pMainWnd = pMainFrame; // 표준 셸 명령, DDE, 파일 열기에 대한 명령줄을 구문 분석합니다. CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // 명령줄에 지정된 명령을 디스패치합니다. // 응용 프로그램이 /RegServer, /Register, /Unregserver 또는 /Unregister로 시작된 경우 FALSE를 반환합니다. if (!ProcessShellCommand(cmdInfo)) return FALSE; // 주 창이 초기화되었으므로 이를 표시하고 업데이트합니다. pMainFrame->ShowWindow(m_nCmdShow); pMainFrame->UpdateWindow(); m_pMainWnd->DragAcceptFiles(); return TRUE; }