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


C++ ShowErrorMessage函数代码示例

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


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

示例1: ReadHeightmapPNG

/**
 * Reads the heightmap and/or size of the heightmap from a PNG file.
 * If map == NULL only the size of the PNG is read, otherwise a map
 * with grayscale pixels is allocated and assigned to *map.
 */
static bool ReadHeightmapPNG(char *filename, uint *x, uint *y, byte **map)
{
	FILE *fp;
	png_structp png_ptr = NULL;
	png_infop info_ptr  = NULL;

	fp = FioFOpenFile(filename, "rb");
	if (fp == NULL) {
		ShowErrorMessage(STR_ERROR_PNGMAP, STR_ERROR_PNGMAP_FILE_NOT_FOUND, WL_ERROR);
		return false;
	}

	png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
	if (png_ptr == NULL) {
		ShowErrorMessage(STR_ERROR_PNGMAP, STR_ERROR_PNGMAP_MISC, WL_ERROR);
		fclose(fp);
		return false;
	}

	info_ptr = png_create_info_struct(png_ptr);
	if (info_ptr == NULL || setjmp(png_jmpbuf(png_ptr))) {
		ShowErrorMessage(STR_ERROR_PNGMAP, STR_ERROR_PNGMAP_MISC, WL_ERROR);
		fclose(fp);
		png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
		return false;
	}

	png_init_io(png_ptr, fp);

	/* Allocate memory and read image, without alpha or 16-bit samples
	 * (result is either 8-bit indexed/grayscale or 24-bit RGB) */
	png_set_packing(png_ptr);
	png_read_png(png_ptr, info_ptr, PNG_TRANSFORM_PACKING | PNG_TRANSFORM_STRIP_ALPHA | PNG_TRANSFORM_STRIP_16, NULL);

	/* Maps of wrong colour-depth are not used.
	 * (this should have been taken care of by stripping alpha and 16-bit samples on load) */
	if ((png_get_channels(png_ptr, info_ptr) != 1) && (png_get_channels(png_ptr, info_ptr) != 3) && (png_get_bit_depth(png_ptr, info_ptr) != 8)) {
		ShowErrorMessage(STR_ERROR_PNGMAP, STR_ERROR_PNGMAP_IMAGE_TYPE, WL_ERROR);
		fclose(fp);
		png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
		return false;
	}

	if (map != NULL) {
		*map = MallocT<byte>(png_get_image_width(png_ptr, info_ptr) * png_get_image_height(png_ptr, info_ptr));
		ReadHeightmapPNGImageData(*map, png_ptr, info_ptr);
	}

	*x = png_get_image_width(png_ptr, info_ptr);
	*y = png_get_image_height(png_ptr, info_ptr);

	fclose(fp);
	png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
	return true;
}
开发者ID:jemmyw,项目名称:openttd,代码行数:60,代码来源:heightmap.cpp

示例2: DoCommandP

/*!
 * Toplevel network safe docommand function for the current company. Must not be called recursively.
 * The callback is called when the command succeeded or failed. The parameters
 * \a tile, \a p1, and \a p2 are from the #CommandProc function. The parameter \a cmd is the command to execute.
 * The parameter \a my_cmd is used to indicate if the command is from a company or the server.
 *
 * @param tile The tile to perform a command on (see #CommandProc)
 * @param p1 Additional data for the command (see #CommandProc)
 * @param p2 Additional data for the command (see #CommandProc)
 * @param cmd The command to execute (a CMD_* value)
 * @param callback A callback function to call after the command is finished
 * @param text The text to pass
 * @param my_cmd indicator if the command is from a company or server (to display error messages for a user)
 * @return \c true if the command succeeded, else \c false.
 */
bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text, bool my_cmd)
{
	/* Cost estimation is generally only done when the
	 * local user presses shift while doing somthing.
	 * However, in case of incoming network commands,
	 * map generation or the pause button we do want
	 * to execute. */
	bool estimate_only = _shift_pressed && IsLocalCompany() &&
			!_generating_world &&
			!(cmd & CMD_NETWORK_COMMAND) &&
			(cmd & CMD_ID_MASK) != CMD_PAUSE;

	/* We're only sending the command, so don't do
	 * fancy things for 'success'. */
	bool only_sending = _networking && !(cmd & CMD_NETWORK_COMMAND);

	/* Where to show the message? */
	int x = TileX(tile) * TILE_SIZE;
	int y = TileY(tile) * TILE_SIZE;

	if (_pause_mode != PM_UNPAUSED && !IsCommandAllowedWhilePaused(cmd)) {
		ShowErrorMessage(GB(cmd, 16, 16), STR_ERROR_NOT_ALLOWED_WHILE_PAUSED, WL_INFO, x, y);
		return false;
	}

#ifdef ENABLE_NETWORK
	/* Only set p2 when the command does not come from the network. */
	if (!(cmd & CMD_NETWORK_COMMAND) && GetCommandFlags(cmd) & CMD_CLIENT_ID && p2 == 0) p2 = CLIENT_ID_SERVER;
#endif

	CommandCost res = DoCommandPInternal(tile, p1, p2, cmd, callback, text, my_cmd, estimate_only);
	if (res.Failed()) {
		/* Only show the error when it's for us. */
		StringID error_part1 = GB(cmd, 16, 16);
		if (estimate_only || (IsLocalCompany() && error_part1 != 0 && my_cmd)) {
			ShowErrorMessage(error_part1, res.GetErrorMessage(), WL_INFO, x, y, res.GetTextRefStackSize(), res.GetTextRefStack());
		}
	} else if (estimate_only) {
		ShowEstimatedCostOrIncome(res.GetCost(), x, y);
	} else if (!only_sending && res.GetCost() != 0 && tile != 0 && IsLocalCompany() && _game_mode != GM_EDITOR) {
		/* Only show the cost animation when we did actually
		 * execute the command, i.e. we're not sending it to
		 * the server, when it has cost the local company
		 * something. Furthermore in the editor there is no
		 * concept of cost, so don't show it there either. */
		ShowCostOrIncomeAnimation(x, y, GetSlopePixelZ(x, y), res.GetCost());
	}

	if (!estimate_only && !only_sending && callback != NULL) {
		callback(res, tile, p1, p2);
	}

	return res.Succeeded();
}
开发者ID:ComLock,项目名称:OpenTTD,代码行数:69,代码来源:command.cpp

示例3: ShowErrorMessage

void CTblInfoView::SaveLocalCache()
{
    //prepare the content firstly
    CString strContent = "";

    //updatetime
    strContent += m_strUpdateTime;
    strContent += SEP_RECORD;


    map<CString, CString>::iterator it;
    for (it = m_map_req_resp.begin(); 
         it != m_map_req_resp.end(); 
         it++)
    {
        strContent += it->first;
        strContent += SEP_RECORD;
        strContent += it->second;
        strContent += SEP_RECORD;
    }
    
    //now write to file
    HANDLE hFile = ::CreateFile(CACHE_FILE, 
                                GENERIC_WRITE,          //desired access
                                FILE_SHARE_READ,        //share mode
                                NULL,                   //Security
                                CREATE_ALWAYS,
                                FILE_ATTRIBUTE_NORMAL,
                                NULL);

    if (INVALID_HANDLE_VALUE == hFile)
    {
        ShowErrorMessage();
        return;
    }	

    DWORD dwLen      = strContent.GetLength();
    DWORD dwWriteLen = 0;
    BOOL  bRet       = FALSE;

    bRet = WriteFile(hFile, 
                    (LPCVOID)strContent.GetBuffer(0),
                    dwLen, 
                    &dwWriteLen, 
                    NULL
                    );

    if (!bRet)
    {
        ShowErrorMessage();
    }
   
    CloseHandle(hFile);
}
开发者ID:xuwenbo,项目名称:Ph2_StudManage,代码行数:54,代码来源:TblInfoView.cpp

示例4: ReadHeightmapBMP

