当前位置: 首页>>代码示例>>C++>>正文


C++ MessageBoxW函数代码示例

本文整理汇总了C++中MessageBoxW函数的典型用法代码示例。如果您正苦于以下问题:C++ MessageBoxW函数的具体用法?C++ MessageBoxW怎么用?C++ MessageBoxW使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了MessageBoxW函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: WinMain

//*********************************************************************//
// WinMain
//	- application entry point
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{	
	// Don't let more than one instance of the application exist
	if( IsAlreadyRunning() == true )
		return -1;
    

	// Create the window
	HWND hWnd = MakeWindow( hInstance );
	if( hWnd == 0 )
	{
		MessageBoxW( HWND_DESKTOP, L"ERROR: Failed to create the Main Window.", WINDOW_TITLE, MB_OK | MB_ICONERROR );
		return -2;
	}


	// Display the window
	ShowWindow( hWnd, nCmdShow );
	UpdateWindow( hWnd );

	
	/////////////////////////////////////////////////////////////////////
	// Initialize game
	
	// Access the singleton
	Game* pGame = Game::GetInstance();

	// Initialize
	if( pGame->Initialize( WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_TITLE ) == false )
		return -3;


	// Run the message loop
	MSG msg = { };
	while( true )
	{
		if( PeekMessageW( &msg, NULL, 0, 0, PM_REMOVE ) == TRUE )
		{ 
			// Quit the application?
			if( msg.message == WM_QUIT )
				break;
		
			// Send the message to the window proc
			DispatchMessageW( &msg );
		}
		else
		{
			/////////////////////////////////////////////////////////////
			// Run game
			int result = pGame->Update();
			if( result != 0 )
				PostQuitMessage( result );
		}
	}
	
	
	/////////////////////////////////////////////////////////////////////
	// Terminate game
	
	pGame->Terminate();
	pGame = nullptr;
	Game::DeleteInstance();



	// Unregister the window class
	UnregisterClassW( WINDOW_CLASS_NAME, hInstance );
	
	// Return message's Quit code to the OS
	return (int)(msg.wParam);
}
开发者ID:BGCX261,项目名称:zombiestrikearcade-git,代码行数:74,代码来源:WinMain.cpp

示例2: NS_ENSURE_ARG_POINTER


