TCHAR CLocale::MinAlphaUpper() { // TODO do this properly, this won't work for Japanese // we should go through the characters from the beginning // until we reach the first upper case character, probably // using isupper() // For Japanese this function is probably no use anyway, since // there is no real concept of upper case characters return TCHAR('A'); }
void CStrings::Ascii2Unicode(char *Source, CString &Target) { TCHAR ch; Target.Empty(); while (*Source) { ch = TCHAR(*(Source++)); Target.AppendChar(ch); } }
const TCHAR* UTextProperty::ImportText_Internal( const TCHAR* Buffer, void* Data, int32 PortFlags, UObject* Parent, FOutputDevice* ErrorText ) const { FText* Text = GetPropertyValuePtr(Data); FString BufferAsString; if( !(PortFlags & PPF_Delimited) ) { BufferAsString = FString(Buffer); // in order to indicate that the value was successfully imported, advance the buffer past the last character that was imported Buffer += FCString::Strlen(Buffer); } else { // require quoted string here if (*Buffer != TCHAR('"')) { ErrorText->Logf(TEXT("Missing opening '\"' in string property value: %s"), Buffer); return NULL; } const TCHAR* Start = Buffer; FString Temp; Buffer = UPropertyHelpers::ReadToken(Buffer, Temp); if (Buffer == NULL) { return NULL; } if (Buffer > Start && Buffer[-1] != TCHAR('"')) { ErrorText->Logf(TEXT("Missing terminating '\"' in string property value: %s"), Start); return NULL; } BufferAsString = FString(Temp); } *Text = FText::FromString( FString(BufferAsString) ); return Buffer; }
MFileXMLProcessor::MFileXMLProcessor(PWScore *pcore, UUIDVector *pPossible_Aliases, UUIDVector *pPossible_Shortcuts, MultiCommands *p_multicmds, CReport *prpt) : m_pXMLcore(pcore), m_delimiter(TCHAR('^')), m_pPossible_Aliases(pPossible_Aliases), m_pPossible_Shortcuts(pPossible_Shortcuts), m_pmulticmds(p_multicmds), m_prpt(prpt) { }
//--------------------------------------------------------------------------------------- // Attempt to load blueprint with given qualified class path UBlueprint * FSkookumScriptEditor::load_blueprint_asset(const FString & class_path, bool * sk_class_deleted_p) { // Try to extract asset path from meta file of Sk class FString full_class_path = m_overlay_path / class_path; FString meta_file_path = full_class_path / TEXT("!Class.sk-meta"); FString meta_file_text; *sk_class_deleted_p = false; if (FFileHelper::LoadFileToString(meta_file_text, *meta_file_path)) { // Found meta file - try to extract asset path contained in it int32 package_path_begin_pos = meta_file_text.Find(m_package_name_key); if (package_path_begin_pos >= 0) { package_path_begin_pos += m_package_name_key.Len(); int32 package_path_end_pos = meta_file_text.Find(TEXT("\""), ESearchCase::CaseSensitive, ESearchDir::FromStart, package_path_begin_pos); if (package_path_end_pos > package_path_begin_pos) { // Successfully got the path of the package, so assemble with asset name and load the asset FString package_path = meta_file_text.Mid(package_path_begin_pos, package_path_end_pos - package_path_begin_pos); FString class_name = FPaths::GetCleanFilename(class_path); // If there's a dot in the name, use portion right of it int dot_pos = -1; if (class_name.FindChar(TCHAR('.'), dot_pos)) { class_name = class_name.Mid(dot_pos + 1); } FString asset_path = package_path + TEXT(".") + class_name; UBlueprint * blueprint_p = LoadObject<UBlueprint>(nullptr, *asset_path); if (!blueprint_p) { // Asset not found, ask the user what to do FText title = FText::Format(FText::FromString(TEXT("Asset Not Found For {0}")), FText::FromString(class_name)); if (FMessageDialog::Open( EAppMsgType::YesNo, FText::Format(FText::FromString( TEXT("Cannot find Blueprint asset belonging to SkookumScript class '{0}'. ") TEXT("It was originally generated from the asset '{1}' but this asset appears to no longer exist. ") TEXT("Maybe it was deleted or renamed. ") TEXT("If you no longer need the SkookumScript class '{0}', you can fix this issue by deleting the class. ") TEXT("Would you like to delete the SkookumScript class '{0}'?")), FText::FromString(class_name), FText::FromString(asset_path)), &title) == EAppReturnType::Yes) { // User requested deletion, so nuke it IFileManager::Get().DeleteDirectory(*full_class_path, false, true); *sk_class_deleted_p = true; get_runtime()->on_class_scripts_changed_by_editor(class_name, ISkookumScriptRuntime::ChangeType_deleted); } } return blueprint_p; } } } return nullptr; }
void CXMLNode::UniformString(CString& str) { // Non-alphanumeric characters which will not be ignored static LPCTSTR pszOK = _T("'-&/,;#()"); str.Trim(); BOOL bSpace = TRUE; for ( int nPos = 0 ; nPos < str.GetLength() ; nPos++ ) { int nChar = (int)(unsigned short)str.GetAt( nPos ); if ( nChar <= 32 ) { if ( bSpace ) { str = str.Left( nPos ) + str.Mid( nPos + 1 ); nPos--; } else { if ( nChar != 32 ) str.SetAt( nPos, 32 ); bSpace = TRUE; } } else if ( ! _istalnum( TCHAR( nChar ) ) && nChar < 0xC0 && _tcschr( pszOK, TCHAR( nChar ) ) == NULL ) { if ( nPos == 0 || str.GetAt( nPos - 1 ) == ' ' ) str = str.Left( nPos ) + str.Mid( nPos + 1 ); else { LPTSTR pszTemp = _tcsninc( str, nPos ); pszTemp[ 0 ] = ' '; bSpace = TRUE; } } else { bSpace = FALSE; } } }
bool FStringAssetReference::ImportTextItem(const TCHAR*& Buffer, int32 PortFlags, UObject* Parent, FOutputDevice* ErrorText) { FString ImportedPath = TEXT(""); const TCHAR* NewBuffer = UPropertyHelpers::ReadToken(Buffer, ImportedPath, 1); if (!NewBuffer) { return false; } Buffer = NewBuffer; if (ImportedPath == TEXT("None")) { ImportedPath = TEXT(""); } else { if (*Buffer == TCHAR('\'')) { NewBuffer = UPropertyHelpers::ReadToken(Buffer, ImportedPath, 1); if (!NewBuffer) { return false; } Buffer = NewBuffer; if (*Buffer++ != TCHAR('\'')) { return false; } } } SetPath(MoveTemp(ImportedPath)); #if WITH_EDITOR // Consider this a load, so Config string asset references get cooked if (FCoreUObjectDelegates::StringAssetReferenceLoaded.IsBound()) { FCoreUObjectDelegates::StringAssetReferenceLoaded.Execute(ToString()); } #endif // WITH_EDITOR return true; }
//============================================================================================ // Загружает строки из внешнего файла //============================================================================================ void Internat::LoadMessages() { int index,i,l,l2,offset; // 1. открываем файл FILE *fin; if(0!=fopen_s(&fin,"messages.bkb","rb")) { return; } while(NULL!=fgetws(buf,4095,fin)) { // Убираем перевод строки Strip(buf); // отделяем номер от остальной строки l=wcslen(buf); for(i=0;i<l;i++) { if((L' '==buf[i])||(TCHAR(9)==buf[i])) // Пробел или табуляция, разделяющий номер ресурса и строку { //OutputDebugString(L"Space found\n"); if(TCHAR(0xFEFF)==buf[0]) offset=1; else offset=0; // Ищем BOM swscanf_s(buf+offset,L"%d",&index); // Пропускаем BOM, считываем номер ресурса if((index<0)||(index>=BKB_MAX_MESSAGES)) goto cleanup; // Файл битый, дальше не читаем if(messages[index]) goto cleanup; // Строка уже загружена => файл битый, дальше не читаем l2=wcslen(&buf[i+1])+1; // Длина оставшейся строки + место под ноль в конце messages[index]=new TCHAR[l2]; wcscpy_s(messages[index],l2,&buf[i+1]); break; // поиск пробела-табуляции прекращён } } // for } // закрываем файл cleanup: fclose(fin); }
const TCHAR* UAssetObjectProperty::ImportText_Internal( const TCHAR* InBuffer, void* Data, int32 PortFlags, UObject* Parent, FOutputDevice* ErrorText ) const { FAssetPtr& AssetPtr = *(FAssetPtr*)Data; FString NewPath; const TCHAR* Buffer = InBuffer; const TCHAR* NewBuffer = UPropertyHelpers::ReadToken( Buffer, NewPath, 1 ); if( !NewBuffer ) { return NULL; } Buffer = NewBuffer; if( NewPath==TEXT("None") ) { AssetPtr = NULL; } else { if( *Buffer == TCHAR('\'') ) { // A ' token likely means we're looking at an asset string in the form "Texture2d'/Game/UI/HUD/Actions/Barrel'" and we need to read and append the path part // We have to skip over the first ' as UPropertyHelpers::ReadToken doesn't read single-quoted strings correctly, but does read a path correctly NewPath += *Buffer++; // Append the leading ' NewBuffer = UPropertyHelpers::ReadToken( Buffer, NewPath, 1 ); if( !NewBuffer ) { return NULL; } Buffer = NewBuffer; if( *Buffer != TCHAR('\'') ) { return NULL; } NewPath += *Buffer++; // Append the trailing ' } FStringAssetReference ID(NewPath); AssetPtr = ID; } return Buffer; }
BOOL CArrayMatrix::InputRow(const CString & RS) { int len=lstrlen(RS); int tprow=0; for(int i=0;i<len;i++) { if(RS[i]==TCHAR('\n')) tprow++; } if(tprow==0) return FALSE; m_wRow=tprow; return TRUE; }
static LPTSTR GetLastErrorText(LPTSTR lpszBuf, DWORD dwSize) { DWORD dwRet; DWORD dwError = GetLastError(); LPTSTR lpszTemp = NULL; dwRet = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ARGUMENT_ARRAY, NULL, dwError, LANG_NEUTRAL, (LPTSTR) &lpszTemp, 0, NULL); if (dwRet == 0 || (long) dwSize < (long) (dwRet + 14)) lpszBuf[0] = TCHAR('\0'); else { lpszTemp[lstrlen(lpszTemp) - 2] = TCHAR('\0'); _stprintf(lpszBuf, _T("%s (0x%x)"), lpszTemp, dwError); } if (lpszTemp != NULL) LocalFree((HLOCAL) lpszTemp); return lpszBuf; }
void clearScreen() { HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); CONSOLE_SCREEN_BUFFER_INFO csbi; GetConsoleScreenBufferInfo(hConsole, &csbi); DWORD dwConSize = csbi.dwSize.X * csbi.dwSize.Y; COORD upperLeft = { 0, 0 }; DWORD dwCharsWritten; FillConsoleOutputCharacter(hConsole, TCHAR(' '), dwConSize, upperLeft, &dwCharsWritten); SetConsoleCursorPosition(hConsole, upperLeft); }
//-------------------------------------------------------------------- //-------------------------------------------------------------------- bool CBFFileHelper::replaceExtension(LPCTSTR fname, LPCTSTR ext, CString& res) { res = fname; int dotPos = res.ReverseFind(TCHAR('.')); if (dotPos == -1) { res.Empty(); return false; } res = res.Left(dotPos + 1); res += ext; return true; }
void usage() { _TCHAR * progname = g_progname; _TCHAR * endName = _tcsrchr(g_progname, TCHAR('\\')); if (endName) { progname = endName + 1; } #if !defined(TWO_PIPE) fprintf(stderr, "usage: %s [-l] pipe [address] port\n\n", progname); fprintf(stderr, "where - pipe is the name of the local pipe which the\n" " Microsoft Windows Debugger will try to connect to.\n" " address [optional] is the address of the target\n" " to connect to if Xen is listening.\n" " port is the (decimal) number of the TCP port Xen\n" " is configured to listen on or to connect to on\n" " this machine.\n\n" " Note: If sockpipe is listening then the port must\n" " be open through this machine's firewall.\n\n" " -l [optional] if specified, enable logging. N.B.\n" " the log file can become quite large very quickly.\n" "example: %s my_pipe 7001\n", progname); #else fprintf(stderr, "usage: %s [-l] pipe1 pipe2\n\n", progname); fprintf(stderr, "where - pipe1 is the name of the local pipe which the\n" " Microsoft Windows Debugger will try to connect to.\n" " pipe2 is the full path pipe name to the pipe being\n" " offered by a machine to be debugged.\n\n" " -l [optional] if specified, enable logging. N.B.\n" " the log file can become quite large very quickly.\n" "example: %s my_pipe \\remotemachine\pipe\debugee_name\n", progname); #endif fprintf(stderr, "\n" "This program (%s) needs to be started BEFORE either the\n" "kernel debugger or the system to be debugged.\n" "To configure the serial ports of a Xen guest to connect,\n" "add a line to the guest configuration file of the form-\n\n" "serial='tcp:proxy-machine:port_number'\n\n" "where proxy-machine is the IP address or name of the machine where\n" "this program is running and port_number is the TCP port number it\n" "is listening on.\n\n" "To configure the serial ports of a Xen guest to listen,\n" "add a line to the guest configuration file of the form-\n\n" "serial='tcp::port_number,server,nodelay'\n\n" "where port_number is the TCP port number the program should\n" "connect to.\n", progname); my_exit(1); }
TCHAR CLocale::DecimalPoint() { // TODO should really allow multiple character decimal point markers // although I'm not sure if any languages use them. TCHAR Buf[10]; if (GetLocaleInfo(m_LocaleID, LOCALE_SDECIMAL, Buf, sizeof(Buf))) { if (strlen(Buf) == 1) return (Buf[0]); } // default return (TCHAR('.')); }
static double atofs(LPCTSTR s) { const TCHAR tcBase[] = { TEXT("XxOoQqBb") }; const int base[] = {16, 8, 8, 2 }; TCHAR *pC = LPSTR(s), c, *pB; while (isspace(c = *pC)) pC++; if ( c == TCHAR('0') && (pB = strchr(tcBase, pC[1])) ) return (double)strtoul(pC + 2, NULL, base[(pB - tcBase)/ 2]); else return strtod(pC, NULL); }
size_t PWSfileV1V2::ReadCBC(unsigned char &type, StringX &data) { unsigned char *buffer = NULL; size_t buffer_len = 0; size_t retval; ASSERT(m_fish != NULL && m_IV != NULL); retval = _readcbc(m_fd, buffer, buffer_len, type, m_fish, m_IV, m_terminal); if (buffer_len > 0) { #ifdef UNICODE wchar_t *wc = new wchar_t[buffer_len+1]; size_t wcLen = pws_os::mbstowcs(wc, buffer_len + 1, reinterpret_cast<const char *>(buffer), buffer_len, false); ASSERT(wcLen != 0); if (wcLen < buffer_len + 1) wc[wcLen] = TCHAR('\0'); else wc[buffer_len] = TCHAR('\0'); data = wc; trashMemory(wc, wcLen); delete[] wc; #else StringX str((const char *)buffer, buffer_len); data = str; #endif trashMemory(buffer, buffer_len); delete[] buffer; } else { data = _T(""); // no need to delete[] buffer, since _readcbc will not allocate if // buffer_len is zero } return retval; }
void CArrayMatrix::ProcStringEnter(CString & sHead) { CString m_temp=sHead; int len=lstrlen(sHead); sHead.GetBufferSetLength(len+1); int j=0; for(int i=0;i<len;i++) { if(m_temp[i]==TCHAR('\n')) { if((i+1)!=len&&m_temp[i+1]==TCHAR('\n')) continue; else { sHead.SetAt(j,m_temp[i]); j++; } } else {sHead.SetAt(j,m_temp[i]);j++;} } sHead.SetAt(j,TCHAR('\0')); j=lstrlen(sHead); sHead.GetBufferSetLength(j); }
//------------------------------------------------------------------------- bool ResetPermissionDialog::GetFolderText( stringT &Folder, bool bWarnRoot, bool bAddWildCard, bool bQuoteIfNeeded) { TCHAR Path[MAX_PATH * 4]; UINT len = GetDlgItemText( hDlg, IDTXT_FOLDER, Path, _countof(Path)); if (len == 0) return false; if (bWarnRoot) { // Warn if resetting root permissions if (_tcslen(Path) == 3 && Path[1] == _TCHAR(':') && Path[2] == _TCHAR('\\')) { if (MessageBox(hDlg, STR_ROOT_WARNING, STR_WARNING, MB_YESNO | MB_ICONWARNING) == IDNO) return false; } // Warn if tool is used on unsupported file system if (!IsSupportedFileSystem(Path)) { if (MessageBox(hDlg, STR_FS_NOT_SUPPORTED_WARNING, STR_WARNING, MB_YESNO | MB_ICONWARNING) == IDNO) return false; } } Folder = Path; // Add the wildcard mask if (bAddWildCard) { if (*Folder.rbegin() != TCHAR('\\')) Folder += _TEXT("\\"); Folder += _TEXT("*"); } // Quote the folder if needed if (bQuoteIfNeeded) QuotePath(Folder); return true; }
const TCHAR* UAssetObjectProperty::ImportText_Internal( const TCHAR* InBuffer, void* Data, int32 PortFlags, UObject* Parent, FOutputDevice* ErrorText ) const { FAssetPtr& AssetPtr = *(FAssetPtr*)Data; FString NewPath; const TCHAR* Buffer = InBuffer; const TCHAR* NewBuffer = UPropertyHelpers::ReadToken( Buffer, NewPath, 1 ); if( !NewBuffer ) { return NULL; } Buffer = NewBuffer; if( NewPath==TEXT("None") ) { AssetPtr = NULL; } else { if( *Buffer == TCHAR('\'') ) { NewBuffer = UPropertyHelpers::ReadToken( Buffer, NewPath, 1 ); if( !NewBuffer ) { return NULL; } Buffer = NewBuffer; if( *Buffer++ != TCHAR('\'') ) { return NULL; } } FStringAssetReference ID(NewPath); AssetPtr = ID; } return Buffer; }
//Simple plugin About box INT_PTR WINAPI AboutDlgProcIntel(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM /*lParam*/) { switch (wMsg) { case WM_INITDIALOG: { //Set window name string windowTitle = DDSExporterPluginName; windowTitle += DDSExporterPluginVersion; SetWindowText(hDlg, windowTitle.c_str()); CenterDialog(hDlg); } break; case WM_CHAR: { TCHAR chCharCode = TCHAR(wParam); if (chCharCode == VK_ESCAPE || chCharCode == VK_RETURN) EndDialog(hDlg, 0); } break; case WM_LBUTTONDOWN: EndDialog(hDlg, 0); break; case WM_COMMAND: switch (COMMANDID(wParam)) { case OK: EndDialog(hDlg, 0); break; case CANCEL: EndDialog(hDlg, 0); break; default: return FALSE; } break; default: return FALSE; } // switch (wMsg) return TRUE; }
LRESULT CEditWnd::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) { LRESULT lRes = 0; BOOL bHandled = TRUE; if (uMsg == WM_KILLFOCUS) { lRes = OnKillFocus(uMsg, wParam, lParam, bHandled); } else if (uMsg == OCM_COMMAND) { if (GET_WM_COMMAND_CMD(wParam, lParam) == EN_CHANGE) { lRes = OnEditChanged(uMsg, wParam, lParam, bHandled); } else if (GET_WM_COMMAND_CMD(wParam, lParam) == EN_UPDATE) { RECT rcClient; ::GetClientRect(m_hWnd, &rcClient); ::InvalidateRect(m_hWnd, &rcClient, FALSE); } } else if (uMsg == WM_KEYDOWN && TCHAR(wParam) == VK_RETURN) { m_pOwner->GetManager()->SendNotify(m_pOwner, _T("return")); } else if (uMsg == WM_KEYDOWN) { lRes = OnEdit(uMsg, wParam, lParam, bHandled); } else if( uMsg == OCM__BASE + WM_CTLCOLOREDIT || uMsg == OCM__BASE + WM_CTLCOLORSTATIC ) { if (m_pOwner->GetNativeEditBkColor() == 0xFFFFFFFF) return NULL; // // TODO: Change Edit backgournd color // ::SetBkMode((HDC)wParam, TRANSPARENT); DWORD dwTextColor = m_pOwner->GetTextColor(); ::SetTextColor((HDC)wParam, RGB(GetBValue(dwTextColor),GetGValue(dwTextColor),GetRValue(dwTextColor))); if (m_hBkBrush == NULL) { DWORD clrColor = m_pOwner->GetNativeEditBkColor(); m_hBkBrush = ::CreateSolidBrush(RGB(GetBValue(clrColor), GetGValue(clrColor), GetRValue(clrColor))); } return (LRESULT)m_hBkBrush; } else bHandled = FALSE; if (!bHandled) return CWindowWnd::HandleMessage(uMsg, wParam, lParam); return lRes; }
void CChordEaseApp::MakeStartCase(CString& str) { str.MakeLower(); int len = str.GetLength(); int pos = 0; while (1) { while (pos < len && str[pos] == ' ') // skip spaces pos++; if (pos >= len) // if end of string break; str.SetAt(pos, TCHAR(toupper(str[pos]))); // capitalize start of word if ((pos = str.Find(' ', pos)) < 0) // find next space if any break; } }
MOZCE_SHUNT_API char* getcwd(char* buff, size_t size) { #ifdef API_LOGGING mozce_printf("getcwd called.\n"); #endif int i; unsigned short dir[MAX_PATH]; GetModuleFileName(GetModuleHandle (NULL), dir, MAX_PATH); for (i = _tcslen(dir); i && dir[i] != TEXT('\\'); i--) {} dir[i + 1] = TCHAR('\0'); w2a_buffer(dir, -1, buff, size); return buff; }
static void CommandLineParseHelper(const TCHAR* InCmdLine, TArray<FString>& Tokens, TArray<FString>& Switches) { FString NextToken; while(FParse::Token(InCmdLine,NextToken,false)) { if((**NextToken == TCHAR('-'))) { new(Switches)FString(NextToken.Mid(1)); } else { new(Tokens)FString(NextToken); } } }
bool CGuid::ConvertFrom(BSTR bstrGuid) { if (bstrGuid == NULL) { return false; } UINT nLen = ::SysStringLen(bstrGuid); if (nLen < GUID_STRING_LEN - 4) { return false; } CString csguid = bstrGuid; if (csguid.GetAt(0) == TCHAR('{')) { ATLASSERT(csguid.Find(TCHAR('}'))!=-1); return ConvertFrom(csguid.Mid(1, csguid.GetLength()-2)); } else { return ConvertFrom(csguid); } }
void CharacterButton::SetCharacter(unsigned _character) { if (_character == character) return; character = _character; #ifdef _UNICODE const TCHAR buffer[2] = { TCHAR(character), _T('\0') }; #else char buffer[7]; *UnicodeToUTF8(character, buffer) = '\0'; #endif SetCaption(buffer); }
LRESULT CHotKeyWnd::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) { LRESULT lRes = 0; BOOL bHandled = TRUE; if( uMsg == WM_KILLFOCUS ) lRes = OnKillFocus(uMsg, wParam, lParam, bHandled); else if( uMsg == OCM_COMMAND ) { if( GET_WM_COMMAND_CMD(wParam, lParam) == EN_CHANGE ) lRes = OnEditChanged(uMsg, wParam, lParam, bHandled); else if( GET_WM_COMMAND_CMD(wParam, lParam) == EN_UPDATE ) { RECT rcClient; ::GetClientRect(m_hWnd, &rcClient); ::InvalidateRect(m_hWnd, &rcClient, FALSE); } } else if( uMsg == WM_KEYDOWN && TCHAR(wParam) == VK_RETURN ) { m_pOwner->GetManager()->SendNotify(m_pOwner, _T("return")); } else if ( (uMsg == WM_NCACTIVATE) || (uMsg == WM_NCACTIVATE) || (uMsg == WM_NCCALCSIZE) ) { return 0; } else if (uMsg == WM_PAINT) { PAINTSTRUCT ps = { 0 }; HDC hDC = ::BeginPaint(m_hWnd, &ps); DWORD dwTextColor = m_pOwner->GetTextColor(); DWORD dwBkColor = m_pOwner->GetNativeBkColor(); CDuiString strText = GetHotKeyName(); ::RECT rect; ::GetClientRect(m_hWnd, &rect); ::SetBkMode(hDC, TRANSPARENT); ::SetTextColor(hDC, RGB(GetBValue(dwTextColor), GetGValue(dwTextColor), GetRValue(dwTextColor))); HBRUSH hBrush = CreateSolidBrush( RGB(GetBValue(dwBkColor), GetGValue(dwBkColor), GetRValue(dwBkColor)) ); ::FillRect(hDC, &rect, hBrush); ::DeleteObject(hBrush); HFONT hOldFont = (HFONT)SelectObject(hDC, GetWindowFont(m_hWnd)); ::SIZE size = { 0 }; ::GetTextExtentPoint32(hDC, strText.GetData(), strText.GetLength(), &size) ; ::DrawText(hDC, strText.GetData(), -1, &rect, DT_LEFT|DT_SINGLELINE|DT_END_ELLIPSIS|DT_NOPREFIX); ::SelectObject(hDC, hOldFont); ::SetCaretPos(size.cx, 0); ::EndPaint(m_hWnd, &ps); bHandled = TRUE; } else bHandled = FALSE; if( !bHandled ) return CWindowWnd::HandleMessage(uMsg, wParam, lParam); return lRes; }
static TString ProcessCommands(const _TCHAR *file) { FILE *fin; #ifdef UNICODE int err = _wfopen_s(&fin, file, L"r,ccs=unicode"); #else int err = fopen_s(&fin, file, "r"); #endif if (err) return TString(file); FILE *fout; auto output_file = TempFile::Create(TEXT(".txt"), true); #ifdef UNICODE err = _wfopen_s(&fout, output_file.data(), L"w,ccs=unicode"); #else err = fopen_s(&fout, output_file.data(), "w"); #endif if (err) { perror("LinkWrapper:ProcessCommands"); exit(err); } _TINT ch = _gettc(fin); while (ch != _TEOF) { while (ch != _TEOF && _istspace(ch)) { _puttc(ch, fout); ch = _gettc(fin); } // FIXME: input files with spaces in them??? (are they quoted???) TString word; while (ch != _TEOF && !_istspace(ch)) { word.push_back(ch); ch = _gettc(fin); } // FIXME: handle comments (starting with ';') auto comment_pos = word.find(TCHAR(';')); assert(comment_pos == -1 && "Found comment in command file"); if (!word.empty()) { auto new_word = ProcessArg(word.data()); _fputts(new_word.data(), fout); } } fclose(fin); fclose(fout); return output_file; }
bool CFileBrowserListCtrl::RenameFile(HWND hWnd, LPCTSTR OldName, LPCTSTR NewName, FILEOP_FLAGS Flags) { // pFrom/pTo can contain multiple names and must be double null-terminated CString sFrom = OldName; CString sTo = NewName; sFrom.Insert(sFrom.GetLength(), TCHAR(0)); // add extra terminator sTo.Insert(sTo.GetLength(), TCHAR(0)); // add extra terminator SHFILEOPSTRUCT op; ZeroMemory(&op, sizeof(op)); op.pFrom = sFrom; op.pTo = sTo; op.hwnd = hWnd; op.wFunc = FO_RENAME; op.fFlags = Flags; if (SHFileOperation(&op)) // non-zero result means failure return(FALSE); // if the rename causes a confirmation dialog and the user cancels, // SHFileOperation returns success though the file was NOT renamed return(PathFileExists(NewName) != 0); // verify that rename succeeded }