/**
 * Reads the heightmap and/or size of the heightmap from a BMP file.
 * If map == nullptr only the size of the BMP is read, otherwise a map
 * with grayscale pixels is allocated and assigned to *map.
 */
static bool ReadHeightmapBMP(const char *filename, uint *x, uint *y, byte **map)
{
	FILE *f;
	BmpInfo info;
	BmpData data;
	BmpBuffer buffer;

	/* Init BmpData */
	memset(&data, 0, sizeof(data));

	f = FioFOpenFile(filename, "rb", HEIGHTMAP_DIR);
	if (f == nullptr) {
		ShowErrorMessage(STR_ERROR_BMPMAP, STR_ERROR_PNGMAP_FILE_NOT_FOUND, WL_ERROR);
		return false;
	}

	BmpInitializeBuffer(&buffer, f);

	if (!BmpReadHeader(&buffer, &info, &data)) {
		ShowErrorMessage(STR_ERROR_BMPMAP, STR_ERROR_BMPMAP_IMAGE_TYPE, WL_ERROR);
		fclose(f);
		BmpDestroyData(&data);
		return false;
	}

	/* Check if image dimensions don't overflow a size_t to avoid memory corruption. */
	if ((uint64)info.width * info.height >= (size_t)-1 / (info.bpp == 24 ? 3 : 1)) {
		ShowErrorMessage(STR_ERROR_BMPMAP, STR_ERROR_HEIGHTMAP_TOO_LARGE, WL_ERROR);
		fclose(f);
		BmpDestroyData(&data);
		return false;
	}

	if (map != nullptr) {
		if (!BmpReadBitmap(&buffer, &info, &data)) {
			ShowErrorMessage(STR_ERROR_BMPMAP, STR_ERROR_BMPMAP_IMAGE_TYPE, WL_ERROR);
			fclose(f);
			BmpDestroyData(&data);
			return false;
		}

		*map = MallocT<byte>(info.width * info.height);
		ReadHeightmapBMPImageData(*map, &info, &data);
	}

	BmpDestroyData(&data);

	*x = info.width;
	*y = info.height;

	fclose(f);
	return true;
}
开发者ID:OpenTTD,项目名称:OpenTTD,代码行数:58,代码来源:heightmap.cpp

示例5: OnClick

	virtual void OnClick(Point pt, int widget)
	{
#ifdef ENABLE_NETWORK
		/* Do not create a network server when you (just) have closed one of the game
		 * creation/load windows for the network server. */
		if (IsInsideMM(widget, SGI_GENERATE_GAME, SGI_EDIT_SCENARIO + 1)) _is_network_server = false;
#endif /* ENABLE_NETWORK */

		switch (widget) {
			case SGI_GENERATE_GAME:
				if (_ctrl_pressed) {
					StartNewGameWithoutGUI(GENERATE_NEW_SEED);
				} else {
					ShowGenerateLandscape();
				}
				break;

			case SGI_LOAD_GAME:      ShowSaveLoadDialog(SLD_LOAD_GAME); break;
			case SGI_PLAY_SCENARIO:  ShowSaveLoadDialog(SLD_LOAD_SCENARIO); break;
			case SGI_PLAY_HEIGHTMAP: ShowSaveLoadDialog(SLD_LOAD_HEIGHTMAP); break;
			case SGI_EDIT_SCENARIO:  StartScenarioEditor(); break;

			case SGI_PLAY_NETWORK:
				if (!_network_available) {
					ShowErrorMessage(STR_NETWORK_ERROR_NOTAVAILABLE, INVALID_STRING_ID, 0, 0);
				} else {
					ShowNetworkGameWindow();
				}
				break;

			case SGI_TEMPERATE_LANDSCAPE: case SGI_ARCTIC_LANDSCAPE:
			case SGI_TROPIC_LANDSCAPE: case SGI_TOYLAND_LANDSCAPE:
				this->RaiseWidget(_settings_newgame.game_creation.landscape + SGI_TEMPERATE_LANDSCAPE);
				SetNewLandscapeType(widget - SGI_TEMPERATE_LANDSCAPE);
				this->SetLandscapeButtons();
				break;

			case SGI_OPTIONS:         ShowGameOptions(); break;
			case SGI_DIFFICULTIES:    ShowGameDifficulty(); break;
			case SGI_SETTINGS_OPTIONS:ShowGameSettings(); break;
			case SGI_GRF_SETTINGS:    ShowNewGRFSettings(true, true, false, &_grfconfig_newgame); break;
			case SGI_CONTENT_DOWNLOAD:
				if (!_network_available) {
					ShowErrorMessage(STR_NETWORK_ERROR_NOTAVAILABLE, INVALID_STRING_ID, 0, 0);
				} else {
					ShowNetworkContentListWindow();
				}
				break;
			case SGI_AI_SETTINGS:     ShowAIConfigWindow(); break;
			case SGI_EXIT:            HandleExitGameRequest(); break;
		}
	}