//.........这里部分代码省略.........
        result = ::GetOpenFileNameW(&ofn);
      }
      else if (mMode == modeSave) {
        ofn.Flags |= OFN_NOREADONLYRETURN;

        // Don't follow shortcuts when saving a shortcut, this can be used
        // to trick users (bug 271732)
        NS_ConvertUTF16toUTF8 ext(mDefault);
        ext.Trim(" .", PR_FALSE, PR_TRUE); // watch out for trailing space and dots
        ToLowerCase(ext);
        if (StringEndsWith(ext, NS_LITERAL_CSTRING(".lnk")) ||
            StringEndsWith(ext, NS_LITERAL_CSTRING(".pif")) ||
            StringEndsWith(ext, NS_LITERAL_CSTRING(".url")))
          ofn.Flags |= OFN_NODEREFERENCELINKS;

        result = ::GetSaveFileNameW(&ofn);
        if (!result) {
          // Error, find out what kind.
          if (::GetLastError() == ERROR_INVALID_PARAMETER 
              || ::CommDlgExtendedError() == FNERR_INVALIDFILENAME
              ) {
            // probably the default file name is too long or contains illegal characters!
            // Try again, without a starting file name.
            ofn.lpstrFile[0] = 0;
            result = ::GetSaveFileNameW(&ofn);
          }
        }
      } 
      else {
        NS_ERROR("unsupported mode"); 
      }
    }
    MOZ_SEH_EXCEPT(PR_TRUE) {
      MessageBoxW(ofn.hwndOwner,
                  0,
                  L"The filepicker was unexpectedly closed by Windows.",
                  MB_ICONERROR);
      result = PR_FALSE;
    }

    if (result) {
      // Remember what filter type the user selected
      mSelectedType = (PRInt16)ofn.nFilterIndex;

      // Set user-selected location of file or directory
      if (mMode == modeOpenMultiple) {
        
        // from msdn.microsoft.com, "Open and Save As Dialog Boxes" section:
        // If you specify OFN_EXPLORER,
        // The directory and file name strings are NULL separated, 
        // with an extra NULL character after the last file name. 
        // This format enables the Explorer-style dialog boxes
        // to return long file names that include spaces. 
        PRUnichar *current = fileBuffer;
        
        nsAutoString dirName(current);
        // sometimes dirName contains a trailing slash
        // and sometimes it doesn't.
        if (current[dirName.Length() - 1] != '\\')
          dirName.Append((PRUnichar)'\\');
        
        nsresult rv;
        while (current && *current && *(current + nsCRT::strlen(current) + 1)) {
          current = current + nsCRT::strlen(current) + 1;
          
          nsCOMPtr<nsILocalFile> file = do_CreateInstance("@mozilla.org/file/local;1", &rv);
开发者ID:s-austin,项目名称:DOMinator,代码行数:67,代码来源:nsFilePicker.cpp

示例3: ThreadFunc


//.........这里部分代码省略.........
    switch(SettingsInfo.Proxy)
    {
        case 0: /* preconfig */
            hOpen = InternetOpenW(lpszAgent, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
            break;
        case 1: /* direct (no proxy) */
            hOpen = InternetOpenW(lpszAgent, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
            break;
        case 2: /* use proxy */
            hOpen = InternetOpenW(lpszAgent, INTERNET_OPEN_TYPE_PROXY, SettingsInfo.szProxyServer, SettingsInfo.szNoProxyFor, 0);
            break;
        default: /* preconfig */
            hOpen = InternetOpenW(lpszAgent, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
            break;
    }

    if (!hOpen)
        goto end;

    hFile = InternetOpenUrlW(hOpen, AppInfo->szUrlDownload, NULL, 0, INTERNET_FLAG_PRAGMA_NOCACHE|INTERNET_FLAG_KEEP_CONNECTION, 0);
    if (!hFile)
        goto end;

    if (!HttpQueryInfoW(hFile, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &dwStatus, &dwStatusLen, NULL))
        goto end;

    if(dwStatus != HTTP_STATUS_OK)
    {
        WCHAR szMsgText[MAX_STR_LEN];

        if (!LoadStringW(hInst, IDS_UNABLE_TO_DOWNLOAD, szMsgText, sizeof(szMsgText) / sizeof(WCHAR)))
            goto end;

        MessageBoxW(hMainWnd, szMsgText, NULL, MB_OK | MB_ICONERROR);
        goto end;
    }

    dwStatusLen = sizeof(dwStatus);

    memset(&urlComponents, 0, sizeof(urlComponents));
    urlComponents.dwStructSize = sizeof(urlComponents);

    if(FAILED(StringCbLengthW(AppInfo->szUrlDownload, sizeof(AppInfo->szUrlDownload), &urlLength)))
        goto end;

    urlLength /= sizeof(WCHAR);
    urlComponents.dwSchemeLength = urlLength + 1;
    urlComponents.lpszScheme = (LPWSTR)malloc(urlComponents.dwSchemeLength * sizeof(WCHAR));
    urlComponents.dwHostNameLength = urlLength + 1;
    urlComponents.lpszHostName = (LPWSTR)malloc(urlComponents.dwHostNameLength * sizeof(WCHAR));

    if(!InternetCrackUrlW(AppInfo->szUrlDownload, urlLength+1, ICU_DECODE | ICU_ESCAPE, &urlComponents))
        goto end;
    
    if(urlComponents.nScheme == INTERNET_SCHEME_HTTP || urlComponents.nScheme == INTERNET_SCHEME_HTTPS)
        HttpQueryInfo(hFile, HTTP_QUERY_CONTENT_LENGTH | HTTP_QUERY_FLAG_NUMBER, &dwContentLen, &dwStatus, 0);

    if(urlComponents.nScheme == INTERNET_SCHEME_FTP)
        dwContentLen = FtpGetFileSize(hFile, &dwStatus);

#ifdef USE_CERT_PINNING
    /* are we using HTTPS to download the RAPPS update package? check if the certificate is original */
    if ((urlComponents.nScheme == INTERNET_SCHEME_HTTPS) &&
        (wcscmp(AppInfo->szUrlDownload, APPLICATION_DATABASE_URL) == 0) &&
        (!CertIsValid(hOpen, urlComponents.lpszHostName)))
    {
开发者ID:GYGit,项目名称:reactos,代码行数:67,代码来源:loaddlg.cpp

示例4: StartShell


//.........这里部分代码省略.........
    /* Safe Mode shell run */
    rc = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
                       L"SYSTEM\\CurrentControlSet\\Control\\SafeBoot\\Option",
                       0, KEY_QUERY_VALUE, &hKey);
    if (rc == ERROR_SUCCESS)
    {
        Size = sizeof(Value);
        rc = RegQueryValueExW(hKey, L"UseAlternateShell", NULL,
                              &Type, (LPBYTE)&Value, &Size);
        RegCloseKey(hKey);

        if (rc == ERROR_SUCCESS)
        {
            if (Type == REG_DWORD)
            {
                if (Value)
                {
                    /* Safe Mode Alternate Shell required */
                    rc = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
                                       L"SYSTEM\\CurrentControlSet\\Control\\SafeBoot",
                                       0, KEY_READ, &hKey);
                    if (rc == ERROR_SUCCESS)
                    {
                        Size = sizeof(Shell);
                        rc = RegQueryValueExW(hKey, L"AlternateShell", NULL,
                                              &Type, (LPBYTE)Shell, &Size);
                        RegCloseKey(hKey);

                        if (rc == ERROR_SUCCESS)
                        {
                            if ((Type == REG_SZ) || (Type == REG_EXPAND_SZ))
                            {
                                TRACE("Key located - %s\n", debugstr_w(Shell));

                                /* Try to run alternate shell */
                                if (TryToStartShell(Shell))
                                {
                                    TRACE("Alternate shell started (Safe Mode)\n");
                                    return TRUE;
                                }
                            }
                            else
                            {
                                WARN("Wrong type %lu (expected %u or %u)\n",
                                     Type, REG_SZ, REG_EXPAND_SZ);
                            }
                        }
                        else
                        {
                            WARN("Alternate shell in Safe Mode required but not specified.");
                        }
                    }
                }
            }
            else
            {
                WARN("Wrong type %lu (expected %u)\n", Type, REG_DWORD);
            }
        }
    }

    /* Try to run shell in user key */
    if (GetShell(Shell, HKEY_CURRENT_USER) && TryToStartShell(Shell))
    {
        TRACE("Started shell from HKEY_CURRENT_USER\n");
        return TRUE;
    }

    /* Try to run shell in local machine key */
    if (GetShell(Shell, HKEY_LOCAL_MACHINE) && TryToStartShell(Shell))
    {
        TRACE("Started shell from HKEY_LOCAL_MACHINE\n");
        return TRUE;
    }

    /* Try default shell */
    if (IsConsoleShell())
    {
        if (GetSystemDirectoryW(Shell, ARRAYSIZE(Shell) - 8))
            wcscat(Shell, L"\\cmd.exe");
        else
            wcscpy(Shell, L"cmd.exe");
    }
    else
    {
        if (GetWindowsDirectoryW(Shell, ARRAYSIZE(Shell) - 13))
            wcscat(Shell, L"\\explorer.exe");
        else
            wcscpy(Shell, L"explorer.exe");
    }

    if (!TryToStartShell(Shell))
    {
        WARN("Failed to start default shell %s\n", debugstr_w(Shell));
        LoadStringW(GetModuleHandle(NULL), IDS_SHELL_FAIL, szMsg, ARRAYSIZE(szMsg));
        MessageBoxW(NULL, szMsg, NULL, MB_OK);
        return FALSE;
    }
    return TRUE;
}
开发者ID:sdever,项目名称:reactos,代码行数:101,代码来源:userinit.c

示例5: InstallLiveCD

DWORD WINAPI
InstallLiveCD(IN HINSTANCE hInstance)
{
    STARTUPINFOW StartupInfo;
    PROCESS_INFORMATION ProcessInformation;
    BOOL bRes;

    if (!CommonInstall())
        goto error;
    
    /* Register components */
    _SEH2_TRY
    {
        if (!SetupInstallFromInfSectionW(NULL,
            hSysSetupInf, L"RegistrationPhase2",
            SPINST_ALL,
            0, NULL, 0, NULL, NULL, NULL, NULL))
        {
            DPRINT1("SetupInstallFromInfSectionW failed!\n");
        }

        RegisterTypeLibraries(hSysSetupInf, L"TypeLibraries");
    }
    _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
    {
        DPRINT1("Catching exception\n");
    }
    _SEH2_END;
    
    SetupCloseInfFile(hSysSetupInf);

    /* Run the shell */
    ZeroMemory(&StartupInfo, sizeof(StartupInfo));
    StartupInfo.cb = sizeof(StartupInfo);
    bRes = CreateProcessW(
        L"userinit.exe",
        NULL,
        NULL,
        NULL,
        FALSE,
        0,
        NULL,
        NULL,
        &StartupInfo,
        &ProcessInformation);
    if (!bRes)
        goto error;

    CloseHandle(ProcessInformation.hThread);
    CloseHandle(ProcessInformation.hProcess);

    return 0;

error:
    MessageBoxW(
        NULL,
        L"Failed to load LiveCD! You can shutdown your computer, or press ENTER to reboot.",
        L"ReactOS LiveCD",
        MB_OK);
    return 0;
}
开发者ID:hoangduit,项目名称:reactos,代码行数:61,代码来源:install.c

示例6: MessageBox

	void MessageBox(const wchar_t* caption, const wchar_t* message)
	{
		MessageBoxW(0, message, caption, MB_OK | MB_ICONINFORMATION);
	}
开发者ID:Valrandir,项目名称:BoreCastle,代码行数:4,代码来源:Engine.Win32.cpp

示例7: D3DX11CompileFromFileW

	//----------------------------------------------------------------------------------------------------
	bool EEPoints2D::InitializePoints2D()
	{
		if (!s_isPoints2DInitialized)
		{
			HRESULT result;
			ID3D10Blob *errorMessage = NULL;
			ID3D10Blob *vertexShaderBuffer = NULL;
			ID3D10Blob *pixelShaderBuffer = NULL;

			result = D3DX11CompileFromFileW(L"EEShader\\EEPoints2DShader.hlsl", NULL, NULL, "PointsVS", "vs_5_0", D3D10_SHADER_ENABLE_STRICTNESS, 0, NULL, &vertexShaderBuffer, &errorMessage, NULL);
			if (FAILED(result))
			{
				if (errorMessage)
				{
					MessageBoxA(NULL, (char*)errorMessage->GetBufferPointer(), "ShaderCompileError", MB_YESNO);
					SAFE_RELEASE(errorMessage);
					SAFE_RELEASE(vertexShaderBuffer);
					SAFE_RELEASE(pixelShaderBuffer);
				}
				else
				{
					MessageBoxW(NULL, L"CompileShader´íÎó!", L"´íÎó", MB_OK);
					SAFE_RELEASE(errorMessage);
					SAFE_RELEASE(vertexShaderBuffer);
					SAFE_RELEASE(pixelShaderBuffer);
				}
				return FALSE;
			}
			result = D3DX11CompileFromFileW(L"EEShader\\EEPoints2DShader.hlsl", NULL, NULL, "PointsPS", "ps_5_0", D3D10_SHADER_ENABLE_STRICTNESS, 0, NULL, &pixelShaderBuffer, &errorMessage, NULL);
			if (FAILED(result))
			{
				if (errorMessage)
				{
					MessageBoxA(NULL, (char*)errorMessage->GetBufferPointer(), "ShaderCompileError", MB_YESNO);
					SAFE_RELEASE(errorMessage);
					SAFE_RELEASE(vertexShaderBuffer);
					SAFE_RELEASE(pixelShaderBuffer);
				}
				else
				{
					MessageBoxW(NULL, L"CompileShader´íÎó!", L"´íÎó", MB_OK);
					SAFE_RELEASE(errorMessage);
					SAFE_RELEASE(vertexShaderBuffer);
					SAFE_RELEASE(pixelShaderBuffer);
				}
				return FALSE;
			}
			result = EECore::s_EECore->GetDevice()->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &s_pointsVS);
			if (FAILED(result))
			{
				SAFE_RELEASE(errorMessage);
				SAFE_RELEASE(vertexShaderBuffer);
				SAFE_RELEASE(pixelShaderBuffer);
				return false;
			}
			result = EECore::s_EECore->GetDevice()->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &s_pointsPS);
			if (FAILED(result))
			{
				SAFE_RELEASE(errorMessage);
				SAFE_RELEASE(vertexShaderBuffer);
				SAFE_RELEASE(pixelShaderBuffer);
				return false;
			}
			D3D11_INPUT_ELEMENT_DESC inputDesc[1] =
			{
				{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
			};
			result = EECore::s_EECore->GetDevice()->CreateInputLayout(inputDesc, 1, vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), &s_pointsIL);
			if (FAILED(result))
			{
				SAFE_RELEASE(errorMessage);
				SAFE_RELEASE(vertexShaderBuffer);
				SAFE_RELEASE(pixelShaderBuffer);
				return false;
			}

			SAFE_RELEASE(errorMessage);
			SAFE_RELEASE(vertexShaderBuffer);
			SAFE_RELEASE(pixelShaderBuffer);

			s_isPoints2DInitialized = true;
		}

		return true;
	}
开发者ID:GarfieldZHU,项目名称:Emerald,代码行数:86,代码来源:EEPoints2D.cpp

示例8: ImportRegistryFile

static BOOL ImportRegistryFile(HWND hWnd)
{
    BOOL bRet = FALSE;
    OPENFILENAME ofn;
    WCHAR Caption[128], szTitle[512], szText[512];
    HKEY hKeyRoot;
    LPCWSTR pszKeyPath;

    /* Figure out in which key path we are importing */
    pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);

    InitOpenFileName(hWnd, &ofn);
    LoadStringW(hInst, IDS_IMPORT_REG_FILE, Caption, COUNT_OF(Caption));
    ofn.lpstrTitle = Caption;
    ofn.Flags |= OFN_ENABLESIZING;
    /*    ofn.lCustData = ;*/
    if (GetOpenFileName(&ofn))
    {
        /* Look at the extension of the file to determine its type */
        if (ofn.nFileExtension >= 1 &&
            _wcsicmp(ofn.lpstrFile + ofn.nFileExtension, L"reg") == 0) /* REGEDIT4 or Windows Registry Editor Version 5.00 */
        {
            /* Open the file */
            FILE* fp = _wfopen(ofn.lpstrFile, L"r");

            /* Import it */
            if (fp == NULL || !import_registry_file(fp))
            {
                /* Error opening the file */
                LoadStringW(hInst, IDS_APP_TITLE, szTitle, COUNT_OF(szTitle));
                LoadStringW(hInst, IDS_IMPORT_ERROR, szText, COUNT_OF(szText));
                InfoMessageBox(hWnd, MB_OK | MB_ICONERROR, szTitle, szText, ofn.lpstrFile);
                bRet = FALSE;
            }
            else
            {
                /* Show successful import */
                LoadStringW(hInst, IDS_APP_TITLE, szTitle, COUNT_OF(szTitle));
                LoadStringW(hInst, IDS_IMPORT_OK, szText, COUNT_OF(szText));
                InfoMessageBox(hWnd, MB_OK | MB_ICONINFORMATION, szTitle, szText, ofn.lpstrFile);
                bRet = TRUE;
            }

            /* Close the file */
            if (fp) fclose(fp);
        }
        else /* Registry Hive Files */
        {
            LoadStringW(hInst, IDS_QUERY_IMPORT_HIVE_CAPTION, szTitle, COUNT_OF(szTitle));
            LoadStringW(hInst, IDS_QUERY_IMPORT_HIVE_MSG, szText, COUNT_OF(szText));

            /* Display a confirmation message */
            if (MessageBoxW(g_pChildWnd->hWnd, szText, szTitle, MB_ICONWARNING | MB_YESNO) == IDYES)
            {
                LONG lResult;
                HKEY hSubKey;

                /* Open the subkey */
                lResult = RegOpenKeyExW(hKeyRoot, pszKeyPath, 0, KEY_WRITE, &hSubKey);
                if (lResult == ERROR_SUCCESS)
                {
                    /* Enable the 'restore' privilege, restore the hive then disable the privilege */
                    EnablePrivilege(SE_RESTORE_NAME, NULL, TRUE);
                    lResult = RegRestoreKey(hSubKey, ofn.lpstrFile, REG_FORCE_RESTORE);
                    EnablePrivilege(SE_RESTORE_NAME, NULL, FALSE);

                    /* Flush the subkey and close it */
                    RegFlushKey(hSubKey);
                    RegCloseKey(hSubKey);
                }

                /* Set the return value */
                bRet = (lResult == ERROR_SUCCESS);

                /* Display error, if any */
                if (!bRet) ErrorMessageBox(hWnd, Caption, lResult);
            }
        }
    }
    else
    {
        CheckCommDlgError(hWnd);
    }

    /* refresh tree and list views */
    RefreshTreeView(g_pChildWnd->hTreeWnd);
    pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
    RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, pszKeyPath);

    return bRet;
}
开发者ID:reactos,项目名称:reactos,代码行数:91,代码来源:framewnd.c

