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


C++ CDuiString::AssignString方法代码示例

本文整理汇总了C++中CDuiString::AssignString方法的典型用法代码示例。如果您正苦于以下问题:C++ CDuiString::AssignString方法的具体用法?C++ CDuiString::AssignString怎么用?C++ CDuiString::AssignString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CDuiString的用法示例。


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

示例1: DisplayError

ErrRet DisplayError(const char* errorTitle,
                    const char* errorText,
                    const char* errorDescription,
                    const char* fileName,
                    int lineNumber)
{
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(_WIN64) || defined(WIN64) || defined(__WIN64__)
    const int MODULE_NAME_SIZE = 255;
    char moduleName[MODULE_NAME_SIZE];

    // attempt to get the module name
    if (!GetModuleFileNameA(NULL, moduleName, MODULE_NAME_SIZE))
    {
        char *msg = "<unknown application>";
//			_tcscpy_s(moduleName, _tcsclen(msg), msg);
        strcpy_s(moduleName,strlen(msg),msg);
    }

    // build a collosal string containing the entire asster message
    const	int		MAX_BUFFER_SIZE = 1024;
    char	buffer[MAX_BUFFER_SIZE];

    int Size = _snprintf_s(buffer,
                           MAX_BUFFER_SIZE,
                           "%s\n\nProgram : %s\nFile : %s\nLine : %d\nError: %s\nComment: %s\n"
                           "Abort to exit (or debug), Retry to continue,\n"
                           "Ignore to disregard all occurances of this error\n",
                           errorTitle,
                           moduleName,
                           fileName,
                           lineNumber,
                           errorText,
                           errorDescription);


    // place a copy of the message into the clipboard
    if (OpenClipboard(NULL))
    {
        size_t bufferLength = strlen(buffer);
        HGLOBAL hMem = GlobalAlloc(GHND|GMEM_DDESHARE, bufferLength+1);

        if (hMem)
        {
            BYTE* pMem = (BYTE*)GlobalLock(hMem);
            memcpy(pMem, buffer, bufferLength);
            GlobalUnlock(hMem);
            EmptyClipboard();
            SetClipboardData(CF_TEXT, hMem);
        }

        CloseClipboard();
    }


    // find the top most window of the current application
    HWND hWndParent = GetActiveWindow();
    if (NULL != hWndParent)
    {
        hWndParent = GetLastActivePopup(hWndParent);
    }
    CDuiString sbuf;
    sbuf.AssignString(buffer);
    // put up a message box with the error
    int iRet = MessageBox ( hWndParent,
                            sbuf.GetData(),
                            _T( "ERROR NOTIFICATION..." ),
                            MB_TASKMODAL|MB_SETFOREGROUND|MB_ABORTRETRYIGNORE|MB_ICONERROR);

    // Figure out what to do on the return.
    if (iRet == IDRETRY)
    {
        // ignore this error and continue
        return (ERRRET_CONTINUE);
    }
    if (iRet == IDIGNORE)
    {
        // ignore this error and continue,
        // plus never stop on this error again (handled by the caller)
        return (ERRRET_IGNORE);
    }

    // The return has to be IDABORT, but does the user want to enter the debugger
    // or just exit the application?
    iRet = MessageBox(	hWndParent,
                        _T("Do you wish to debug the last error?"),
                        _T( "DEBUG OR EXIT?" ),
                        MB_TASKMODAL|MB_SETFOREGROUND|MB_YESNO|MB_ICONQUESTION);

    if (iRet == IDYES)
    {
        // inform the caller to break on the current line of execution
        return (ERRRET_BREAKPOINT);
    }

    // must be a full-on termination of the app
    ExitProcess ( (UINT)-1 ) ;
    return (ERRRET_ABORT);

#else

//.........这里部分代码省略.........
开发者ID:uvbs,项目名称:myduilib,代码行数:101,代码来源:AssertX.cpp


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