コード例 #1
0
ファイル: shellpath.c プロジェクト: NVIDIA/winex_lgpl
/*************************************************************************
 * PathRemoveExtension	[SHELL32.250]
 */
void WINAPI PathRemoveExtensionAW(LPVOID lpszPath)
{
	if (SHELL_OsIsUnicode())
            PathRemoveExtensionW(lpszPath);
        else
            PathRemoveExtensionA(lpszPath);
}
コード例 #2
0
ファイル: CommandObj.cpp プロジェクト: killvxk/WebbrowserLock
bool CCommandObj::FormatCommandInfo(LPCTSTR lpFileName,mdk::NetHost & nClientHost)
{
	OutA(Dbg,("[CCommandServicesObj]Format Command Info[%s] Start."),lpFileName);
	bool bRet = FALSE;
	CHAR szFileName[MAX_PATH] = {0};
	RESOURCEREQUIT rResourceRequit;
//	memcpy_s(rResourceRequit.btResourceBag,MAX_BAG_LEN,m_btCommandBag,MAX_BAG_LEN);


#ifdef UNICODE
	WcsToMbs(lpFileName,szFileName);
#else
	_tcscpy_s(szFileName,MAX_PATH,lpFileName);
#endif

	PathRemoveExtensionA(szFileName);
	strcpy_s(rResourceRequit.szResourceID,szFileName);

	OutA(Dbg,("[CCommandServicesObj]Send Resource Requit Info:[%s] Len:[%d] Start."),rResourceRequit.szResourceID,sizeof(RESOURCEREQUIT));
	bRet = nClientHost.Send((PUCHAR)&rResourceRequit,sizeof(RESOURCEREQUIT));

	Out(Dbg,_T("[CCommandServicesObj]Format Command Info Stop[%d]."),bRet);
	return bRet;
}
コード例 #3
0
ファイル: main.cpp プロジェクト: Pastor/videotools
INT_PTR CALLBACK
MainDialog(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    static HINSTANCE hInstance = nullptr;
    static HFONT hFont = nullptr;
    static auto  cDefColor = RGB(240, 240, 240);
    static auto  cStatusColor = RGB(0, 0, 0);
    static auto  cErrorColor = RGB(178, 34, 34);
    static HBRUSH hDefBrush = nullptr;

    static HBITMAP hBitmap = nullptr;

    static HMENU hMainMenu = nullptr;
    static HWND  hProgress = nullptr;
    static HWND  hError = nullptr;
    static HWND  hStartProcess = nullptr;
    static HWND  hStopProcess = nullptr;
    static HWND  hCurrentLine = nullptr;
    static HWND  hProcessPercent = nullptr;

    static HANDLE hProcessThread = nullptr;
    static DWORD  dwProcessThreadId;
    static ProcessParam param;

    switch (uMsg) {
    case WM_INITDIALOG:
    {
        hInstance = reinterpret_cast<HINSTANCE>(lParam);

        hProgress = GetDlgItem(hWnd, IDC_PROCESS_PROGRESS);
        hStartProcess = GetDlgItem(hWnd, IDC_START_PROCESS);
        hStopProcess = GetDlgItem(hWnd, IDC_STOP_PROCESS);
        hCurrentLine = GetDlgItem(hWnd, IDC_INFO_CURRENT_LINE);
        hError = GetDlgItem(hWnd, IDC_ERROR_TEXT);
        hProcessPercent = GetDlgItem(hWnd, IDC_PROCESS_PERCENT);
        hDefBrush = CreateSolidBrush(cDefColor);
        hFont = CreateFont(12, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, DEFAULT_CHARSET,
            OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, CLEARTYPE_QUALITY, DEFAULT_PITCH, TEXT("Lucida Console"));
        hMainMenu = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_MAINMENU));
        SetMenu(hWnd, hMainMenu);
        SetWindowText(hProcessPercent, TEXT(""));
        SetWindowText(hError, TEXT(""));

        SendMessage(hProcessPercent, WM_SETFONT, reinterpret_cast<WPARAM>(hFont), static_cast<LPARAM>(0));
        {
            auto name = gProp->getWString(Constants::ApplicationName);
            if (name.size() > 0) {
                SetWindowText(hWnd, name.c_str());
            }
            auto database_name = gProp->getString(Constants::DatabaseName);
            if (database_name.size() > 0) {
                param.database_name = database_name;
            }
        }
        param.hwnd = hWnd;
        param.size = 0;
        return TRUE;
    }
    case WM_NOTIFY:
    {
        auto wCtrlId = LOWORD(wParam);
        auto lHdr = reinterpret_cast<LPNMHDR>(lParam);
        break;
    }
    case WM_COMMAND:
    {
        auto wNotifyId = HIWORD(wParam);
        auto wCtrlId = LOWORD(wParam);

        switch (wCtrlId) {
        case ID_FILE_QUIT:
        {
            SendMessage(hWnd, WM_CLOSE, 0, 0);
            break;
        }
        case ID_FILE_OPEN:
        {
            OPENFILENAMEA ofn;
            RtlSecureZeroMemory(&ofn, sizeof(ofn));
            RtlSecureZeroMemory(param.szFileName, sizeof(param.szFileName));
            ofn.lStructSize = sizeof(ofn);
            ofn.hwndOwner = hWnd;
            ofn.lpstrFile = param.szFileName;
            ofn.nMaxFile = sizeof(param.szFileName);
            ofn.lpstrFilter = "Все\0*.*\0Текстовый файл\0*.txt\0Файл CSV\0*.csv\0Файл LDOTS\0*.ldots\0";
            ofn.nFilterIndex = 4;
            ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_EXPLORER;
            if (GetOpenFileNameA(&ofn) == TRUE) {
                StringCchCopyA(param.szFileTemplate, sizeof(param.szFileTemplate), param.szFileName);
                PathRemoveExtensionA(param.szFileTemplate);
                param.size = file_size(param.szFileName);
                param.table_name = fs::basename(std::string(param.szFileTemplate));
                SetWindowText(GetDlgItem(hWnd, IDC_START_PROCESS), TEXT("Запуск"));
                EnableWindow(hStartProcess, TRUE);
            } else {
                EnableWindow(hStartProcess, FALSE);
            }
            EnableWindow(hStopProcess, hProcessThread == nullptr ? FALSE : TRUE);
            break;
        }
        case IDC_START_PROCESS:
        {
            SetWindowText(hError, TEXT(""));
            SendMessage(hProgress, PBM_SETSTEP, static_cast<WPARAM>(1), 0);
            SendMessage(hProgress, PBM_SETRANGE, 0, MAKELPARAM(0, 100));
            hProcessThread = CreateThread(nullptr, 0, reinterpret_cast<LPTHREAD_START_ROUTINE>(__ProcessFile), &param, 0, &dwProcessThreadId);
            EnableWindow(hStopProcess, hProcessThread == nullptr ? FALSE : TRUE);
            EnableWindow(hStartProcess, FALSE);
            break;
        }
        case IDC_STOP_PROCESS:
        {
            is_processing = false;
            break;
        }

        }
        break;
    }
    case WM_PROCESS_LINE:
    {
        auto pl = reinterpret_cast<ProcessLine *>(lParam);
        auto percent = (pl->process * 100) / param.size;
        auto tail = param.size - pl->process;

        __WindowPrintf(hCurrentLine, TEXT("%d"), pl->line);
        __WindowPrintf(hProcessPercent, TEXT("%d%%"), percent);
        {
            auto total = tail * pl->dwMiddleTime;
            auto sec = total / 1000 % 60;
            auto minutes = total / 1000 / 60 % 60;
            auto hours = total / 1000 / 60 / 60 % 24;
            auto days = total / 1000 / 60 / 60 / 24 % 7;
            __WindowPrintf(GetDlgItem(hWnd, IDC_INFO_TIME), TEXT("%02d:%02d:%02d"), hours, minutes, sec);
        }
        {
            auto sec = pl->dwProcessTime / 1000 % 60;
            auto minutes = pl->dwProcessTime / 1000 / 60 % 60;
            auto hours = pl->dwProcessTime / 1000 / 60 / 60 % 24;
            auto days = pl->dwProcessTime / 1000 / 60 / 60 / 24 % 7;
            __WindowPrintf(GetDlgItem(hWnd, IDC_INFO_TIME_COMPLETE), TEXT("%02d:%02d:%02d"), hours, minutes, sec);
        }
        SendMessage(hProgress, PBM_SETPOS, percent, 0);
        break;
    }
    case WM_PROCESS_ERROR:
    {
        auto error = reinterpret_cast<LPCSTR>(lParam);
        SetWindowTextA(hError, error);
        UpdateWindow(hError);

    }
    case WM_PROCESS_COMPLETE:
    {
        if (hProcessThread != nullptr)
            CloseHandle(hProcessThread);
        hProcessThread = nullptr;
        dwProcessThreadId = 0;
        EnableWindow(hStopProcess, hProcessThread == nullptr ? FALSE : TRUE);
        SendMessage(hProgress, PBM_SETPOS, 0, 0);
        SetWindowText(hProcessPercent, TEXT(""));
        SetWindowText(GetDlgItem(hWnd, IDC_START_PROCESS), TEXT("Запуск"));
        break;
    }
    case WM_CTLCOLORSTATIC:
    {
        auto hdc = reinterpret_cast<HDC>(wParam);
        if (reinterpret_cast<HWND>(lParam) == nullptr) {
            SetTextColor(hdc, cStatusColor);
            SetBkColor(hdc, cDefColor);
            SetBkMode(hdc, TRANSPARENT);
            return reinterpret_cast<INT_PTR>(hDefBrush);
        } else if (reinterpret_cast<HWND>(lParam) == hError) {
            SetTextColor(hdc, cErrorColor);
            SetBkColor(hdc, cDefColor);
            SetBkMode(hdc, TRANSPARENT);
            return reinterpret_cast<INT_PTR>(hDefBrush);
        }
        return DefWindowProc(hWnd, uMsg, wParam, lParam);
    }
    case WM_CLOSE:
    {
        if (hProcessThread != nullptr) {
            is_processing = false;
            Sleep(1000);
            CloseHandle(hProcessThread);
            hProcessThread = nullptr;
        }
        EndDialog(hWnd, lParam);
        PostQuitMessage(0);
        is_running = false;
        return TRUE;
    }
    }
    return FALSE;
}