开发者ID:Voxar,项目名称:OpenTTD,代码行数:52,代码来源:intro_gui.cpp

示例6: MakeScreenshot

/**
 * Make an actual screenshot.
 * @param t    the type of screenshot to make.
 * @param name the name to give to the screenshot.
 * @return true iff the screenshot was made successfully
 */
bool MakeScreenshot(ScreenshotType t, const char *name)
{
	if (t == SC_VIEWPORT) {
		/* First draw the dirty parts of the screen and only then change the name
		 * of the screenshot. This way the screenshot will always show the name
		 * of the previous screenshot in the 'successful' message instead of the
		 * name of the new screenshot (or an empty name). */
		UndrawMouseCursor();
		DrawDirtyBlocks();
	}

	_screenshot_name[0] = '\0';
	if (name != NULL) strecpy(_screenshot_name, name, lastof(_screenshot_name));

	bool ret;
	switch (t) {
		case SC_VIEWPORT:
			ret = MakeSmallScreenshot(false);
			break;

		case SC_CRASHLOG:
			ret = MakeSmallScreenshot(true);
			break;

		case SC_ZOOMEDIN:
		case SC_DEFAULTZOOM:
		case SC_WORLD:
			ret = MakeLargeWorldScreenshot(t);
			break;

		case SC_HEIGHTMAP: {
			const ScreenshotFormat *sf = _screenshot_formats + _cur_screenshot_format;
			ret = MakeHeightmapScreenshot(MakeScreenshotName(HEIGHTMAP_NAME, sf->extension));
			break;
		}

		default:
			NOT_REACHED();
	}

	if (ret) {
		SetDParamStr(0, _screenshot_name);
		ShowErrorMessage(STR_MESSAGE_SCREENSHOT_SUCCESSFULLY, INVALID_STRING_ID, WL_WARNING);
	} else {
		ShowErrorMessage(STR_ERROR_SCREENSHOT_FAILED, INVALID_STRING_ID, WL_ERROR);
	}

	return ret;
}
开发者ID:Ayutac,项目名称:OpenTTD,代码行数:55,代码来源:screenshot.cpp

示例7: DEF_CONTENT_RECEIVE_COMMAND

DEF_CONTENT_RECEIVE_COMMAND(Client, PACKET_CONTENT_SERVER_CONTENT)
{
	if (this->curFile == NULL) {
		delete this->curInfo;
		/* When we haven't opened a file this must be our first packet with metadata. */
		this->curInfo = new ContentInfo;
		this->curInfo->type     = (ContentType)p->Recv_uint8();
		this->curInfo->id       = (ContentID)p->Recv_uint32();
		this->curInfo->filesize = p->Recv_uint32();
		p->Recv_string(this->curInfo->filename, lengthof(this->curInfo->filename));

		if (!this->BeforeDownload()) {
			this->Close();
			return false;
		}
	} else {
		/* We have a file opened, thus are downloading internal content */
		size_t toRead = (size_t)(p->size - p->pos);
		if (fwrite(p->buffer + p->pos, 1, toRead, this->curFile) != toRead) {
			DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
			ShowErrorMessage(STR_CONTENT_ERROR_COULD_NOT_DOWNLOAD_FILE_NOT_WRITABLE, STR_CONTENT_ERROR_COULD_NOT_DOWNLOAD, WL_ERROR);
			this->Close();
			fclose(this->curFile);
			this->curFile = NULL;

			return false;
		}

		this->OnDownloadProgress(this->curInfo, (uint)toRead);

		if (toRead == 0) this->AfterDownload();
	}

	return true;
}
开发者ID:oshepherd,项目名称:openttd-progsigs,代码行数:35,代码来源:network_content.cpp

