Exemplo n.º 1
0
BOOL ConfigDialog::dialogEvent(HWND hWnd,
                               UINT message,
                               WPARAM wParam,
                               LPARAM lParam)
{
    switch (message) {
    case WM_INITDIALOG:
        // Set the spinbox range and its buddy edit control
        SendDlgItemMessage(hWnd, IDC_WAIT_SPIN, UDM_SETRANGE, 0,
                           (LPARAM)MAKELONG((short)9999, (short)1));
        SendDlgItemMessage(hWnd, IDC_WAIT_SPIN, UDM_SETBUDDY,
                           (WPARAM)GetDlgItem(hWnd, IDC_WAIT_NUM), 0);

        // Populate the picture path combo box with saved values
        for (int i = 0; i < settings.getNumRememberedPicturePaths(); i++) {
            std::wstring path = settings.getRememberedPicturePath(i);
            SendDlgItemMessage(hWnd, IDC_PICTURES_PATH, CB_ADDSTRING, 0,
                               (LPARAM)path.c_str());
        }

        updateControls(hWnd,
                       settings.getBasePicturesPath(),
                       settings.getNextPictureWait(),
                       settings.showSmallImages());

        return TRUE;
    case WM_CLOSE:
        EndDialog(hWnd, IDC_CANCEL);
        return TRUE;
    case WM_COMMAND:
        switch (LOWORD(wParam)) {
        case IDC_OK:
            {
                // Pictures Folder
                TCHAR buffer[MAX_PATH+1];
                int text_lenght = GetDlgItemText(hWnd, IDC_PICTURES_PATH,
                                                    buffer, MAX_PATH);
                wstring base_path(buffer, text_lenght);

                // Check that the directory exists before remembering the user settings.
                FileInfo file_info(base_path);
                if (!file_info.exists() || !file_info.isDirectory()) {
                    wstring message = L"Unable to find directory '" + base_path + L"'.\n\n"
                                        L"Please change the selected directory and try again.";
                    MessageBox(hWnd, message.c_str(), L"PhotoViewer", 0);
                    return TRUE;
                }

                settings.setBasePicturesPath(base_path);

                // Reset the last picture, so we start from the first one
                // in the base path
                settings.setLastPicturePath(L"");

                // Wait
                int wait = (int)GetDlgItemInt(hWnd, IDC_WAIT_NUM, NULL, FALSE);
                if (wait < 1) {
                    wait = 1;
                }
                settings.setNextPictureWait(wait * 1000);

                // For short wait times just use a box or bilinear filter as they're
                // quicker.  We don't always use these because they don't look as good
                // as the Catmull Rom filter.
                if (wait == 1) {
                    settings.setRescaleFilterType(FILTER_BOX);
                }
                else if (wait <= 3) {
                    settings.setRescaleFilterType(FILTER_BILINEAR);
                }
                else {
                    settings.setRescaleFilterType(FILTER_CATMULLROM);
                }

                // Ignore Small image
                if (SendDlgItemMessage(hWnd, IDC_SKIP_SMALL_IMAGES, BM_GETCHECK, 0, 0) ==
                        BST_CHECKED) {
                    settings.setShowSmallImages(false);
                }
                else {
                    settings.setShowSmallImages(true);
                }

                EndDialog(hWnd, IDC_OK);
            }
            return TRUE;
        case IDC_CANCEL:
            EndDialog(hWnd, IDC_CANCEL);
            return TRUE;
        case IDC_BROWSE:
            {
                BROWSEINFO browse_info;
                browse_info.hwndOwner = hWnd;
                browse_info.pidlRoot = NULL;
                browse_info.lpszTitle = L"Select folder containing images.";
                browse_info.pszDisplayName = NULL;
                browse_info.ulFlags =  BIF_NEWDIALOGSTYLE | BIF_NONEWFOLDERBUTTON;
                browse_info.lpfn = NULL;
                browse_info.lParam = 0;
                browse_info.iImage = 0;
                LPITEMIDLIST itemIDList;
                if ((itemIDList = SHBrowseForFolder(&browse_info)) != NULL) {
                    TCHAR buffer[MAX_PATH+1];
                    SHGetTargetFolderPath(itemIDList, buffer);
                    if (wstring(buffer).length() != 0)
                        SetDlgItemText(hWnd, IDC_PICTURES_PATH, buffer);
                }
            }
            return TRUE;
        case IDC_DEFAULT:
            settings.resetLastPicturePath();
            updateControls(hWnd,
                            settings.getDefaultBasePicturesPath(),
                            settings.getDefaultNextPictureWait(),
                            settings.showSmallImagesDefault());
            break;
        case IDC_ABOUT:
            MessageBox(hWnd, L"Screensaver for viewing a collection of images.\n\n"
                        L"Developed and maintained by [email protected]\n\n"
                        L"Some Rights Reserved.\n"
                        L"http://creativecommons.org/licenses/by-nc-sa/3.0/\n\n"
                        L"This software uses the FreeImage open source image library.\n"
                        L"FreeImage is used under the §6.1 FIPL license.\n"
                        L"http://freeimage.sourceforge.net/\n",
                        L"About PhotoViewer", 0);
            break;
        }
        break;
    }
    return FALSE;
}
Exemplo n.º 2
0
LRESULT CALLBACK Fq4EditorWindow::OnCommand( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
    int wmId = LOWORD( wParam );
    switch ( wmId )
    {
    case IDM_KINGS:
        {
            int count = GiveTeam( m_kingDatas );
            std::wstring&& message = LogTeamResult( count, m_kingDatas.size() );
            MessageBox( hWnd, message.c_str(), L"國王們", MB_OK );
        }
        break;

    case IDM_FOREST:
        {
            int count = GiveTeam( m_forestDatas );
            std::wstring&& message = LogTeamResult( count, m_forestDatas.size() );
            MessageBox( hWnd, message.c_str(), L"森林國 雷斯達", MB_OK );
        }
        break;

    case IDM_ELF:
        {
            int count = GiveTeam( m_elfDatas );
            std::wstring&& message = LogTeamResult( count, m_elfDatas.size() );
            MessageBox( hWnd, message.c_str(), L"精靈國 薩內多", MB_OK );
        }
        break;

    case IDM_MINE:
        {
            int count = GiveTeam( m_mineDatas );
            std::wstring&& message = LogTeamResult( count, m_mineDatas.size() );
            MessageBox( hWnd, message.c_str(), L"礦山國 格林斯", MB_OK );
        }
        break;

    case IDM_SEA:
        {
            int count = GiveTeam( m_seaDatas );
            std::wstring&& message = LogTeamResult( count, m_seaDatas.size() );
            MessageBox( hWnd, message.c_str(), L"海盜國 慕尼頓", MB_OK );
        }
        break;

    case IDM_PLAIN_MAGICIAN:
        {
           int count = GiveTeam( m_plainMagicianDatas );
           std::wstring&& message = LogTeamResult( count, m_plainMagicianDatas.size() );
           MessageBox( hWnd, message.c_str(), L" 平原國 休利亞(魔法軍團)", MB_OK );
        }
        break;

    case IDM_PLAIN_KNIGHT:
        {
            int count = GiveTeam( m_plainKnightDatas );
            std::wstring&& message = LogTeamResult( count, m_plainKnightDatas.size() );
            MessageBox( hWnd, message.c_str(), L"平原國 休利亞(騎士軍團)", MB_OK );
        }
        break;

    case IDM_ITEM:
        {
            GiveItem();
            MessageBox( hWnd, L"所有道具 +10", L"ITEM", MB_OK );
        }
        break;

    case IDM_MONEY:
        {
            GiveMoney();
            MessageBox( hWnd, L"獲得 $10000", L"MONEY", MB_OK );
        }
        break;

    case IDM_TIRED:
        {
            ReleaseFatigue();
        }
    break;

    default:
        return EditorWindow::OnCommand( hWnd, message, wParam, lParam );
    }

    return 0;
}