示例9: SettingsDlgProc

static
INT_PTR CALLBACK
SettingsDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
{
    switch (Msg)
    {
    case WM_INITDIALOG:
    {
        NewSettingsInfo = SettingsInfo;
        InitSettingsControls(hDlg, &SettingsInfo);
    }
    break;

    case WM_COMMAND:
    {
        switch (LOWORD(wParam))
        {
        case IDC_CHOOSE:
            ChooseFolder(hDlg);
            break;

        case IDC_SAVE_WINDOW_POS:
            IS_CHECKED(NewSettingsInfo.bSaveWndPos, IDC_SAVE_WINDOW_POS);
            break;

        case IDC_UPDATE_AVLIST:
            IS_CHECKED(NewSettingsInfo.bUpdateAtStart, IDC_UPDATE_AVLIST);
            break;

        case IDC_LOG_ENABLED:
            IS_CHECKED(NewSettingsInfo.bLogEnabled, IDC_LOG_ENABLED);
            break;

        case IDC_DEL_AFTER_INSTALL:
            IS_CHECKED(NewSettingsInfo.bDelInstaller, IDC_DEL_AFTER_INSTALL);
            break;

        case IDC_PROXY_DEFAULT:
            NewSettingsInfo.Proxy = 0;
            EnableWindow(GetDlgItem(hDlg, IDC_PROXY_SERVER), FALSE);
            EnableWindow(GetDlgItem(hDlg, IDC_NO_PROXY_FOR), FALSE);
            break;

        case IDC_NO_PROXY:
            NewSettingsInfo.Proxy = 1;
            EnableWindow(GetDlgItem(hDlg, IDC_PROXY_SERVER), FALSE);
            EnableWindow(GetDlgItem(hDlg, IDC_NO_PROXY_FOR), FALSE);
            break;

        case IDC_USE_PROXY:
            NewSettingsInfo.Proxy = 2;
            EnableWindow(GetDlgItem(hDlg, IDC_PROXY_SERVER), TRUE);
            EnableWindow(GetDlgItem(hDlg, IDC_NO_PROXY_FOR), TRUE);
            break;

        case IDC_DEFAULT_SETTINGS:
            FillDefaultSettings(&NewSettingsInfo);
            InitSettingsControls(hDlg, &NewSettingsInfo);
            break;

        case IDOK:
        {
            WCHAR szDir[MAX_PATH];
            WCHAR szProxy[MAX_PATH];
            WCHAR szNoProxy[MAX_PATH];
            DWORD dwAttr;

            GetWindowTextW(GetDlgItem(hDlg, IDC_DOWNLOAD_DIR_EDIT),
                           szDir, MAX_PATH);

            GetWindowTextW(GetDlgItem(hDlg, IDC_PROXY_SERVER),
                           szProxy, MAX_PATH);
            StringCbCopyW(NewSettingsInfo.szProxyServer, sizeof(NewSettingsInfo.szProxyServer), szProxy);

            GetWindowTextW(GetDlgItem(hDlg, IDC_NO_PROXY_FOR),
                           szNoProxy, MAX_PATH);
            StringCbCopyW(NewSettingsInfo.szNoProxyFor, sizeof(NewSettingsInfo.szNoProxyFor), szNoProxy);

            dwAttr = GetFileAttributesW(szDir);
            if (dwAttr != INVALID_FILE_ATTRIBUTES &&
                    (dwAttr & FILE_ATTRIBUTE_DIRECTORY))
            {
                StringCbCopyW(NewSettingsInfo.szDownloadDir,
                              sizeof(NewSettingsInfo.szDownloadDir),
                              szDir);
            }
            else
            {
                WCHAR szMsgText[MAX_STR_LEN];

                LoadStringW(hInst,
                            IDS_CHOOSE_FOLDER_ERROR,
                            szMsgText, sizeof(szMsgText) / sizeof(WCHAR));

                if (MessageBoxW(hDlg, szMsgText, NULL, MB_YESNO) == IDYES)
                {
                    if (CreateDirectoryW(szDir, NULL))
                    {
                        EndDialog(hDlg, LOWORD(wParam));
                    }
//.........这里部分代码省略.........
开发者ID:Strongc,项目名称:reactos,代码行数:101,代码来源:settingsdlg.c

示例10: MessageBoxW

DWORD WINAPI FTHelper2::FaceTrackingThread()
{
    FT_CAMERA_CONFIG videoConfig;
    FT_CAMERA_CONFIG depthConfig;
    FT_CAMERA_CONFIG* pDepthConfig = NULL;

    // Try to get the Kinect camera to work
    HRESULT hr = m_KinectSensor.Init(m_depthType, m_depthRes, m_bNearMode, FALSE, m_colorType, m_colorRes, m_bSeatedSkeleton);
    if (SUCCEEDED(hr))
    {
        m_KinectSensorPresent = TRUE;
        m_KinectSensor.GetVideoConfiguration(&videoConfig);
        m_KinectSensor.GetDepthConfiguration(&depthConfig);
        pDepthConfig = &depthConfig;
    }
    else
    {
        m_KinectSensorPresent = FALSE;

        MessageBoxW(m_hWnd, L"Could not initialize the Kinect sensor.\n", L"Face Tracker Initialization Error\n", MB_OK);
        return 1;
    }

    m_UserContext = new FTHelperContext[m_nbUsers];
    if (m_UserContext != 0)
    {
        memset(m_UserContext, 0, sizeof(FTHelperContext)*m_nbUsers);
    }
    else
    {
        MessageBoxW(m_hWnd, L"Could not allocate user context array.\n", L"Face Tracker Initialization Error\n", MB_OK);
        return 2;
    }

    for (UINT i=0; i<m_nbUsers; i++)
    {
        // Try to start the face tracker.
        m_UserContext[i].m_pFaceTracker = FTCreateFaceTracker(_opt);
        if (!m_UserContext[i].m_pFaceTracker)
        {
            MessageBoxW(m_hWnd, L"Could not create the face tracker.\n", L"Face Tracker Initialization Error\n", MB_OK);
            return 3;
        }

        hr = m_UserContext[i].m_pFaceTracker->Initialize(&videoConfig, pDepthConfig, NULL, NULL);
        if (FAILED(hr))
        {
            WCHAR path[512], buffer[1024];
            GetCurrentDirectoryW(ARRAYSIZE(path), path);
            wsprintf(buffer, L"Could not initialize face tracker (%s) for user %d.\n", path, i);

            MessageBoxW(m_hWnd, buffer, L"Face Tracker Initialization Error\n", MB_OK);

            return 4;
        }
        m_UserContext[i].m_pFaceTracker->CreateFTResult(&m_UserContext[i].m_pFTResult);
        if (!m_UserContext[i].m_pFTResult)
        {
            MessageBoxW(m_hWnd, L"Could not initialize the face tracker result for user %d.\n", L"Face Tracker Initialization Error\n", MB_OK);
            return 5;
        }
        m_UserContext[i].m_LastTrackSucceeded = false;
    }

    // Initialize the RGB image.
    m_colorImage = FTCreateImage();
    if (!m_colorImage || FAILED(hr = m_colorImage->Allocate(videoConfig.Width, videoConfig.Height, FTIMAGEFORMAT_UINT8_B8G8R8X8)))
    {
        return 6;
    }

    if (pDepthConfig)
    {
        m_depthImage = FTCreateImage();
        if (!m_depthImage || FAILED(hr = m_depthImage->Allocate(depthConfig.Width, depthConfig.Height, FTIMAGEFORMAT_UINT16_D13P3)))
        {
            return 7;
        }
    }

    SetCenterOfImage(NULL);

    while (m_ApplicationIsRunning)
    {
        CheckCameraInput();
        InvalidateRect(m_hWnd, NULL, FALSE);
        UpdateWindow(m_hWnd);
        Sleep(16);
    }
    return 0;
}
开发者ID:ailove-lab,项目名称:Ailove-Kinect,代码行数:91,代码来源:FTHelper2.cpp

示例11: _CmdWndProc


//.........这里部分代码省略.........
        if (valueName && ModifyValue(hWnd, hKey, valueName, TRUE))
            RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath);
        break;
    case ID_EDIT_RENAME:
        if (GetFocus() == g_pChildWnd->hListWnd)
        {
            if(ListView_GetSelectedCount(g_pChildWnd->hListWnd) == 1)
            {
                item = ListView_GetNextItem(g_pChildWnd->hListWnd, -1, LVNI_SELECTED);
                if(item > -1)
                {
                    (void)ListView_EditLabel(g_pChildWnd->hListWnd, item);
                }
            }
        }
        else if (GetFocus() == g_pChildWnd->hTreeWnd)
        {
            /* Get focused entry of treeview (if any) */
            HTREEITEM hItem = TreeView_GetSelection(g_pChildWnd->hTreeWnd);
            if (hItem != NULL)
                (void)TreeView_EditLabel(g_pChildWnd->hTreeWnd, hItem);
        }
        break;
    case ID_EDIT_DELETE:
    {
        if (GetFocus() == g_pChildWnd->hListWnd)
        {
            UINT nSelected = ListView_GetSelectedCount(g_pChildWnd->hListWnd);
            if(nSelected >= 1)
            {
                WCHAR msg[128], caption[128];
                LoadStringW(hInst, IDS_QUERY_DELETE_CONFIRM, caption, COUNT_OF(caption));
                LoadStringW(hInst, (nSelected == 1 ? IDS_QUERY_DELETE_ONE : IDS_QUERY_DELETE_MORE), msg, COUNT_OF(msg));
                if(MessageBoxW(g_pChildWnd->hWnd, msg, caption, MB_ICONQUESTION | MB_YESNO) == IDYES)
                {
                    int ni, errs;

                    item = -1;
                    errs = 0;
                    while((ni = ListView_GetNextItem(g_pChildWnd->hListWnd, item, LVNI_SELECTED)) > -1)
                    {
                        valueName = GetValueName(g_pChildWnd->hListWnd, item);
                        if(RegDeleteValueW(hKey, valueName) != ERROR_SUCCESS)
                        {
                            errs++;
                        }
                        item = ni;
                    }

                    RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath);
                    if(errs > 0)
                    {
                        LoadStringW(hInst, IDS_ERR_DELVAL_CAPTION, caption, COUNT_OF(caption));
                        LoadStringW(hInst, IDS_ERR_DELETEVALUE, msg, COUNT_OF(msg));
                        MessageBoxW(g_pChildWnd->hWnd, msg, caption, MB_ICONSTOP);
                    }
                }
            }
        }
        else if (GetFocus() == g_pChildWnd->hTreeWnd)
        {
            if (keyPath == 0 || *keyPath == 0)
            {
                MessageBeep(MB_ICONHAND);
            }
            else if (DeleteKey(hWnd, hKeyRoot, keyPath))
开发者ID:reactos,项目名称:reactos,代码行数:67,代码来源:framewnd.c

示例12: DoUnlock

static
BOOL
DoUnlock(
    IN HWND hwndDlg,
    IN PGINA_CONTEXT pgContext,
    OUT LPINT Action)
{
    WCHAR Buffer1[256];
    WCHAR Buffer2[256];
    LPWSTR UserName = NULL;
    LPWSTR Password = NULL;
    BOOL res = FALSE;

    if (GetTextboxText(hwndDlg, IDC_USERNAME, &UserName) && *UserName == '\0')
    {
        HeapFree(GetProcessHeap(), 0, UserName);
        return FALSE;
    }

    if (GetTextboxText(hwndDlg, IDC_PASSWORD, &Password))
    {
        if (UserName != NULL && Password != NULL &&
                wcscmp(UserName, pgContext->UserName) == 0 &&
                wcscmp(Password, pgContext->Password) == 0)
        {
            *Action = WLX_SAS_ACTION_UNLOCK_WKSTA;
            res = TRUE;
        }
        else if (wcscmp(UserName, pgContext->UserName) == 0 &&
                 wcscmp(Password, pgContext->Password) != 0)
        {
            /* Wrong Password */
            LoadStringW(pgContext->hDllInstance, IDS_LOCKEDWRONGPASSWORD, Buffer2, 256);
            LoadStringW(pgContext->hDllInstance, IDS_COMPUTERLOCKED, Buffer1, 256);
            MessageBoxW(hwndDlg, Buffer2, Buffer1, MB_OK | MB_ICONERROR);
        }
        else
        {
            /* Wrong user name */
            if (DoAdminUnlock(pgContext, UserName, NULL, Password))
            {
                *Action = WLX_SAS_ACTION_UNLOCK_WKSTA;
                res = TRUE;
            }
            else
            {
                LoadStringW(pgContext->hDllInstance, IDS_LOCKEDWRONGUSER, Buffer1, 256);
                wsprintfW(Buffer2, Buffer1, pgContext->Domain, pgContext->UserName);
                LoadStringW(pgContext->hDllInstance, IDS_COMPUTERLOCKED, Buffer1, 256);
                MessageBoxW(hwndDlg, Buffer2, Buffer1, MB_OK | MB_ICONERROR);
            }
        }
    }

    if (UserName != NULL)
        HeapFree(GetProcessHeap(), 0, UserName);

    if (Password != NULL)
        HeapFree(GetProcessHeap(), 0, Password);

    return res;
}
开发者ID:Strongc,项目名称:reactos,代码行数:62,代码来源:gui.c

示例13: Fatal

static void Fatal(DWORD dw, wchar_t* message, ...) 
{
	void *lpDisplayBuf, *lpMsgBuf;
	
	if(dw == 0) {
		// If no return code was specified, we assume that the message
		// contains a function name that failed. In that case, we retrieve
		// the system error message for the last-error code
		dw = GetLastError();
		
		FormatMessage(
			FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |FORMAT_MESSAGE_IGNORE_INSERTS,
			NULL,
			dw,
			MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
			(wchar_t*) &lpMsgBuf,
			0,
			NULL
		);

		// Allocate our buffer for the error message.
		lpDisplayBuf = (void*)LocalAlloc(
			LMEM_ZEROINIT,
			(lstrlenW((const wchar_t*)lpMsgBuf) + lstrlenW((const wchar_t*)message) + 47) * sizeof(wchar_t)
		);
		_snwprintf(
			(wchar_t*)lpDisplayBuf,
			LocalSize(lpDisplayBuf) / sizeof(wchar_t),
			L"FATAL: %s failed with error %d: %s",
			message,
			dw,
			lpMsgBuf
		);
	} else {
		// Otherwise, we assume that the error message is a format string.
		va_list args = NULL;
		
		// Allocate buffer for our resulting format string.
		lpMsgBuf = (void*)LocalAlloc(
			LMEM_ZEROINIT,
			(lstrlenW((const wchar_t*)message) + 8) * sizeof(wchar_t)
		);
		_snwprintf(
			(wchar_t*)lpMsgBuf,
			LocalSize(lpMsgBuf) / sizeof(wchar_t),
			L"FATAL: %s",
			message
		);
		
		// Might as well use the maximum allowed buffer, since there's no way I know of the
		// get the size of the resulting buff.
		lpDisplayBuf = (void*)LocalAlloc(LMEM_ZEROINIT, 4096 * sizeof(wchar_t));
		memset(lpDisplayBuf, 0, 4096 * sizeof(wchar_t));
		va_start(args, lpMsgBuf);
		_vsnwprintf(
			(wchar_t*)lpDisplayBuf,
			4096,
			lpMsgBuf,
			args
		);
		va_end(args);
	}
	MessageBoxW(NULL, (const wchar_t*)lpDisplayBuf, L"Fatal Error", MB_OK | MB_ICONERROR);
	LocalFree(lpMsgBuf);
	LocalFree(lpDisplayBuf);
	ExitProcess(dw); 
}
开发者ID:daleathan,项目名称:depends-launcher,代码行数:67,代码来源:depends-launcher.c

示例14: HandleCommandMessage

BOOL HandleCommandMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    int wmID, wmEvent;
    wmID = LOWORD(wParam);
    wmEvent = HIWORD(wParam);

    switch (wmEvent)
    {
    case BN_CLICKED:
        switch (wmID)
        {
        case IDC_ADD:
            {
                SaveLocalizationText(); // save any current changes to the database

                plString buttonText;
                wchar_t buff[256];
                GetDlgItemText(gEditDlg, IDC_ADD, buff, 256);
                buttonText = plString::FromWchar(buff);

                if (buttonText == "Add Element")
                {
                    plAddElementDlg dlg(gCurrentPath);
                    if (dlg.DoPick(gEditDlg))
                    {
                        plString path = dlg.GetValue(); // path is age.set.name
                        if (!pfLocalizationDataMgr::Instance().AddElement(path))
                            MessageBox(gEditDlg, L"Couldn't add new element because one already exists with that name!", L"Error", MB_ICONERROR | MB_OK);
                        else
                        {
                            gCurrentPath = "";
                            plLocTreeView::ClearTreeView(gTreeView);
                            plLocTreeView::FillTreeViewFromData(gTreeView, path);
                            UpdateEditDlg(path);
                        }
                    }
                }
                else if (buttonText == "Add Localization")
                {
                    plAddLocalizationDlg dlg(gCurrentPath);
                    if (dlg.DoPick(gEditDlg))
                    {
                        plString newLanguage = dlg.GetValue();
                        plString ageName, setName, elementName, elementLanguage;
                        SplitLocalizationPath(gCurrentPath, ageName, setName, elementName, elementLanguage);
                        plString key = plString::Format("%s.%s.%s", ageName.c_str(), setName.c_str(), elementName.c_str());
                        if (!pfLocalizationDataMgr::Instance().AddLocalization(key, newLanguage))
                            MessageBox(gEditDlg, L"Couldn't add additional localization!", L"Error", MB_ICONERROR | MB_OK);
                        else
                        {
                            plString path = plString::Format("%s.%s", key.c_str(), newLanguage.c_str());
                            gCurrentPath = "";
                            plLocTreeView::ClearTreeView(gTreeView);
                            plLocTreeView::FillTreeViewFromData(gTreeView, path);
                            UpdateEditDlg(path);
                        }
                    }
                }
                return FALSE;
            }
        case IDC_DELETE:
            {
                SaveLocalizationText(); // save any current changes to the database

                plString messageText = plString::Format("Are you sure that you want to delete %s?", gCurrentPath.c_str());
                int res = MessageBoxW(gEditDlg, messageText.ToWchar(), L"Delete", MB_ICONQUESTION | MB_YESNO);
                if (res == IDYES)
                {
                    plString buttonText;
                    wchar_t buff[256];
                    GetDlgItemText(gEditDlg, IDC_DELETE, buff, 256);
                    buttonText = plString::FromWchar(buff);

                    if (buttonText == "Delete Element")
                    {
                        if (!pfLocalizationDataMgr::Instance().DeleteElement(gCurrentPath))
                            MessageBox(gEditDlg, L"Couldn't delete element!", L"Error", MB_ICONERROR | MB_OK);
                        else
                        {
                            plString path = gCurrentPath;
                            gCurrentPath = "";
                            plLocTreeView::ClearTreeView(gTreeView);
                            plLocTreeView::FillTreeViewFromData(gTreeView, path);
                            UpdateEditDlg(path);
                        }
                    }
                    else if (buttonText == "Delete Localization")
                    {
                        plString ageName, setName, elementName, elementLanguage;
                        SplitLocalizationPath(gCurrentPath, ageName, setName, elementName, elementLanguage);
                        plString key = plString::Format("%s.%s.%s", ageName.c_str(), setName.c_str(), elementName.c_str());
                        if (!pfLocalizationDataMgr::Instance().DeleteLocalization(key, elementLanguage))
                            MessageBox(gEditDlg, L"Couldn't delete localization!", L"Error", MB_ICONERROR | MB_OK);
                        else
                        {
                            plString path = gCurrentPath;
                            gCurrentPath = "";
                            plLocTreeView::ClearTreeView(gTreeView);
                            plLocTreeView::FillTreeViewFromData(gTreeView, path);
                            UpdateEditDlg(path);
//.........这里部分代码省略.........
开发者ID:Filtik,项目名称:Plasma,代码行数:101,代码来源:plEditDlg.cpp

示例15: DoInjectHooks

int DoInjectHooks(LPWSTR asCmdArg)
{
	gbInShutdown = TRUE; // чтобы не возникло вопросов при выходе
	gnRunMode = RM_SETHOOK64;
	LPWSTR pszNext = asCmdArg;
	LPWSTR pszEnd = NULL;
	BOOL lbForceGui = FALSE;
	PROCESS_INFORMATION pi = {NULL};


	pi.hProcess = (HANDLE)wcstoul(pszNext, &pszEnd, 16);

	if (pi.hProcess && pszEnd && *pszEnd)
	{
		pszNext = pszEnd+1;
		pi.dwProcessId = wcstoul(pszNext, &pszEnd, 10);
	}

	if (pi.dwProcessId && pszEnd && *pszEnd)
	{
		pszNext = pszEnd+1;
		pi.hThread = (HANDLE)wcstoul(pszNext, &pszEnd, 16);
	}

	if (pi.hThread && pszEnd && *pszEnd)
	{
		pszNext = pszEnd+1;
		pi.dwThreadId = wcstoul(pszNext, &pszEnd, 10);
	}

	if (pi.dwThreadId && pszEnd && *pszEnd)
	{
		pszNext = pszEnd+1;
		lbForceGui = wcstoul(pszNext, &pszEnd, 10);
	}


	#ifdef SHOW_INJECT_MSGBOX
	wchar_t szDbgMsg[512], szTitle[128];
	PROCESSENTRY32 pinf;
	GetProcessInfo(pi.dwProcessId, &pinf);
	_wsprintf(szTitle, SKIPLEN(countof(szTitle)) L"ConEmuCD PID=%u", GetCurrentProcessId());
	_wsprintf(szDbgMsg, SKIPLEN(countof(szDbgMsg)) L"InjectsTo PID=%s {%s}\nConEmuCD PID=%u", asCmdArg ? asCmdArg : L"", pinf.szExeFile, GetCurrentProcessId());
	MessageBoxW(NULL, szDbgMsg, szTitle, MB_SYSTEMMODAL);
	#endif


	if (pi.hProcess && pi.hThread && pi.dwProcessId && pi.dwThreadId)
	{
		// Аргумент abForceGui не использовался
		CINJECTHK_EXIT_CODES iHookRc = InjectHooks(pi, /*lbForceGui,*/ gbLogProcess);

		if (iHookRc == CIH_OK/*0*/)
		{
			return CERR_HOOKS_WAS_SET;
		}

		// Ошибку (пока во всяком случае) лучше показать, для отлова возможных проблем
		DWORD nErrCode = GetLastError();
		//_ASSERTE(iHookRc == 0); -- ассерт не нужен, есть MsgBox
		wchar_t szDbgMsg[255], szTitle[128];
		_wsprintf(szTitle, SKIPLEN(countof(szTitle)) L"ConEmuC, PID=%u", GetCurrentProcessId());
		_wsprintf(szDbgMsg, SKIPLEN(countof(szDbgMsg)) L"ConEmuC.X, PID=%u\nInjecting hooks into PID=%u\nFAILED, code=%i:0x%08X", GetCurrentProcessId(), pi.dwProcessId, iHookRc, nErrCode);
		MessageBoxW(NULL, szDbgMsg, szTitle, MB_SYSTEMMODAL);
	}
	else
	{
		//_ASSERTE(pi.hProcess && pi.hThread && pi.dwProcessId && pi.dwThreadId);
		wchar_t szDbgMsg[512], szTitle[128];
		_wsprintf(szTitle, SKIPLEN(countof(szTitle)) L"ConEmuC, PID=%u", GetCurrentProcessId());
		_wsprintf(szDbgMsg, SKIPLEN(countof(szDbgMsg)) L"ConEmuC.X, PID=%u\nCmdLine parsing FAILED (%u,%u,%u,%u,%u)!\n%s",
			GetCurrentProcessId(), LODWORD(pi.hProcess), LODWORD(pi.hThread), pi.dwProcessId, pi.dwThreadId, lbForceGui, //-V205
			asCmdArg);
		MessageBoxW(NULL, szDbgMsg, szTitle, MB_SYSTEMMODAL);
	}

	return CERR_HOOKS_FAILED;
}
开发者ID:1833183060,项目名称:ConEmu,代码行数:78,代码来源:Actions.cpp


注:本文中的MessageBoxW函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。