示例8: FinalizePasting

/**
 * Finish a paste process.
 * @return Total cost.
 */
static CommandCost FinalizePasting()
{
	/* Set error string parameters */
	CopyInDParam(0, _current_pasting->err_params, lengthof(_current_pasting->err_params));
	/* Set error summary message (see COPY_PASTE_ERR_SUMMARY_PARAM for details). */
	SetDParam(COPY_PASTE_ERR_SUMMARY_PARAM, _current_pasting->err_summary);
	/* Store the error tile so the GUI (CcPaste) can highlight it. */
	_paste_err_tile = _current_pasting->err_tile;

	CommandCost ret;
	if (_current_pasting->had_success) {
		/* Return overal cost of the operation */
		ret = CommandCost(EXPENSES_CONSTRUCTION, _current_pasting->overal_cost);
		/* Here we are about to return a success. However, there could occured some meaningful
		 * errors (those except "already built", "already leveled" etc.) and we should inform
		 * the user that not everything went right. Show the message now. */
		if ((_current_pasting->dc_flags & DC_EXEC) && IsLocalCompany() && GetPasteErrorImportance(_current_pasting->err_message) > GetPasteErrorImportance(STR_ERROR_NOTHING_TO_DO)) {
			ShowErrorMessage(_current_pasting->err_summary, _current_pasting->err_message, WL_INFO);
		} else {
			/* If we are not showing error message then clear the error tile to prevent GUI
			 * (CcPaste) from higlighting it. */
			_paste_err_tile = INVALID_TILE;
		}
	} else {
		/* Return an error if we didn't have any success. */
		ret = CommandCost(_current_pasting->err_message);
	}

	/* cleanup */
	delete _current_pasting;
	_current_pasting = NULL;

	return ret;
}
开发者ID:koreapyj,项目名称:openttd-yapp,代码行数:38,代码来源:copypaste_cmd.cpp

示例9: OnCreate

BOOL OnCreate(HWND hwnd, LPCREATESTRUCT /*lpCreateStruct*/)
{
    DEV_BROADCAST_DEVICEINTERFACE di = { 0 };
    di.dbcc_size = sizeof(di);
    di.dbcc_devicetype  = DBT_DEVTYP_DEVICEINTERFACE;
    di.dbcc_classguid  = KSCATEGORY_CAPTURE; 

    g_hdevnotify = RegisterDeviceNotification(
        hwnd,
        &di,
        DEVICE_NOTIFY_WINDOW_HANDLE
        );

    if (g_hdevnotify == NULL)
    {
        ShowErrorMessage(
            hwnd, 
            L"RegisterDeviceNotification failed.", 
            HRESULT_FROM_WIN32(GetLastError())
            );
        return FALSE;
    }

    return TRUE;
}
开发者ID:Essjay1,项目名称:Windows-classic-samples,代码行数:25,代码来源:winmain.cpp

示例10: OnTimeout

	virtual void OnTimeout()
	{
		/* This test protects against using widgets 11 and 12 which are only available
		 * in those saveload modes. */
		if (!(_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO || _saveload_mode == SLD_SAVE_HEIGHTMAP)) return;

		if (this->IsWidgetLowered(WID_SL_DELETE_SELECTION)) { // Delete button clicked
			if (!FiosDelete(this->filename_editbox.text.buf)) {
				ShowErrorMessage(STR_ERROR_UNABLE_TO_DELETE_FILE, INVALID_STRING_ID, WL_ERROR);
			} else {
				this->InvalidateData();
				/* Reset file name to current date on successful delete */
				if (_saveload_mode == SLD_SAVE_GAME) GenerateFileName();
			}
		} else if (this->IsWidgetLowered(WID_SL_SAVE_GAME)) { // Save button clicked
			if (_saveload_mode  == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) {
				_switch_mode = SM_SAVE_GAME;
				FiosMakeSavegameName(_file_to_saveload.name, this->filename_editbox.text.buf, sizeof(_file_to_saveload.name));
			} else {
				_switch_mode = SM_SAVE_HEIGHTMAP;
				FiosMakeHeightmapName(_file_to_saveload.name, this->filename_editbox.text.buf, sizeof(_file_to_saveload.name));
			}

			/* In the editor set up the vehicle engines correctly (date might have changed) */
			if (_game_mode == GM_EDITOR) StartupEngines();
		}
	}
开发者ID:Creat,项目名称:OpenTTD-Separation,代码行数:27,代码来源:fios_gui.cpp

示例11: SetRect

void CPreview::OnMediaItemSet(MFP_MEDIAITEM_SET_EVENT * /*pEvent*/)
{
    HRESULT hr = S_OK;

    SIZE szVideo = { 0 };
    RECT rc = { 0 };

    // Adjust the preview window to match the native size
    // of the captured video.

    hr = m_pPlayer->GetNativeVideoSize(&szVideo, NULL);

    if (SUCCEEDED(hr))
    {
        SetRect(&rc, 0, 0, szVideo.cx, szVideo.cy);

        AdjustWindowRect(
            &rc, 
            GetWindowLong(m_hwnd, GWL_STYLE),
            TRUE
            );

        SetWindowPos(m_hwnd, 0, 0, 0, rc.right - rc.left, rc.bottom - rc.top, 
            SWP_NOZORDER | SWP_NOMOVE | SWP_NOOWNERZORDER);

        hr = m_pPlayer->Play();
    }

    if (FAILED(hr))
    {
        ShowErrorMessage(NULL, L"Preview error.", hr);
    }
}
开发者ID:Essjay1,项目名称:Windows-classic-samples,代码行数:33,代码来源:Preview.cpp

示例12: ShowErrorMessage

void CPreview::OnMediaItemCreated(MFP_MEDIAITEM_CREATED_EVENT *pEvent)
{
    HRESULT hr = S_OK;

    if (m_pPlayer)
    {
        // Check if there is video.

        BOOL bHasVideo = FALSE, bIsSelected = FALSE;

        hr = pEvent->pMediaItem->HasVideo(&bHasVideo, &bIsSelected);

        if (SUCCEEDED(hr))
        {
            m_bHasVideo = bHasVideo && bIsSelected;

            // Set this media item on the player.
            hr = m_pPlayer->SetMediaItem(pEvent->pMediaItem);
        }
    }

    if (FAILED(hr))
    {
        ShowErrorMessage(NULL, L"Preview error.", hr);
    }
}
开发者ID:Essjay1,项目名称:Windows-classic-samples,代码行数:26,代码来源:Preview.cpp

示例13: WinMain

int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */,
  #ifdef UNDER_CE
  LPWSTR
  #else
  LPSTR
  #endif
  /* lpCmdLine */, int /* nCmdShow */)
{
  g_hInstance = (HINSTANCE)hInstance;

  NT_CHECK

  try
  {
    return WinMain2();
  }
  catch(const CNewException &)
  {
    ErrorMessageForHRESULT(E_OUTOFMEMORY);
    return NExitCode::kMemoryError;
  }
  catch(...)
  {
    ShowErrorMessage(kUnknownExceptionMessage);
    return NExitCode::kFatalError;
  }
}
开发者ID:0vermind,项目名称:NeoLoader,代码行数:27,代码来源:Main.cpp

示例14: FatalError

/**
 * Fatal error handler. Provides support for formatting the system
 * error message and showing errors with format strings etc blahblah.
 */
STATIC NORETURN FatalError(DWORD dwError, LPTSTR lpMessage, ...)
{
	DWORD dwExit;
	va_list lpArgs = NULL;
	LPTSTR lpDisplayBuf = NULL;
	
	// If dwError has not been set, use the value of GetLastError
	if(dwError == ERROR_SUCCESS) {
		dwError = GetLastError();
	}
	// Format message against args.
	va_start(lpArgs, lpMessage);
	lpDisplayBuf = StringCchVAPrintf(lpMessage, lpArgs);
	va_end(lpArgs);
	
	// If dwError contains an error code, get the system error message for it.
	if(dwError != ERROR_SUCCESS) {
		TCHAR *lpErrMsg = NULL, *lpTemp = NULL;
		dwExit = dwError;
		FormatMessage(
			FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |FORMAT_MESSAGE_IGNORE_INSERTS,
			NULL, dwError, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpErrMsg, 0, NULL
		);
		lpTemp = StringCchAPrintf(_T("%s - Windows Error [0x%08X]: %s"), lpDisplayBuf, dwError, lpErrMsg);
		xfree(lpDisplayBuf);
		lpDisplayBuf = lpTemp;
		LocalFree((HLOCAL)lpErrMsg);
	} else {
		dwExit = 1;
	}
	
	ShowErrorMessage(lpDisplayBuf);
	xfree(lpDisplayBuf);
	ExitProcess(dwExit);
}
开发者ID:juntalis,项目名称:FO4EditUtils,代码行数:39,代码来源:TES5EditStub.c

示例15: OnTimeout

	virtual void OnTimeout()
	{
		/* Widgets WID_SL_DELETE_SELECTION and WID_SL_SAVE_GAME only exist when saving to a file. */
		if (this->fop != SLO_SAVE) return;

		if (this->IsWidgetLowered(WID_SL_DELETE_SELECTION)) { // Delete button clicked
			if (!FiosDelete(this->filename_editbox.text.buf)) {
				ShowErrorMessage(STR_ERROR_UNABLE_TO_DELETE_FILE, INVALID_STRING_ID, WL_ERROR);
			} else {
				this->InvalidateData(SLIWD_RESCAN_FILES);
				/* Reset file name to current date on successful delete */
				if (this->abstract_filetype == FT_SAVEGAME) GenerateFileName();
			}
		} else if (this->IsWidgetLowered(WID_SL_SAVE_GAME)) { // Save button clicked
			if (this->abstract_filetype == FT_SAVEGAME || this->abstract_filetype == FT_SCENARIO) {
				FiosMakeSavegameName(_file_to_saveload.name, this->filename_editbox.text.buf, lastof(_file_to_saveload.name));
				if (FioCheckFileExists(_file_to_saveload.name, Subdirectory::SAVE_DIR)) {
					ShowQuery(STR_SAVELOAD_OVERWRITE_TITLE, STR_SAVELOAD_OVERWRITE_WARNING, this, SaveLoadWindow::SaveGameConfirmationCallback);
				} else {
					_switch_mode = SM_SAVE_GAME;
				}
			} else {
				FiosMakeHeightmapName(_file_to_saveload.name, this->filename_editbox.text.buf, lastof(_file_to_saveload.name));
				if (FioCheckFileExists(_file_to_saveload.name, Subdirectory::SAVE_DIR)) {
					ShowQuery(STR_SAVELOAD_OVERWRITE_TITLE, STR_SAVELOAD_OVERWRITE_WARNING, this, SaveLoadWindow::SaveHeightmapConfirmationCallback);
				} else {
					_switch_mode = SM_SAVE_HEIGHTMAP;
				}
			}

			/* In the editor set up the vehicle engines correctly (date might have changed) */
			if (_game_mode == GM_EDITOR) StartupEngines();
		}
	}
开发者ID:M3Henry,项目名称:openttd,代码行数:34,代码来源:fios_gui.cpp


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