Example #1
0
static void init_dialog(HWND hwnd, int num)
{
    int drive_type, drive_extend_image_policy, n = 0;

    EnableWindow(GetDlgItem(hwnd, IDC_SELECT_DRIVE_TYPE_2031),
                 drive_check_type(DRIVE_TYPE_2031, num - 8));
    EnableWindow(GetDlgItem(hwnd, IDC_SELECT_DRIVE_TYPE_2040),
                 drive_check_type(DRIVE_TYPE_2040, num - 8));
    EnableWindow(GetDlgItem(hwnd, IDC_SELECT_DRIVE_TYPE_3040),
                 drive_check_type(DRIVE_TYPE_3040, num - 8));
    EnableWindow(GetDlgItem(hwnd, IDC_SELECT_DRIVE_TYPE_4040),
                 drive_check_type(DRIVE_TYPE_4040, num - 8));
    EnableWindow(GetDlgItem(hwnd, IDC_SELECT_DRIVE_TYPE_1001),
                 drive_check_type(DRIVE_TYPE_1001, num - 8));
    EnableWindow(GetDlgItem(hwnd, IDC_SELECT_DRIVE_TYPE_8050),
                 drive_check_type(DRIVE_TYPE_8050, num - 8));
    EnableWindow(GetDlgItem(hwnd, IDC_SELECT_DRIVE_TYPE_8250),
                 drive_check_type(DRIVE_TYPE_8250, num - 8));

    resources_get_int_sprintf("Drive%dType", &drive_type, num);
    resources_get_int_sprintf("Drive%dExtendImagePolicy",
                              &drive_extend_image_policy, num);

    switch (drive_type) {
      case DRIVE_TYPE_NONE:
        n = IDC_SELECT_DRIVE_TYPE_NONE;
        break;
      case DRIVE_TYPE_2031:
        n = IDC_SELECT_DRIVE_TYPE_2031;
        break;
      case DRIVE_TYPE_2040:
        n = IDC_SELECT_DRIVE_TYPE_2040;
        break;
      case DRIVE_TYPE_3040:
        n = IDC_SELECT_DRIVE_TYPE_3040;
        break;
      case DRIVE_TYPE_4040:
        n = IDC_SELECT_DRIVE_TYPE_4040;
        break;
      case DRIVE_TYPE_1001:
        n = IDC_SELECT_DRIVE_TYPE_1001;
        break;
      case DRIVE_TYPE_8050:
        n = IDC_SELECT_DRIVE_TYPE_8050;
        break;
      case DRIVE_TYPE_8250:
        n = IDC_SELECT_DRIVE_TYPE_8250;
        break;
    }

    CheckRadioButton(hwnd, IDC_SELECT_DRIVE_TYPE_2031,
                     IDC_SELECT_DRIVE_TYPE_NONE, n);

    enable_controls_for_drive_settings(hwnd, n);

    switch (drive_extend_image_policy) {
      case DRIVE_EXTEND_NEVER:
        n = IDC_SELECT_DRIVE_EXTEND_NEVER;
        break;
      case DRIVE_EXTEND_ASK:
        n = IDC_SELECT_DRIVE_EXTEND_ASK;
        break;
      case DRIVE_EXTEND_ACCESS:
        n = IDC_SELECT_DRIVE_EXTEND_ACCESS;
        break;
    }

    CheckRadioButton(hwnd, IDC_SELECT_DRIVE_EXTEND_NEVER,
                     IDC_SELECT_DRIVE_EXTEND_ACCESS, n);
}
Example #2
0
BOOL FAR PASCAL GraphOptionDlg(HWND hDlg, WORD msg, DWORD wParam, LONG lParam)
/***************************************************************************/
{
static GRAPH_OPTIONS goLocalCopy ;

INT            iTimeMilliseconds ;
TCHAR          szBuff[MiscTextLen] ;
PGRAPHSTRUCT   lgraph;

   lParam ;
   lgraph = pGraphs;

   switch(msg)
      {

      case WM_INITDIALOG:

         dwCurrentDlgID = HC_PM_idDlgOptionChart ;

         // Init the Radio button, Check boxes and text fields.

         goLocalCopy.iGraphOrHistogram =
            lgraph->gOptions.iGraphOrHistogram ;
         if (lgraph->gOptions.iGraphOrHistogram == LINE_GRAPH)
            CheckRadioButton(hDlg, ID_GRAPH, ID_HISTOGRAM, ID_GRAPH) ;
         else
            CheckRadioButton(hDlg, ID_GRAPH, ID_HISTOGRAM, ID_HISTOGRAM) ;

         CheckDlgButton(hDlg, ID_LEGEND, lgraph->gOptions.bLegendChecked) ;
         if (!(lgraph->gOptions.bLegendChecked))
            {
            // can't display valuebar w/o legend
            DialogEnable (hDlg, IDD_CHARTOPTIONSVALUEBAR, FALSE) ;
            }

         CheckDlgButton(hDlg, ID_LABELS, lgraph->gOptions.bLabelsChecked) ;
         CheckDlgButton(hDlg, ID_VERT_GRID, lgraph->gOptions.bVertGridChecked) ;
         CheckDlgButton(hDlg, ID_HORZ_GRID, lgraph->gOptions.bHorzGridChecked) ;
         CheckDlgButton(hDlg, IDD_CHARTOPTIONSVALUEBAR,
            lgraph->gOptions.bStatusBarChecked) ;

         TSPRINTF(szBuff, TEXT("%d"), lgraph->gOptions.iVertMax) ;
         SendDlgItemMessage(hDlg, ID_VERT_MAX, WM_SETTEXT, 0, (LONG) szBuff) ;

         TSPRINTF(szBuff, TEXT("%3.3f"), lgraph->gOptions.eTimeInterval) ;
         ConvertDecimalPoint (szBuff);
         SendDlgItemMessage(hDlg, IDD_CHARTOPTIONSINTERVAL, WM_SETTEXT, 0, (LONG) szBuff) ;

         // Pickup a local copy of the Graph Options.

         goLocalCopy = lgraph->gOptions ;
         LocalManualRefresh = lgraph->bManualRefresh ;

         CheckRadioButton (hDlg,
               IDD_CHARTOPTIONSMANUALREFRESH,
               IDD_CHARTOPTIONSPERIODIC,
               LocalManualRefresh ? IDD_CHARTOPTIONSMANUALREFRESH :
               IDD_CHARTOPTIONSPERIODIC) ;

         if (lgraph->bManualRefresh)
            {
            DialogEnable (hDlg, IDD_CHARTOPTIONSINTERVALTEXT, FALSE) ;
            DialogEnable (hDlg, IDD_CHARTOPTIONSINTERVAL, FALSE) ;
            }
         else
            {
            DialogEnable (hDlg, IDD_CHARTOPTIONSINTERVALTEXT, TRUE) ;
            DialogEnable (hDlg, IDD_CHARTOPTIONSINTERVAL, TRUE) ;
            }

         EditSetLimit (GetDlgItem(hDlg, ID_VERT_MAX),
            sizeof(szBuff) / sizeof(TCHAR) - 1) ;

         EditSetLimit (GetDlgItem(hDlg, IDD_CHARTOPTIONSINTERVAL),
            ShortTextLen) ;

         WindowCenter (hDlg) ;
         return(TRUE);

      case WM_COMMAND:
         switch(LOWORD(wParam))
            {
            case ID_VERT_MAX:
               if (HIWORD(wParam) == EN_CHANGE)
                  {
                  DialogText(hDlg, ID_VERT_MAX, szBuff) ;
                  swscanf(szBuff, TEXT("%d"), &goLocalCopy.iVertMax) ;
                  }
               break ;


            case IDD_CHARTOPTIONSINTERVAL:
               if (HIWORD(wParam) == EN_CHANGE)
                  {
                  goLocalCopy.eTimeInterval =
                     DialogFloat (hDlg, IDD_CHARTOPTIONSINTERVAL, NULL) ;
                  }
               break ;

            case IDD_CHARTOPTIONSPERIODIC:
            case IDD_CHARTOPTIONSMANUALREFRESH:
               // check if the Manual refresh is currently checked.
               // Then toggle the ManualRefresh button
               LocalManualRefresh =
                  IsDlgButtonChecked (hDlg, IDD_CHARTOPTIONSMANUALREFRESH) ;
               CheckRadioButton (hDlg,
                  IDD_CHARTOPTIONSMANUALREFRESH,
                  IDD_CHARTOPTIONSPERIODIC,
                  LocalManualRefresh ? IDD_CHARTOPTIONSPERIODIC :
                  IDD_CHARTOPTIONSMANUALREFRESH) ;

               // gray out time interval if necessary...
               DialogEnable (hDlg, IDD_CHARTOPTIONSINTERVALTEXT,
                  LocalManualRefresh) ;
               DialogEnable (hDlg, IDD_CHARTOPTIONSINTERVAL,
                  LocalManualRefresh) ;
               LocalManualRefresh = !LocalManualRefresh ;
               break ;

            case IDD_CHARTOPTIONSVALUEBAR:
               if (goLocalCopy.bStatusBarChecked == TRUE)
                  goLocalCopy.bStatusBarChecked = FALSE ;
               else
                  goLocalCopy.bStatusBarChecked = TRUE ;
               break ;


            case ID_LEGEND:
               if (goLocalCopy.bLegendChecked == TRUE)
                  goLocalCopy.bLegendChecked = FALSE ;
               else
                  goLocalCopy.bLegendChecked = TRUE ;

               DialogEnable (hDlg, IDD_CHARTOPTIONSVALUEBAR,
                  goLocalCopy.bLegendChecked) ;

               break ;


            case ID_LABELS:
               if (goLocalCopy.bLabelsChecked == TRUE)
                  goLocalCopy.bLabelsChecked = FALSE ;
               else
                  goLocalCopy.bLabelsChecked = TRUE ;
               break ;


            case ID_VERT_GRID:
               if (goLocalCopy.bVertGridChecked == TRUE)
                  goLocalCopy.bVertGridChecked = FALSE ;
               else
                  goLocalCopy.bVertGridChecked = TRUE ;
               break ;


            case ID_HORZ_GRID:
               if (goLocalCopy.bHorzGridChecked == TRUE)
                  goLocalCopy.bHorzGridChecked = FALSE ;
               else
                  goLocalCopy.bHorzGridChecked = TRUE ;
               break ;


            case ID_GRAPH:
            case ID_HISTOGRAM:
               if (goLocalCopy.iGraphOrHistogram == BAR_GRAPH)
                  {
                  goLocalCopy.iGraphOrHistogram = LINE_GRAPH ;
                  }
               else
                  {
                  goLocalCopy.iGraphOrHistogram = BAR_GRAPH ;
                  }
               CheckRadioButton(hDlg, ID_GRAPH, ID_HISTOGRAM,
                  goLocalCopy.iGraphOrHistogram == LINE_GRAPH ?
                  ID_GRAPH : ID_HISTOGRAM) ;

               break ;

            case IDOK:
               //  verify some numeric entries first
               if (goLocalCopy.iVertMax > MAX_VERTICAL ||
                   goLocalCopy.iVertMax < MIN_VERTICAL)
                  {
                  DlgErrorBox (hDlg, ERR_BADVERTMAX) ;
                  SetFocus (DialogControl (hDlg, ID_VERT_MAX)) ;
                  EditSetTextEndPos (hDlg, ID_VERT_MAX) ;
                  return (FALSE) ;
                  break ;
                  }
               if (goLocalCopy.eTimeInterval > MAX_INTERVALSEC ||
                   goLocalCopy.eTimeInterval < MIN_INTERVALSEC)
                  {
                  DlgErrorBox (hDlg, ERR_BADTIMEINTERVAL) ;
                  SetFocus (DialogControl (hDlg, IDD_CHARTOPTIONSINTERVAL)) ;
                  EditSetTextEndPos (hDlg, IDD_CHARTOPTIONSINTERVAL) ;
                  return (FALSE) ;
                  break ;
                  }

               // We need to send a size message to the main window
               // so it can setup the redraw of the graph and legend.

               lgraph->gOptions.bLegendChecked    = goLocalCopy.bLegendChecked ;
               lgraph->gOptions.bStatusBarChecked = goLocalCopy.bStatusBarChecked ;

               if (lgraph->gOptions.eTimeInterval != goLocalCopy.eTimeInterval
                  && !LocalManualRefresh)
                  {
                  iTimeMilliseconds = (INT) (goLocalCopy.eTimeInterval * (FLOAT) 1000.0) ;
                  pGraphs->gInterval = iTimeMilliseconds ;
                  lgraph->bManualRefresh = LocalManualRefresh ;

                  }
               else if (LocalManualRefresh != lgraph->bManualRefresh)
                  {
                  ToggleGraphRefresh (hWndGraph) ;
                  }
               // Assign the local copy of the graph options to the
               // global copy.

               lgraph->gOptions = goLocalCopy ;

//               SizeGraphComponents (hWndGraph) ;
//               WindowInvalidate (hWndGraph) ;
               dwCurrentDlgID = 0 ;
               EndDialog (hDlg, 1) ;
               return (TRUE) ;
               break ;


            case IDCANCEL:
               dwCurrentDlgID = 0 ;
               EndDialog(hDlg,0);
               return(TRUE);

            case ID_HELP:
               CallWinHelp (dwCurrentDlgID) ;
               break ;

            default:
               break;
            }
         break;

      default:
         break;

      }
   return(FALSE);
   }
Example #3
0
/*
================
DialogAFConstraintUniversal::LoadConstraint
================
*/
void DialogAFConstraintUniversal::LoadConstraint( idDeclAF_Constraint *c ) {
	int i, s1, s2;
	idAngles angles;
	idMat3 mat;

	constraint = c;

	// anchor
	SetSafeComboBoxSelection( &m_comboAnchorJoint, constraint->anchor.joint1.c_str(), -1 );
	m_anchor_x = constraint->anchor.ToVec3().x;
	m_anchor_y = constraint->anchor.ToVec3().y;
	m_anchor_z = constraint->anchor.ToVec3().z;
	if ( constraint->anchor.type == idAFVector::VEC_JOINT ) {
		i = IDC_RADIO_ANCHOR_JOINT;
	}
	else {
		i = IDC_RADIO_ANCHOR_COORDINATES;
	}
	CheckRadioButton( IDC_RADIO_ANCHOR_JOINT, IDC_RADIO_ANCHOR_COORDINATES, i );

	// shaft 1
	s1 = SetSafeComboBoxSelection( &m_comboJoint1Shaft1, constraint->shaft[0].joint1.c_str(), -1 );
	s2 = SetSafeComboBoxSelection( &m_comboJoint2Shaft1, constraint->shaft[0].joint2.c_str(), s1 );
	angles = constraint->shaft[0].ToVec3().ToAngles();
	m_pitchShaft1 = angles.pitch;
	m_yawShaft1 = angles.yaw;
	if ( constraint->shaft[0].type == idAFVector::VEC_BONEDIR ) {
		i = IDC_RADIO_UNIVERSAL_BONE_SHAFT1;
	}
	else {
		i = IDC_RADIO_UNIVERSAL_ANGLES_SHAFT1;
		constraint->shaft[0].type = idAFVector::VEC_COORDS;
	}
	CheckRadioButton( IDC_RADIO_UNIVERSAL_BONE_SHAFT1, IDC_RADIO_UNIVERSAL_ANGLES_SHAFT1, i );

	// shaft 2
	s1 = SetSafeComboBoxSelection( &m_comboJoint1Shaft2, constraint->shaft[1].joint1.c_str(), -1 );
	s2 = SetSafeComboBoxSelection( &m_comboJoint2Shaft2, constraint->shaft[1].joint2.c_str(), s1 );
	angles = constraint->shaft[1].ToVec3().ToAngles();
	m_pitchShaft2 = angles.pitch;
	m_yawShaft2 = angles.yaw;
	if ( constraint->shaft[1].type == idAFVector::VEC_BONEDIR ) {
		i = IDC_RADIO_UNIVERSAL_BONE_SHAFT2;
	}
	else {
		i = IDC_RADIO_UNIVERSAL_ANGLES_SHAFT2;
		constraint->shaft[1].type = idAFVector::VEC_COORDS;
	}
	CheckRadioButton( IDC_RADIO_UNIVERSAL_BONE_SHAFT2, IDC_RADIO_UNIVERSAL_ANGLES_SHAFT2, i );

	// limit
	if ( constraint->limit == idDeclAF_Constraint::LIMIT_CONE ) {
		i = IDC_RADIO_UNIVERSAL_LIMIT_CONE;
	}
	else if ( constraint->limit == idDeclAF_Constraint::LIMIT_PYRAMID ) {
		i = IDC_RADIO_UNIVERSAL_LIMIT_PYRAMID;
	}
	else {
		i = IDC_RADIO_UNIVERSAL_LIMIT_NONE;
	}
	CheckRadioButton( IDC_RADIO_UNIVERSAL_LIMIT_NONE, IDC_RADIO_UNIVERSAL_LIMIT_PYRAMID, i );

	m_coneAngle = constraint->limitAngles[0];
	m_pyramidAngle1 = constraint->limitAngles[0];
	m_pyramidAngle2 = constraint->limitAngles[1];
	m_limitRoll = constraint->limitAngles[2];
	angles = constraint->limitAxis.ToVec3().ToAngles();
	m_limitPitch = angles.pitch;
	m_limitYaw = angles.yaw;

	if ( constraint->limitAxis.type == idAFVector::VEC_BONEDIR ) {
		i = IDC_RADIO_UNIVERSAL_LIMIT_BONE;
	}
	else {
		i = IDC_RADIO_UNIVERSAL_LIMIT_ANGLES;
	}
	CheckRadioButton( IDC_RADIO_UNIVERSAL_LIMIT_BONE, IDC_RADIO_UNIVERSAL_LIMIT_ANGLES, i );
	s1 = SetSafeComboBoxSelection( &m_comboLimitJoint1, constraint->limitAxis.joint1.c_str(), -1 );
	s2 = SetSafeComboBoxSelection( &m_comboLimitJoint2, constraint->limitAxis.joint2.c_str(), s1 );

	// update displayed values
	UpdateData( FALSE );
}
Example #4
0
INT_PTR CALLBACK dlgfunc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
    int id, f, option;
    TCHAR buffer[MAX_PATH], temp[2000];

    switch( msg ) {
    case WM_DESTROY:
        g_hDlg = NULL;
        return 0;

    case WM_INITDIALOG:
        g_hDlg = hDlg;
        option = 0;

        Init ();
        if (0 == is_usingNT)
        {
            EnableWindow(GetDlgItem(hDlg, IDC_CHK1), FALSE);
        }
        else if (0 == is_admin)
        {
            /* if not admin, see if a shell is set for this user */
            is_per_user = rw_reg(A_RD|A_SZ, HKEY_CURRENT_USER, logonstr, TEXT("Shell"), buffer);
            SetDlgItemText(hDlg, IDC_CHK1, TEXT("Set shell for this user &individually"));
        }

        CheckDlgButton(hDlg, IDC_CHK1, is_per_user ? BST_CHECKED : BST_UNCHECKED);

display:
        if (is_usingNT) {
            if (0 == is_per_user) {
                _tcscpy(buffer, TEXT("Shell for all users"));
                if (0 == is_admin)
                    _tcscat(buffer, TEXT(" (run as admin to change)"));

            } else {
                DWORD result = sizeof temp;
                temp[0] = 0;
                GetUserName(temp, &result);
                _stprintf(buffer, TEXT("Shell for the current user (%s)"), temp);
            }

            SetDlgItemText(hDlg, IDC_GRP1, buffer);
        }

        if (2 == option)
            _tcscpy(buffer, szBlackbox);
        else
        if (1 == option)
            _tcscpy(buffer, szExplorer);
        else
            get_shell(buffer);

        _tcslwr(_tcscpy(temp, buffer));

        if (0 == _tcsicmp(temp, szBlackbox)) {
            id = IDC_RBN1;
        }
        else if (_tcsstr(temp, TEXT("explorer"))) {
            id = IDC_RBN2;
        } else if (temp[0]) {
            id = IDC_RBN3;
        } else {
            _tcscpy(buffer, TEXT("<not set>"));
            id = 0;
        }

        CheckRadioButton(hDlg, IDC_RBN1, IDC_RBN3, id);
        for (f = IDC_RBN1; f <= IDC_RBN3; ++f)
            EnableWindow(GetDlgItem(hDlg, f), is_admin || is_per_user);

set_line:
        {
            HWND hLine = GetDlgItem(hDlg, IDC_EDT1);
            SetWindowText(hLine, buffer);
            SendMessage(hLine, EM_SETREADONLY, id != IDC_RBN3, 0);
        }
        return 1;


    case WM_COMMAND:
        id = LOWORD( wParam );
        switch(id) {
        case IDC_CHK1:
            is_per_user = 0 != IsDlgButtonChecked(hDlg, id);
            option = 0;
            goto display;

        case IDC_RBN1:
            option = 2;
            goto display;

        case IDC_RBN2:
            option = 1;
            goto display;

        case IDC_RBN3:
            buffer[0] = 0;
            goto set_line;

        case IDCANCEL:
            EndDialog(hDlg, 0);
            return 1;

        case IDOK:
        case IDC_LOG1:
            GetDlgItemText(hDlg, IDC_EDT1, shellpath, sizeof shellpath);
            if (SetAsShell(shellpath) == 1)
              return 1;
            if (0 == is_admin && is_per_user && 0 == get_per_user()) {
                id = 1;
            } else if (id == IDC_LOG1) {
                id = 2;
            } else if (0 == is_admin && 0 == is_per_user) {
                id = 3;
            } else {
                id = 4;
            }

            EndDialog(hDlg, id);
            return 1;
        }
    }
    return 0;
}
BOOL CMergeWizardTree::OnInitDialog()
{
    CMergeWizardBasePage::OnInitDialog();

    CMergeWizard * pWizard = (CMergeWizard*)GetParent();
    CString sUUID = pWizard->sUUID;
    m_URLCombo.SetURLHistory(true, false);
    m_URLCombo.LoadHistory(L"Software\\TortoiseSVN\\History\\repoURLS\\"+sUUID, L"url");
    m_URLCombo2.SetURLHistory(true, false);
    m_URLCombo2.LoadHistory(L"Software\\TortoiseSVN\\History\\repoURLS\\"+sUUID, L"url");
    m_URLCombo2.SetCurSel(0);

    CString sRegKeyFrom = L"Software\\TortoiseSVN\\History\\repoURLS\\MergeURLForFrom" + ((CMergeWizard*)GetParent())->wcPath.GetSVNPathString();
    CString sMergeUrlForWCFrom = CRegString(sRegKeyFrom);
    CString sRegKeyTo = L"Software\\TortoiseSVN\\History\\repoURLS\\MergeURLForTo" + ((CMergeWizard*)GetParent())->wcPath.GetSVNPathString();
    CString sMergeUrlForWCTo = CRegString(sRegKeyTo);

    if (!(DWORD)CRegDWORD(L"Software\\TortoiseSVN\\MergeWCURL", FALSE))
        m_URLCombo.SetCurSel(0);
    else
    {
        if (!sMergeUrlForWCFrom.IsEmpty())
            m_URLCombo.SetWindowText(CPathUtils::PathUnescape(sMergeUrlForWCFrom));
        if (!sMergeUrlForWCTo.IsEmpty())
            m_URLCombo2.SetWindowText(CPathUtils::PathUnescape(sMergeUrlForWCTo));
    }
    // Only set the "From" Url if there is no url history available
    if (m_URLCombo.GetString().IsEmpty())
        m_URLCombo.SetWindowText(CPathUtils::PathUnescape(pWizard->url));
    GetDlgItem(IDC_BROWSE)->EnableWindow(!m_URLCombo.GetString().IsEmpty());
    if (m_URLCombo2.GetString().IsEmpty())
        m_URLCombo2.SetWindowText(CPathUtils::PathUnescape(pWizard->url));
    if (!pWizard->URL1.IsEmpty())
        m_URLCombo.SetWindowText(CPathUtils::PathUnescape(pWizard->URL1));
    if (!pWizard->URL2.IsEmpty())
        m_URLCombo2.SetWindowText(CPathUtils::PathUnescape(pWizard->URL2));
    GetDlgItem(IDC_BROWSE2)->EnableWindow(!m_URLCombo2.GetString().IsEmpty());

    SetDlgItemText(IDC_WCEDIT, ((CMergeWizard*)GetParent())->wcPath.GetWinPath());

    // set head revision as default revision
    if (pWizard->startRev.IsHead() || !pWizard->startRev.IsValid())
        CheckRadioButton(IDC_REVISION_HEAD1, IDC_REVISION_N1, IDC_REVISION_HEAD1);
    else
    {
        CheckRadioButton(IDC_REVISION_HEAD1, IDC_REVISION_N1, IDC_REVISION_N1);
        m_sStartRev = pWizard->startRev.ToString();
        SetDlgItemText(IDC_REVISION_START, m_sStartRev);
    }
    if (pWizard->endRev.IsHead() || !pWizard->endRev.IsValid())
        CheckRadioButton(IDC_REVISION_HEAD, IDC_REVISION_N, IDC_REVISION_HEAD);
    else
    {
        CheckRadioButton(IDC_REVISION_HEAD, IDC_REVISION_N, IDC_REVISION_N);
        m_sEndRev = pWizard->endRev.ToString();
        SetDlgItemText(IDC_REVISION_END, m_sEndRev);
    }

    AdjustControlSize(IDC_REVISION_HEAD1);
    AdjustControlSize(IDC_REVISION_N1);
    AdjustControlSize(IDC_REVISION_HEAD);
    AdjustControlSize(IDC_REVISION_N);

    AddAnchor(IDC_MERGETREEFROMGROUP, TOP_LEFT, TOP_RIGHT);
    AddAnchor(IDC_URLCOMBO, TOP_LEFT, TOP_RIGHT);
    AddAnchor(IDC_BROWSE, TOP_RIGHT);
    AddAnchor(IDC_REVISION_HEAD1, TOP_LEFT);
    AddAnchor(IDC_REVISION_N1, TOP_LEFT);
    AddAnchor(IDC_REVISION_START, TOP_LEFT);
    AddAnchor(IDC_FINDBRANCHSTART, TOP_LEFT);
    AddAnchor(IDC_MERGETREETOGROUP, TOP_LEFT, TOP_RIGHT);
    AddAnchor(IDC_URLCOMBO2, TOP_LEFT, TOP_RIGHT);
    AddAnchor(IDC_BROWSE2, TOP_RIGHT);
    AddAnchor(IDC_REVISION_HEAD, TOP_LEFT);
    AddAnchor(IDC_REVISION_N, TOP_LEFT);
    AddAnchor(IDC_REVISION_END, TOP_LEFT);
    AddAnchor(IDC_FINDBRANCHEND, TOP_LEFT);
    AddAnchor(IDC_MERGETREEWCGROUP, TOP_LEFT, TOP_RIGHT);
    AddAnchor(IDC_WCEDIT, TOP_LEFT, TOP_RIGHT);
    AddAnchor(IDC_SHOWLOGWC, TOP_RIGHT);

    StartWCCheckThread(((CMergeWizard*)GetParent())->wcPath);

    return TRUE;
}
Example #6
0
void MarketDefaultTest::Init(HWND hWnd)
{
	CheckRadioButton(hWnd, IDC_SHOWALL, IDC_SHOWERRORS, IDC_SHOWALL);
}
Example #7
0
BOOL CPushDlg::OnInitDialog()
{
	CHorizontalResizableStandAloneDialog::OnInitDialog();
	CAppUtils::MarkWindowAsUnpinnable(m_hWnd);

	AddAnchor(IDOK,BOTTOM_RIGHT);
	AddAnchor(IDCANCEL,BOTTOM_RIGHT);
	AddAnchor(IDC_BRANCH_GROUP, TOP_LEFT,TOP_RIGHT);
	AddAnchor(IDC_STATIC_REMOTE, TOP_LEFT);
	AddAnchor(IDC_STATIC_SOURCE, TOP_LEFT);

	AddAnchor(IDC_PUSHALL, TOP_LEFT);
	AddAnchor(IDC_BRANCH_REMOTE, TOP_LEFT, TOP_RIGHT);
	AddAnchor(IDC_BUTTON_BROWSE_DEST_BRANCH, TOP_RIGHT);
	AddAnchor(IDC_BRANCH_SOURCE, TOP_LEFT, TOP_RIGHT);
	AddAnchor(IDC_BUTTON_BROWSE_SOURCE_BRANCH, TOP_RIGHT);

	AddAnchor(IDC_URL_GROUP, TOP_LEFT,TOP_RIGHT);
	AddAnchor(IDC_RD_REMOTE, TOP_LEFT);
	AddAnchor(IDC_RD_URL, TOP_LEFT);

	AddAnchor(IDC_REMOTE, TOP_LEFT, TOP_RIGHT);

	AddAnchor(IDC_URL, TOP_LEFT,TOP_RIGHT);

	AddAnchor(IDC_OPTION_GROUP, TOP_LEFT,TOP_RIGHT);

	AddAnchor(IDC_FORCE, TOP_LEFT);
	AddAnchor(IDC_PACK, TOP_LEFT);
	AddAnchor(IDC_TAGS, TOP_LEFT);
	AddAnchor(IDC_PUTTYKEY_AUTOLOAD,TOP_LEFT);

	AddAnchor(IDC_REMOTE_MANAGE,TOP_RIGHT);
	AddAnchor(IDHELP, BOTTOM_RIGHT);

	AddOthersToAnchor();

	CString sWindowTitle;
	GetWindowText(sWindowTitle);
	CAppUtils::SetWindowTitle(m_hWnd, g_Git.m_CurrentDir, sWindowTitle);

	this->GetDlgItem(IDC_PUTTYKEY_AUTOLOAD)->EnableWindow(CAppUtils::IsSSHPutty());

	EnableSaveRestore(_T("PushDlg"));

	m_RemoteURL.SetURLHistory(TRUE);

	CString WorkingDir=g_Git.m_CurrentDir;
	WorkingDir.Replace(_T(':'),_T('_'));
	m_RemoteURL.LoadHistory(CString(_T("Software\\TortoiseGit\\History\\PushURLS\\"))+WorkingDir, _T("url"));
	CString clippath=CAppUtils::GetClipboardLink();
	if(clippath.IsEmpty())
		m_RemoteURL.SetCurSel(0);
	else
		m_RemoteURL.SetWindowText(clippath);

	m_RemoteURL.EnableWindow(FALSE);
	CheckRadioButton(IDC_RD_REMOTE,IDC_RD_URL,IDC_RD_REMOTE);


	this->m_regAutoLoad = CRegDWORD(CString(_T("Software\\TortoiseGit\\History\\PushDlgAutoLoad\\"))+WorkingDir,
									m_bAutoLoad);
	m_bAutoLoad = this->m_regAutoLoad;
	if(!CAppUtils::IsSSHPutty())
		m_bAutoLoad = false;

	Refresh();


	//m_BranchRemote.SetWindowTextW(m_BranchSource.GetString());

	this->UpdateData(false);
	return TRUE;
}
Example #8
0
bool CMpaDecSettingsWnd::OnActivate()
{
	DWORD dwStyle = WS_VISIBLE|WS_CHILD|WS_TABSTOP;

	CRect r;

	CPoint p(10, 10);

	m_outputformat_static.Create(ResStr(IDS_MPADECSETTINGSWND_0), dwStyle, CRect(p, CSize(120, m_fontheight)), this);

	p.y += m_fontheight + 5;

	m_outputformat_combo.Create(dwStyle|CBS_DROPDOWNLIST, CRect(p + CSize(10, 0), CSize(100, 200)), this, IDC_PP_COMBO1);
	m_outputformat_combo.SetItemData(m_outputformat_combo.AddString(_T("PCM 16 Bit")), SF_PCM16);
	m_outputformat_combo.SetItemData(m_outputformat_combo.AddString(_T("PCM 24 Bit")), SF_PCM24);
	m_outputformat_combo.SetItemData(m_outputformat_combo.AddString(_T("PCM 32 Bit")), SF_PCM32);
	m_outputformat_combo.SetItemData(m_outputformat_combo.AddString(_T("IEEE Float")), SF_FLOAT32);
	m_outputformat_combo.SetCurSel(0);

	for(int i = 0; i < m_outputformat_combo.GetCount(); i++)
		if((int)m_outputformat_combo.GetItemData(i) == m_outputformat)
			m_outputformat_combo.SetCurSel(i);

	p.y += 30;

	CString	strSpeak;
	strSpeak.Format (_T("%s%s"), ResStr(IDS_MPADECSETTINGSWND_1), GetDolbyMode(m_ddmode));
	m_ac3spkcfg_static.Create(ResStr(IDS_MPADECSETTINGSWND_1) + GetDolbyMode(m_ddmode), dwStyle, CRect(p, CSize(220, m_fontheight)), this);

	p.y += m_fontheight + 5;

	m_ac3spkcfg_combo.Create(dwStyle|CBS_DROPDOWNLIST, CRect(p + CSize(150, 0), CSize(100, 200)), this, IDC_PP_COMBO2);
	m_ac3spkcfg_combo.SetItemData(m_ac3spkcfg_combo.AddString(_T("单声道")), A52_MONO);
	m_ac3spkcfg_combo.SetItemData(m_ac3spkcfg_combo.AddString(_T("双单声道")), A52_CHANNEL);
	m_ac3spkcfg_combo.SetItemData(m_ac3spkcfg_combo.AddString(_T("立体声")), A52_STEREO);
	m_ac3spkcfg_combo.SetItemData(m_ac3spkcfg_combo.AddString(_T("杜比立体声")), A52_DOLBY);
	m_ac3spkcfg_combo.SetItemData(m_ac3spkcfg_combo.AddString(ResStr(IDS_MPA_3F)), A52_3F);
	m_ac3spkcfg_combo.SetItemData(m_ac3spkcfg_combo.AddString(ResStr(IDS_MPA_2F_1R)), A52_2F1R);
	m_ac3spkcfg_combo.SetItemData(m_ac3spkcfg_combo.AddString(ResStr(IDS_MPA_3F_1R)), A52_3F1R);
	m_ac3spkcfg_combo.SetItemData(m_ac3spkcfg_combo.AddString(ResStr(IDS_MPA_2F_2R)), A52_2F2R);
	m_ac3spkcfg_combo.SetItemData(m_ac3spkcfg_combo.AddString(ResStr(IDS_MPA_3F_2R)), A52_3F2R);
	m_ac3spkcfg_combo.SetItemData(m_ac3spkcfg_combo.AddString(ResStr(IDS_MPA_CHANNEL_1)), A52_CHANNEL1);
	m_ac3spkcfg_combo.SetItemData(m_ac3spkcfg_combo.AddString(ResStr(IDS_MPA_CHANNEL_2)), A52_CHANNEL2);

	for(int i = 0, sel = abs(m_ac3spkcfg) & A52_CHANNEL_MASK; i < m_ac3spkcfg_combo.GetCount(); i++)
		if((int)m_ac3spkcfg_combo.GetItemData(i) == sel)
			m_ac3spkcfg_combo.SetCurSel(i);

	m_ac3spkcfg_combo.GetWindowRect(r);
	ScreenToClient(r);

	m_ac3lfe_check.Create(_T("LFE"), dwStyle|BS_AUTOCHECKBOX, CRect(CPoint(r.left, r.bottom + 3), CSize(50, m_fontheight)), this, IDC_PP_CHECK4);
	m_ac3lfe_check.SetCheck(!!(abs(m_ac3spkcfg) & A52_LFE));

	for(int i = 0, h = max(20, m_fontheight)+1; i < countof(m_ac3spkcfg_radio); i++, p.y += h)
	{
		static const TCHAR* labels[] = {m_strDecodeToSpeaker, _T("SPDIF")};
		DWORD ddwStyle = dwStyle;
		if(wcscmp(labels[i],_T("SPDIF")) == 0){
			ddwStyle =  (dwStyle& ~WS_VISIBLE);
		}
		m_ac3spkcfg_radio[i].Create(labels[i],ddwStyle|BS_AUTORADIOBUTTON|(i == 0 ? WS_GROUP : 0), CRect(p + CPoint(10, 0), CSize(140, h)), this, IDC_PP_RADIO1+i);
	}

	CheckRadioButton(IDC_PP_RADIO1, IDC_PP_RADIO2, m_ac3spkcfg >= 0 ? IDC_PP_RADIO1 : IDC_PP_RADIO2);

	p.y += 5;

	m_ac3spkcfg_check.Create(ResStr(IDS_MPA_DYNRANGE), dwStyle|BS_AUTOCHECKBOX, CRect(p + CPoint(10, 0), CSize(150, m_fontheight)), this, IDC_PP_CHECK1);
	m_ac3spkcfg_check.SetCheck(m_ac3drc);

	p.y += m_fontheight + 10;

	m_dtsspkcfg_static.Create(ResStr(IDS_MPADECSETTINGSWND_7), dwStyle, CRect(p, CSize(120, m_fontheight)), this);

	p.y += m_fontheight + 5;

	m_dtsspkcfg_combo.Create(dwStyle|CBS_DROPDOWNLIST, CRect(p + CSize(150, 0), CSize(100, 200)), this, IDC_PP_COMBO3);
	m_dtsspkcfg_combo.SetItemData(m_dtsspkcfg_combo.AddString(_T("单声道")), DTS_MONO);
	m_dtsspkcfg_combo.SetItemData(m_dtsspkcfg_combo.AddString(_T("双单声道")), DTS_CHANNEL);
	m_dtsspkcfg_combo.SetItemData(m_dtsspkcfg_combo.AddString(_T("立体声")), DTS_STEREO);
	//m_dtsspkcfg_combo.SetItemData(m_dtsspkcfg_combo.AddString(_T("Stereo ..")), DTS_STEREO_SUMDIFF);
	//m_dtsspkcfg_combo.SetItemData(m_dtsspkcfg_combo.AddString(_T("Stereo ..")), DTS_STEREO_TOTAL);
	m_dtsspkcfg_combo.SetItemData(m_dtsspkcfg_combo.AddString(ResStr(IDS_MPA_3F)), DTS_3F);
	m_dtsspkcfg_combo.SetItemData(m_dtsspkcfg_combo.AddString(ResStr(IDS_MPA_2F_1R)), DTS_2F1R);
	m_dtsspkcfg_combo.SetItemData(m_dtsspkcfg_combo.AddString(ResStr(IDS_MPA_3F_1R)), DTS_3F1R);
	m_dtsspkcfg_combo.SetItemData(m_dtsspkcfg_combo.AddString(ResStr(IDS_MPA_2F_2R)), DTS_2F2R);
	m_dtsspkcfg_combo.SetItemData(m_dtsspkcfg_combo.AddString(ResStr(IDS_MPA_3F_2R)), DTS_3F2R);

	for(int i = 0, sel = abs(m_dtsspkcfg) & DTS_CHANNEL_MASK; i < m_dtsspkcfg_combo.GetCount(); i++)
		if((int)m_dtsspkcfg_combo.GetItemData(i) == sel)
			m_dtsspkcfg_combo.SetCurSel(i);

	m_dtsspkcfg_combo.GetWindowRect(r);
	ScreenToClient(r);

	m_dtslfe_check.Create(_T("LFE"), dwStyle|BS_AUTOCHECKBOX, CRect(CPoint(r.left, r.bottom + 3), CSize(50, m_fontheight)), this, IDC_PP_CHECK5);
	m_dtslfe_check.SetCheck(!!(abs(m_dtsspkcfg) & DTS_LFE));

	for(int i = 0, h = max(20, m_fontheight)+1; i < countof(m_dtsspkcfg_radio); i++, p.y += h)
	{
		static const TCHAR* labels[] = {m_strDecodeToSpeaker, _T("SPDIF")};
		DWORD ddwStyle = dwStyle;
		if(wcscmp(labels[i],_T("SPDIF")) == 0){
			ddwStyle =  (dwStyle& ~WS_VISIBLE);
		}
		m_dtsspkcfg_radio[i].Create(labels[i], ddwStyle|BS_AUTORADIOBUTTON|(i == 0 ? WS_GROUP : 0), CRect(p + CPoint(10, 0), CSize(140, h)), this, IDC_PP_RADIO3+i);
	}

	CheckRadioButton(IDC_PP_RADIO3, IDC_PP_RADIO4, m_dtsspkcfg >= 0 ? IDC_PP_RADIO3 : IDC_PP_RADIO4);

	p.y += 5;

	m_dtsspkcfg_check.Create(ResStr(IDS_MPA_DYNRANGE), dwStyle|WS_DISABLED|BS_AUTOCHECKBOX, CRect(p + CPoint(10, 0), CSize(150, m_fontheight)), this, IDC_PP_CHECK2);
	m_dtsspkcfg_check.SetCheck(m_dtsdrc);

	p.y += m_fontheight + 10;

	m_aacspkcfg_static.Create(ResStr(IDS_MPADECSETTINGSWND_11), dwStyle, CRect(p, CSize(120, m_fontheight)), this);

	p.y += m_fontheight + 5;

	m_aacdownmix_check.Create(ResStr(IDS_MPADECSETTINGSWND_12), dwStyle|BS_AUTOCHECKBOX, CRect(p + CPoint(10, 0), CSize(150, m_fontheight)), this, IDC_PP_CHECK3);
	m_aacdownmix_check.SetCheck(m_aacdownmix);

	for(CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow())
		pWnd->SetFont(&m_font, FALSE);

	return true;
}
Example #9
0
static INT_PTR CALLBACK CheckOptionsFastProc(HWND hDlg, UINT messg, WPARAM wParam, LPARAM lParam)
{
	switch (messg)
	{
	case WM_SETHOTKEY:
		gnWndSetHotkey = wParam;
		break;

	case WM_INITDIALOG:
		{
			SendMessage(hDlg, WM_SETICON, ICON_BIG, (LPARAM)hClassIcon);
			SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)hClassIconSm);

			if (gp_DpiAware)
			{
				gp_DpiAware->Attach(hDlg, NULL);
			}

			RECT rect = {};
			if (GetWindowRect(hDlg, &rect))
			{
				CDpiAware::GetCenteredRect(NULL, rect);
				MoveWindowRect(hDlg, rect);
			}

			LRESULT lbRc = FALSE;
			if (lParam)
			{
				SetWindowText(hDlg, (LPCWSTR)lParam);
			}
			else
			{
				wchar_t szTitle[512];
				wcscpy_c(szTitle, gpConEmu->GetDefaultTitle());
				wcscat_c(szTitle, L" fast configuration");
				SetWindowText(hDlg, szTitle);
			}


			// lbStorageLocation
			SettingsStorage Storage = {}; bool ReadOnly = false;
			gpSet->GetSettingsType(Storage, ReadOnly);
			wchar_t* pszSettingsPlaces[] = {
				lstrdup(L"HKEY_CURRENT_USER\\Software\\ConEmu"),
				ExpandEnvStr(L"%APPDATA%\\ConEmu.xml"),
				ExpandEnvStr(L"%ConEmuBaseDir%\\ConEmu.xml"),
				ExpandEnvStr(L"%ConEmuDir%\\ConEmu.xml"),
				NULL
			};
			int iAllowed = 0;
			if (lstrcmp(Storage.szType, CONEMU_CONFIGTYPE_XML) == 0)
			{
				iAllowed = 1; // Реестр уже низя
				if (Storage.pszFile)
				{
					if (lstrcmpi(Storage.pszFile, pszSettingsPlaces[1]) == 0)
						iAllowed = 1; // OK, перебить может любой другой xml
					else if (lstrcmpi(Storage.pszFile, pszSettingsPlaces[2]) == 0)
						iAllowed = 2; // "Перебить" может только %APPDATA%
					else if (lstrcmpi(Storage.pszFile, pszSettingsPlaces[3]) == 0)
						iAllowed = 3; // Приоритетнее настроек нет
					else
					{
						// Этот xml мог быть указан в "/LoadCfgFile ..."
						SafeFree(pszSettingsPlaces[3]);
						pszSettingsPlaces[3] = lstrdup(Storage.pszFile);
						iAllowed = 3; // Приоритетнее настроек нет
					}
				}
			}
			while (pszSettingsPlaces[iAllowed])
			{
				SendDlgItemMessage(hDlg, lbStorageLocation, CB_ADDSTRING, 0, (LPARAM)pszSettingsPlaces[iAllowed]);
				iAllowed++;
			}
			SendDlgItemMessage(hDlg, lbStorageLocation, CB_SETCURSEL, 0, 0);
			for (int i = 0; pszSettingsPlaces[i]; i++)
			{
				SafeFree(pszSettingsPlaces[i]);
			}


			// continue
			CheckDlgButton(hDlg, cbSingleInstance, gpSetCls->IsSingleInstanceArg());

			CheckDlgButton(hDlg, cbUseKeyboardHooksFast, gpSet->isKeyboardHooks(true));



			// Debug purposes only. ConEmu.exe switch "/nokeyhooks"
			#ifdef _DEBUG
			EnableWindow(GetDlgItem(hDlg, cbUseKeyboardHooksFast), !gpConEmu->DisableKeybHooks);
			#endif

			CheckDlgButton(hDlg, cbInjectConEmuHkFast, gpSet->isUseInjects);

			if (!gpConEmu->isUpdateAllowed())
			{
				EnableWindow(GetDlgItem(hDlg, cbEnableAutoUpdateFast), FALSE);
				EnableWindow(GetDlgItem(hDlg, rbAutoUpdateStableFast), FALSE);
				EnableWindow(GetDlgItem(hDlg, rbAutoUpdatePreviewFast), FALSE);
				EnableWindow(GetDlgItem(hDlg, rbAutoUpdateDeveloperFast), FALSE);
				EnableWindow(GetDlgItem(hDlg, stEnableAutoUpdateFast), FALSE);
			}
			else
			{
				if (gpSet->UpdSet.isUpdateUseBuilds != 0)
					CheckDlgButton(hDlg, cbEnableAutoUpdateFast, gpSet->UpdSet.isUpdateCheckOnStartup|gpSet->UpdSet.isUpdateCheckHourly);
				CheckRadioButton(hDlg, rbAutoUpdateStableFast, rbAutoUpdateDeveloperFast,
					(gpSet->UpdSet.isUpdateUseBuilds == 1) ? rbAutoUpdateStableFast :
					(gpSet->UpdSet.isUpdateUseBuilds == 3) ? rbAutoUpdatePreviewFast : rbAutoUpdateDeveloperFast);
			}

			if (!bCheckIme)
			{
				ShowWindow(GetDlgItem(hDlg, gbDisableConImeFast), SW_HIDE);
				ShowWindow(GetDlgItem(hDlg, cbDisableConImeFast), SW_HIDE);
				ShowWindow(GetDlgItem(hDlg, stDisableConImeFast1), SW_HIDE);
				ShowWindow(GetDlgItem(hDlg, stDisableConImeFast2), SW_HIDE);
				ShowWindow(GetDlgItem(hDlg, stDisableConImeFast3), SW_HIDE);
				RECT rcGroup, rcBtn, rcWnd;
				if (GetWindowRect(GetDlgItem(hDlg, gbDisableConImeFast), &rcGroup))
				{
					int nShift = (rcGroup.bottom-rcGroup.top);

					HWND h = GetDlgItem(hDlg, IDOK);
					GetWindowRect(h, &rcBtn); MapWindowPoints(NULL, hDlg, (LPPOINT)&rcBtn, 2);
					SetWindowPos(h, NULL, rcBtn.left, rcBtn.top - nShift, 0,0, SWP_NOSIZE|SWP_NOZORDER);

					h = GetDlgItem(hDlg, IDCANCEL);
					GetWindowRect(h, &rcBtn); MapWindowPoints(NULL, hDlg, (LPPOINT)&rcBtn, 2);
					SetWindowPos(h, NULL, rcBtn.left, rcBtn.top - nShift, 0,0, SWP_NOSIZE|SWP_NOZORDER);

					h = GetDlgItem(hDlg, stHomePage);
					GetWindowRect(h, &rcBtn); MapWindowPoints(NULL, hDlg, (LPPOINT)&rcBtn, 2);
					SetWindowPos(h, NULL, rcBtn.left, rcBtn.top - nShift, 0,0, SWP_NOSIZE|SWP_NOZORDER);

					GetWindowRect(hDlg, &rcWnd);
					MoveWindow(hDlg, rcWnd.left, rcWnd.top+(nShift>>1), rcWnd.right-rcWnd.left, rcWnd.bottom-rcWnd.top-nShift, FALSE);
				}
			}

			return lbRc;
		}
Example #10
0
//Handle Select Mode dialog box
INT_PTR CALLBACK WINDOW::SelectModeProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch(msg)
	{
	case WM_COMMAND:
		{
			switch (LOWORD(wParam))
			{
			case IDOK:	//If OK was pressed
				{
					//Make changes to resolution
					if(IsDlgButtonChecked(hWnd, IDC_640))
					{
						Instance()->width=640;
						Instance()->height=480;
					}
					if(IsDlgButtonChecked(hWnd, IDC_800))
					{
						Instance()->width=800;
						Instance()->height=600;
					}
					if(IsDlgButtonChecked(hWnd, IDC_1024))
					{
						Instance()->width=1024;
						Instance()->height=768;
					}

					EndDialog(hWnd, wParam);
					return true;
				}
			}

			switch (HIWORD(wParam))
			{
			case BN_CLICKED:	//If a button was pressed
				{
					CheckDlgButton(hWnd, lParam, BST_CHECKED);

					//If it is the fullscreen button, change the variable
					if((int)LOWORD(wParam) == IDC_FULLSCREEN)
						Instance()->fullscreen=!Instance()->fullscreen;

					//If it is an AA settings button, save the nuber of samples
					if((int) LOWORD(wParam) == IDC_NOAA)
						Instance()->numSamples=0;

					for(int i=2; i<16; ++i)
					{
						if((int) LOWORD(wParam)==IDC_2AA+i-2)
							Instance()->numSamples=i;
					}

					return true;
				}
			}

			break;
		}

	case WM_INITDIALOG:		//Initiate dialog box
		{
			//Set default resolution
			if(Instance()->width==640)
				CheckRadioButton(hWnd, IDC_640, IDC_1024, IDC_640);
			if(Instance()->width==800)
				CheckRadioButton(hWnd, IDC_640, IDC_1024, IDC_800);
			if(Instance()->width==1024)
				CheckRadioButton(hWnd, IDC_640, IDC_1024, IDC_1024);

			//Set default full screen
			if(Instance()->fullscreen)
				CheckDlgButton(hWnd, IDC_FULLSCREEN, true);

			//Grey out the unsupported AA modes
			HWND buttonHWnd;
			for(int i=2; i<=16; ++i)
			{
				//requires that 2AA - 16AA have sequential ID numbers
				buttonHWnd=GetDlgItem(hWnd, IDC_2AA+(i-2));

				EnableWindow(buttonHWnd, Instance()->samplesSupported[i]);
			}

			//Set default to no AA
			CheckRadioButton(hWnd, IDC_NOAA, IDC_16AA, IDC_NOAA);

			return true;
		}
	}

	return false;
}
Example #11
0
void WINAPI handleRadioBtn(HWND hwnd, int methodID, const char* methodVal, DWORD resourceID) {
	gOptions.setOption(methodID, methodVal);
	CheckRadioButton(hwnd, IDC_RADIO_GET, IDC_RADIO_OPTIONS, resourceID);
}
Example #12
0
/*
 * Dialog-box function for the main PuTTYgen dialog box.
 */
static int CALLBACK MainDlgProc(HWND hwnd, UINT msg,
				WPARAM wParam, LPARAM lParam)
{
    static const char generating_msg[] =
	"Please wait while a key is generated...";
    static const char entropy_msg[] =
	"Please generate some randomness by moving the mouse over the blank area.";
    struct MainDlgState *state;

    switch (msg) {
      case WM_INITDIALOG:
        if (help_path)
            SetWindowLong(hwnd, GWL_EXSTYLE,
                          GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_CONTEXTHELP);
        else {
            /*
             * If we add a Help button, this is where we destroy it
             * if the help file isn't present.
             */
        }
        requested_help = FALSE;
	SendMessage(hwnd, WM_SETICON, (WPARAM) ICON_BIG,
		    (LPARAM) LoadIcon(hinst, MAKEINTRESOURCE(200)));

	state = snew(struct MainDlgState);
	state->generation_thread_exists = FALSE;
	state->collecting_entropy = FALSE;
	state->entropy = NULL;
	state->key_exists = FALSE;
	SetWindowLong(hwnd, GWL_USERDATA, (LONG) state);
	{
	    HMENU menu, menu1;

	    menu = CreateMenu();

	    menu1 = CreateMenu();
	    AppendMenu(menu1, MF_ENABLED, IDC_LOAD, "&Load private key");
	    AppendMenu(menu1, MF_ENABLED, IDC_SAVEPUB, "Save p&ublic key");
	    AppendMenu(menu1, MF_ENABLED, IDC_SAVE, "&Save private key");
	    AppendMenu(menu1, MF_SEPARATOR, 0, 0);
	    AppendMenu(menu1, MF_ENABLED, IDC_QUIT, "E&xit");
	    AppendMenu(menu, MF_POPUP | MF_ENABLED, (UINT) menu1, "&File");
	    state->filemenu = menu1;

	    menu1 = CreateMenu();
	    AppendMenu(menu1, MF_ENABLED, IDC_GENERATE, "&Generate key pair");
	    AppendMenu(menu1, MF_SEPARATOR, 0, 0);
	    AppendMenu(menu1, MF_ENABLED, IDC_KEYSSH1, "SSH&1 key (RSA)");
	    AppendMenu(menu1, MF_ENABLED, IDC_KEYSSH2RSA, "SSH2 &RSA key");
	    AppendMenu(menu1, MF_ENABLED, IDC_KEYSSH2DSA, "SSH2 &DSA key");
	    AppendMenu(menu, MF_POPUP | MF_ENABLED, (UINT) menu1, "&Key");
	    state->keymenu = menu1;

	    menu1 = CreateMenu();
	    AppendMenu(menu1, MF_ENABLED, IDC_IMPORT, "&Import key");
	    AppendMenu(menu1, MF_SEPARATOR, 0, 0);
	    AppendMenu(menu1, MF_ENABLED, IDC_EXPORT_OPENSSH,
		       "Export &OpenSSH key");
	    AppendMenu(menu1, MF_ENABLED, IDC_EXPORT_SSHCOM,
		       "Export &ssh.com key");
	    AppendMenu(menu, MF_POPUP | MF_ENABLED, (UINT) menu1,
		       "Con&versions");
	    state->cvtmenu = menu1;

	    menu1 = CreateMenu();
	    AppendMenu(menu1, MF_ENABLED, IDC_ABOUT, "&About");
	    if (help_path)
		AppendMenu(menu1, MF_ENABLED, IDC_GIVEHELP, "&Help");
	    AppendMenu(menu, MF_POPUP | MF_ENABLED, (UINT) menu1, "&Help");

	    SetMenu(hwnd, menu);
	}

	/*
	 * Centre the window.
	 */
	{			       /* centre the window */
	    RECT rs, rd;
	    HWND hw;

	    hw = GetDesktopWindow();
	    if (GetWindowRect(hw, &rs) && GetWindowRect(hwnd, &rd))
		MoveWindow(hwnd,
			   (rs.right + rs.left + rd.left - rd.right) / 2,
			   (rs.bottom + rs.top + rd.top - rd.bottom) / 2,
			   rd.right - rd.left, rd.bottom - rd.top, TRUE);
	}

	{
	    struct ctlpos cp, cp2;

	    /* Accelerators used: acglops1rbd */

	    ctlposinit(&cp, hwnd, 4, 4, 4);
	    beginbox(&cp, "Key", IDC_BOX_KEY);
	    cp2 = cp;
	    statictext(&cp2, "No key.", 1, IDC_NOKEY);
	    cp2 = cp;
	    statictext(&cp2, "", 1, IDC_GENERATING);
	    progressbar(&cp2, IDC_PROGRESS);
	    bigeditctrl(&cp,
			"&Public key for pasting into authorized_keys file:",
			IDC_PKSTATIC, IDC_KEYDISPLAY, 5);
	    SendDlgItemMessage(hwnd, IDC_KEYDISPLAY, EM_SETREADONLY, 1, 0);
	    staticedit(&cp, "Key f&ingerprint:", IDC_FPSTATIC,
		       IDC_FINGERPRINT, 75);
	    SendDlgItemMessage(hwnd, IDC_FINGERPRINT, EM_SETREADONLY, 1,
			       0);
	    staticedit(&cp, "Key &comment:", IDC_COMMENTSTATIC,
		       IDC_COMMENTEDIT, 75);
	    staticpassedit(&cp, "Key p&assphrase:", IDC_PASSPHRASE1STATIC,
			   IDC_PASSPHRASE1EDIT, 75);
	    staticpassedit(&cp, "C&onfirm passphrase:",
			   IDC_PASSPHRASE2STATIC, IDC_PASSPHRASE2EDIT, 75);
	    endbox(&cp);
	    beginbox(&cp, "Actions", IDC_BOX_ACTIONS);
	    staticbtn(&cp, "Generate a public/private key pair",
		      IDC_GENSTATIC, "&Generate", IDC_GENERATE);
	    staticbtn(&cp, "Load an existing private key file",
		      IDC_LOADSTATIC, "&Load", IDC_LOAD);
	    static2btn(&cp, "Save the generated key", IDC_SAVESTATIC,
		       "Save p&ublic key", IDC_SAVEPUB,
		       "&Save private key", IDC_SAVE);
	    endbox(&cp);
	    beginbox(&cp, "Parameters", IDC_BOX_PARAMS);
	    radioline(&cp, "Type of key to generate:", IDC_TYPESTATIC, 3,
		      "SSH&1 (RSA)", IDC_KEYSSH1,
		      "SSH2 &RSA", IDC_KEYSSH2RSA,
		      "SSH2 &DSA", IDC_KEYSSH2DSA, NULL);
	    staticedit(&cp, "Number of &bits in a generated key:",
		       IDC_BITSSTATIC, IDC_BITS, 20);
	    endbox(&cp);
	}
	CheckRadioButton(hwnd, IDC_KEYSSH1, IDC_KEYSSH2DSA, IDC_KEYSSH2RSA);
	CheckMenuRadioItem(state->keymenu, IDC_KEYSSH1, IDC_KEYSSH2DSA,
			   IDC_KEYSSH2RSA, MF_BYCOMMAND);
	SetDlgItemInt(hwnd, IDC_BITS, DEFAULT_KEYSIZE, FALSE);

	/*
	 * Initially, hide the progress bar and the key display,
	 * and show the no-key display. Also disable the Save
	 * buttons, because with no key we obviously can't save
	 * anything.
	 */
	ui_set_state(hwnd, state, 0);

	/*
	 * Load a key file if one was provided on the command line.
	 */
	if (cmdline_keyfile)
	    load_key_file(hwnd, state, filename_from_str(cmdline_keyfile), 0);

	return 1;
      case WM_MOUSEMOVE:
	state = (struct MainDlgState *) GetWindowLong(hwnd, GWL_USERDATA);
	if (state->collecting_entropy &&
	    state->entropy && state->entropy_got < state->entropy_required) {
	    state->entropy[state->entropy_got++] = lParam;
	    state->entropy[state->entropy_got++] = GetMessageTime();
	    SendDlgItemMessage(hwnd, IDC_PROGRESS, PBM_SETPOS,
			       state->entropy_got, 0);
	    if (state->entropy_got >= state->entropy_required) {
		struct rsa_key_thread_params *params;
		DWORD threadid;

		/*
		 * Seed the entropy pool
		 */
		random_add_heavynoise(state->entropy, state->entropy_size);
		memset(state->entropy, 0, state->entropy_size);
		sfree(state->entropy);
		state->collecting_entropy = FALSE;

		SetDlgItemText(hwnd, IDC_GENERATING, generating_msg);
		SendDlgItemMessage(hwnd, IDC_PROGRESS, PBM_SETRANGE, 0,
				   MAKELPARAM(0, PROGRESSRANGE));
		SendDlgItemMessage(hwnd, IDC_PROGRESS, PBM_SETPOS, 0, 0);

		params = snew(struct rsa_key_thread_params);
		params->progressbar = GetDlgItem(hwnd, IDC_PROGRESS);
		params->dialog = hwnd;
		params->keysize = state->keysize;
		params->is_dsa = state->is_dsa;
		params->key = &state->key;
		params->dsskey = &state->dsskey;

		if (!CreateThread(NULL, 0, generate_rsa_key_thread,
				  params, 0, &threadid)) {
		    MessageBox(hwnd, "Out of thread resources",
			       "Key generation error",
			       MB_OK | MB_ICONERROR);
		    sfree(params);
		} else {
		    state->generation_thread_exists = TRUE;
		}
	    }
	}
	break;
      case WM_COMMAND:
	switch (LOWORD(wParam)) {
	  case IDC_KEYSSH1:
	  case IDC_KEYSSH2RSA:
	  case IDC_KEYSSH2DSA:
	    {
		state = (struct MainDlgState *)
		    GetWindowLong(hwnd, GWL_USERDATA);
		if (!IsDlgButtonChecked(hwnd, LOWORD(wParam)))
		    CheckRadioButton(hwnd, IDC_KEYSSH1, IDC_KEYSSH2DSA,
				     LOWORD(wParam));
		CheckMenuRadioItem(state->keymenu, IDC_KEYSSH1, IDC_KEYSSH2DSA,
				   LOWORD(wParam), MF_BYCOMMAND);
	    }
	    break;
	  case IDC_QUIT:
	    PostMessage(hwnd, WM_CLOSE, 0, 0);
	    break;
	  case IDC_COMMENTEDIT:
	    if (HIWORD(wParam) == EN_CHANGE) {
		state = (struct MainDlgState *)
		    GetWindowLong(hwnd, GWL_USERDATA);
		if (state->key_exists) {
		    HWND editctl = GetDlgItem(hwnd, IDC_COMMENTEDIT);
		    int len = GetWindowTextLength(editctl);
		    if (*state->commentptr)
			sfree(*state->commentptr);
		    *state->commentptr = snewn(len + 1, char);
		    GetWindowText(editctl, *state->commentptr, len + 1);
		    if (state->ssh2) {
			setupbigedit2(hwnd, IDC_KEYDISPLAY, IDC_PKSTATIC,
				      &state->ssh2key);
		    } else {
			setupbigedit1(hwnd, IDC_KEYDISPLAY, IDC_PKSTATIC,
				      &state->key);
		    }
		}
	    }
Example #13
0
BOOL WINPROC EXPORT DlgRoomWhoAreYou (HWND hWnd,UINT wMsg,WPARAM wParam,LPARAM lParam)
{
	STRING	szTmp;
	WORD	wKey;
	int		iTmp;
    BOOL	bHandled = TRUE;
	int		iPtSize = 30;

	if (wMsg == WM_INITDIALOG)
	{
#ifdef _MAC	
		RECT rEdit;
#endif		
		DefRoomProc (hWnd, wMsg, wParam, lParam);

		if (LoadString (hInstAstral, IDS_FONT_NORMAL, szTmp, sizeof(szTmp)))
		{
			hDlgFont = (HFONT)NULL;
			hDlgFont = CreateFont (-iPtSize,		// Height
									0,				// Width
									0,				// Escapement
									0,				// Orientation
									0,				// Weight
									0,				// Italic
									0,				// Underline
									0,				// Strikeout
									0,				// Charset
									0,				// OutputPrecision
									0,				// ClipPrecision
									0,				// Quality
									0,				// PitchAndFamily
		  							(PSTR)szTmp);	// Typeface Name

			if (hDlgFont != NULL)
			{
				SendDlgItemMessage (hWnd, IDC_WHO_BUTTON1, WM_SETFONT, (WPARAM)hDlgFont, 0L);
				SendDlgItemMessage (hWnd, IDC_WHO_BUTTON2, WM_SETFONT, (WPARAM)hDlgFont, 0L);
				SendDlgItemMessage (hWnd, IDC_WHO_BUTTON3, WM_SETFONT, (WPARAM)hDlgFont, 0L);
				SendDlgItemMessage (hWnd, IDC_WHO_BUTTON4, WM_SETFONT, (WPARAM)hDlgFont, 0L);
				SendDlgItemMessage (hWnd, IDC_WHO_NEWBUTTON, WM_SETFONT, (WPARAM)hDlgFont, 0L);
				SendDlgItemMessage (hWnd, IDC_WHO_EDIT, WM_SETFONT, (WPARAM)hDlgFont, 0L);
			}
		}
		
		
#ifdef _MAC	
		// Make sure the edit control is exactly the same size as the radio button.
		// Without this hack, it is smaller on the mac.
		
		if (LoadString (hInstAstral, IDS_IM_NEW, szTmp, sizeof(szTmp)))
			SetDlgItemText (hWnd, IDC_WHO_EDIT, szTmp);

		GetClientRect(GetDlgItem(hWnd, IDC_WHO_NEWBUTTON), &rEdit);	
		SetWindowPos(
			GetDlgItem(hWnd, IDC_WHO_EDIT),
			NULL,
			0, 0,
			RectWidth(&rEdit),
			RectHeight(&rEdit),
			SWP_NOMOVE | SWP_NOZORDER);
#endif		
		
		// initially hide the edit control
    	ShowWindow (GetDlgItem(hWnd, IDC_WHO_EDIT), SW_HIDE);

		if (LoadString (hInstAstral, IDS_IM_NEW, szTmp, sizeof(szTmp)))
			SetDlgItemText (hWnd, IDC_WHO_NEWBUTTON, szTmp);

		DoInit (hWnd);

    	ShowWindow (GetDlgItem(hWnd, IDOK), SW_HIDE);
		fButtonHidden = FALSE;
		bHandled = TRUE;
	}
    else if (wMsg == WM_CLOSE)
    {
        AstralDlgEnd (hWnd,TRUE|2);
		bHandled = TRUE;
    }
    else if (wMsg == WM_COMMAND)
    {
		switch (wParam)
		{
			// Go To Room hotspot
			case HS_WHO:
				if (CheckUsername (hWnd))
				{
					DeleteObject (hDlgFont);
        			GoRoom (hInstAstral, RM_ARTROOM, FALSE);
				}
				bHandled = TRUE;
				break;

			// I'm New button
			case IDC_WHO_NEWBUTTON:
#ifndef _MAC	// This problem doesn't exist on the mac			
				if (! fNoUsers)	// hack for Windows focus problem
#endif				
				{
					CheckRadioButton (hWnd, IDC_WHO_BUTTON1,
					  IDC_WHO_NEWBUTTON, IDC_WHO_NEWBUTTON);
    				ShowWindow (GetDlgItem(hWnd, IDC_WHO_NEWBUTTON), SW_HIDE);
    				ShowWindow (GetDlgItem(hWnd, IDC_WHO_EDIT), SW_SHOW);

					if (LoadString (hInstAstral, IDS_YOUR_NAME, szTmp,
				  	sizeof(szTmp)))
						SetDlgItemText (hWnd, IDC_WHO_EDIT, szTmp);

					SetFocus (GetDlgItem (hWnd, IDC_WHO_EDIT));
					SendDlgItemMessage (hWnd, IDC_WHO_EDIT, EM_SETSEL, 0,
				  	  MAKELONG(0, -1) );
				}
				iButtonIndex = 4;
				fNoUsers = FALSE;
				bHandled = TRUE;
				fButtonHidden = TRUE;
				break;

			// Scroll names down
			case HS_WHO_UPARROW:
				if (iUserCount > 4)
				{
					iTmp = iUserIndex;
					if (iUserIndex > 0)
                    {
						iUserIndex--;
                    	ShowWindow (GetDlgItem(hWnd, HS_WHO_DNARROW), SW_SHOW);

						if (iUserIndex == 0)
                    		ShowWindow (GetDlgItem(hWnd, HS_WHO_UPARROW), SW_HIDE);
                    }
                    else
            			ShowWindow (GetDlgItem(hWnd, HS_WHO_UPARROW), SW_HIDE);

					if (iUserIndex != iTmp)
						UpdateButtons (hWnd, iUserIndex, iUserCount);
				}
				bHandled = TRUE;
				break;

			// Scroll names up
			case HS_WHO_DNARROW:
				if (iUserCount > 4)
				{
					iTmp = iUserIndex;
					if (iUserIndex < (iUserCount - 4))
                    {
						iUserIndex++;
                    	ShowWindow (GetDlgItem(hWnd, HS_WHO_UPARROW), SW_SHOW);

						if (iUserIndex +4 >= iUserCount)
                    		ShowWindow (GetDlgItem(hWnd, HS_WHO_DNARROW), SW_HIDE);
                    }
                    else
            			ShowWindow (GetDlgItem(hWnd, HS_WHO_DNARROW), SW_HIDE);

					if (iUserIndex != iTmp)
						UpdateButtons (hWnd, iUserIndex, iUserCount);
				}
				bHandled = TRUE;
				break;

			case IDC_WHO_BUTTON1:
				HandleButton (hWnd, 0);
        		bHandled = TRUE;
				// if they click twice on same control - validate and continue
				if ((iButtonIndex == 0) && (CheckUsername (hWnd)))
				{
					DeleteObject (hDlgFont);
        			GoRoom (hInstAstral, RM_ARTROOM, FALSE);
				}
				iButtonIndex = 0;
				break;

			case IDC_WHO_BUTTON2:
				HandleButton (hWnd, 1);
        		bHandled = TRUE;
				if ((iButtonIndex == 1) && (CheckUsername (hWnd)))
				{
					DeleteObject (hDlgFont);
        			GoRoom (hInstAstral, RM_ARTROOM, FALSE);
				}
				iButtonIndex = 1;
				break;

			case IDC_WHO_BUTTON3:
				HandleButton (hWnd, 2);
        		bHandled = TRUE;
				if ((iButtonIndex == 2) && (CheckUsername (hWnd)))
				{
					DeleteObject (hDlgFont);
        			GoRoom (hInstAstral, RM_ARTROOM, FALSE);
				}
				iButtonIndex = 2;
				break;

			case IDC_WHO_BUTTON4:
				HandleButton (hWnd, 3);
        		bHandled = TRUE;
				if ((iButtonIndex == 3) && (CheckUsername (hWnd)))
				{
					DeleteObject (hDlgFont);
        			GoRoom (hInstAstral, RM_ARTROOM, FALSE);
				}
				iButtonIndex = 3;
				break;

			case IDC_WHO_DELNAME:
				if (Control.CurrentUser[0] != 0)
				{
					if (! (GetNumberIniEntries() ))
					{
						if (GetUserNameByDir (Control.CurrentUser, szTmp))
						{
							DeleteUserName (szTmp);
							lstrcpy (szTmp, Control.WorkPath);
							lstrcat (szTmp, Control.CurrentUser);
#ifdef WIN32
							RemoveDirectory (szTmp);
#else
							_rmDir (szTmp);
#endif							
							clr ((LPTR)Control.CurrentUser, sizeof(Control.CurrentUser));
							DoInit (hWnd);
						}
					}
				}
        		bHandled = TRUE;
				break;

			case IDOK:
				bHandled = TRUE;
				if (CheckUsername (hWnd))
				{
					DeleteObject (hDlgFont);
       				GoRoom (hInstAstral, RM_ARTROOM, FALSE);
				}
				break;

			default:
        		bHandled = FALSE;
				break;
		}
    }
    else if (wMsg == WM_CHAR)
	{
		wKey = (WORD)lParam;
		if (wKey == VK_DELETE)
		{
			GetUserNameString (iUserIndex, szTmp);
		}
	}
    else
        bHandled = FALSE;

    if (! bHandled)
        bHandled = DefRoomProc (hWnd, wMsg, wParam, lParam);

    return bHandled;
}
BOOL CDlgExtractSignature::OnInitDialog() 
{
#ifndef _UNSTABLE
	CDialog::OnInitDialog();
	
	// TODO: Zusätzliche Initialisierung hier einfügen

	LOGFONT LogFont;
	char DefaultFontName[32];
	LONG defaultFontWeight;
	CFont *defaultFont = m_DefEditCtrl.GetFont();
	defaultFont->GetLogFont( &LogFont ); // Default Systemschrift ermitteln
	strncpy(DefaultFontName, LogFont.lfFaceName, 32); // Default Wert sichern
	defaultFontWeight = LogFont.lfWeight; // Default Wert sichern
	LogFont.lfWeight = FW_BOLD; // Auf Fettdruck umstellen
	Font.CreateFontIndirect( &LogFont ); // Font initialisieren
	m_TextMsgCtrl.SetFont(&Font);
	m_TextSigCtrl.SetFont(&Font);
	m_TextSignerCtrl.SetFont(&Font);
	m_TextKeyCtrl.SetFont(&Font);
	m_TextAlgCtrl.SetFont(&Font);

	LogFont.lfWeight = defaultFontWeight; // Auf default Wert zurückstellen
	strncpy(LogFont.lfFaceName, "Courier", 32); // Auf Courier umstellen
	Font2.CreateFontIndirect( &LogFont ); // Font2 initialisieren
    m_MessageCtrl.SetFont(&Font2);
	m_SignatureCtrl.SetFont(&Font2);
	//strncpy(LogFont.lfFaceName, DefaultFontStyle, 32);

	LoadString(AfxGetInstanceHandle(),IDS_STRING_SIGNATURE,pc_str,STR_LAENGE_STRING_TABLE);
	m_TextSig = (CString) pc_str;
	LoadString(AfxGetInstanceHandle(),IDS_STRING_SIGNED_MESSAGE,pc_str,STR_LAENGE_STRING_TABLE);
	m_TextMsg = (CString) pc_str;
	LoadString(AfxGetInstanceHandle(),IDS_STRING_SIGNATURE_ORIGINATOR,pc_str,STR_LAENGE_STRING_TABLE);
	m_TextSigner = (CString) pc_str;
	LoadString(AfxGetInstanceHandle(),IDS_STRING_SIGNATURE_USED_KEY,pc_str,STR_LAENGE_STRING_TABLE);
	m_TextKey = (CString) pc_str;
	LoadString(AfxGetInstanceHandle(),IDS_STRING_SIGNATURE_METHOD,pc_str,STR_LAENGE_STRING_TABLE);
	m_TextAlg = (CString) pc_str;
	UpdateData(FALSE);

	int err;

	bool messagefromfile=false; // zeigt an, ob die signierte Nachricht aus einer Datei
	// gelesen werden musste
	CString filename;
				
	CString SigAlg="";
	CString HashAlg="";
	CString UserKeyId="";
	int SignLength; // (Aus dem Ausgabefenster eingelesene) Länge der Signatur in Bits

	CKeyFile FileHandling;

	SignatureType = GetSignData(inFileName,messagefromfile,filename,&message,SigAlg,HashAlg,UserKeyId,&SignLength,&Signatur,c,d);
	// Folgende Speicherbereiche sind von GetSignData() alloziert worden und
	// müssen später wieder freigegeben werden:
	// message.octets (falls != NULL) 
	// Signatur.signature.bits (falls != NULL)

	if ( (SignatureType > 0) && (SignatureType != EC_SIGN) &&\
		(SignatureType != RSA_OR_DSA_SIGN) && (SignatureType != UNKNOWN_SIGN) )
	{
		// Fehler beim auslesen der Daten (Nicht genügend Speicher vorhanden)
		Message(IDS_STRING_ERR_MEMORY_SIGNATURE_VERIFICATION, MB_ICONSTOP);
		if (Signatur.signature.bits) free(Signatur.signature.bits);
		if (message.octets) free(message.octets);
		EndDialog(-1);
		return TRUE;
	}
	else if ((SignatureType != EC_SIGN) && (SignatureType != RSA_OR_DSA_SIGN) &&\
		(SignatureType != UNKNOWN_SIGN))
	{
		Message(IDS_STRING_ASYMKEY_COULD_NOT_EXTRACT_SIGNATURE,MB_ICONSTOP);
		if (Signatur.signature.bits) free(Signatur.signature.bits);
		if (message.octets) free(message.octets);
		EndDialog(-2);
		return TRUE;
	}

	if (messagefromfile == true)
	{
		// Die signierte Nachricht ist zu gross und passt nicht komplett
		// in ein CEdit Feld. Es wird lediglich ein erster Teil der Nachricht dargestellt
		LoadString(AfxGetInstanceHandle(),IDS_STRING_SIGNED_MESSAGE_FIRST_PART,pc_str,STR_LAENGE_STRING_TABLE);
		m_TextMsg = (CString) pc_str;
	}

	// Überprüfe, ob angegebener Schlüsselbezeichner tatsächlich existiert
	bool keyExists = FileHandling.FilenameExisting(UserKeyId);

	char *name=NULL;
	char *firstname=NULL;
	char *keyType=NULL;
	char *keyInfo=NULL;
	char *creattime=NULL;
	char *ctstr=NULL;

	CString kInfo;

	if (keyExists == true)
	{
		err = FileHandling.ExtractData(UserKeyId,&ctstr,&creattime,&name,&firstname,&keyType,&keyInfo);
		if (ctstr) free(ctstr); // wird hier nicht benötigt
		if (keyInfo==NULL)
			kInfo="";
		else
			kInfo = ((CString)" (")+((CString)keyInfo)+((CString)") ");

		// Infos über den Signaturersteller
		m_InfoAboutSigner = (CString) ((CString)firstname)+((CString)" ")+((CString)name); // Signatur erzeugt von:

		// Infos über Schlüssel
		LoadString(AfxGetInstanceHandle(),IDS_STRING_SIGNATURE_DATE,pc_str1,STR_LAENGE_STRING_TABLE);
		sprintf(pc_str, pc_str1,((CString)keyType)+kInfo,((CString)creattime));
		m_KeyInfo = (CString) pc_str; // Benutzter Schlüssel:
	}
	else
	{
		// Schlüsselbezeichner "UserKeyId" existiert nicht
		LoadString(AfxGetInstanceHandle(),IDS_STRING_SIGNATURE_UNKNOWN_KEY_IDENTIFIER,pc_str1,STR_LAENGE_STRING_TABLE);
		// pc_str1 = "Übermittelter Schlüsselbezeichner existiert nicht!"
		m_InfoAboutSigner = ((CString)pc_str1);
		// Signaturerzeuger unbekannt
	}

	// Überprüfe ob angegebener Signatur-/Hashalgorithmus bekannt ist
	if ( (SigAlg!="RSA") && (SigAlg!="DSA") && (SigAlg!="ECSP-NR") && (SigAlg!="ECSP-DSA") )
	{
		// unbekannter Signaturalgorithmus angegeben
		LoadString(AfxGetInstanceHandle(),IDS_STRING_UNKNOWN,pc_str,STR_LAENGE_STRING_TABLE);
		// pc_str = "unbekannt !"
		SigAlg = SigAlg+((CString)" (")+((CString)pc_str)+((CString)")");
	}
	if ( (HashAlg!="MD2") && (HashAlg!="MD5") && (HashAlg!="SHA") && (HashAlg!="SHA-1") &&\
		(HashAlg!="RIPEMD-160") )
	{
		// unbekannter Hashalgorithmus angegeben
		LoadString(AfxGetInstanceHandle(),IDS_STRING_UNKNOWN,pc_str,STR_LAENGE_STRING_TABLE);
		// pc_str = "unbekannt !"
		HashAlg = HashAlg+((CString)" (")+((CString)pc_str)+((CString)")");
	}

	// Benutzter Signaturalgorithmus
	LoadString(AfxGetInstanceHandle(),IDS_STRING_SIGNATURE_HASH_FUNCTION,pc_str1,STR_LAENGE_STRING_TABLE);
	sprintf(pc_str, pc_str1, SigAlg, HashAlg);
	m_SigHashAlg = (CString) pc_str;

	UpdateData(FALSE);

	int srcSize;
	int destSize;

	// Signierte Nachricht ausgeben
	if (message.noctets != 0)
	{
		// Nachricht ist kein leerer String
		srcSize = message.noctets;
		destSize = ((srcSize+hexdumpCols-1)/hexdumpCols)*(11+hexdumpCols*4)-hexdumpCols+(srcSize%hexdumpCols)+1;

		char *msgdata = (char *) malloc(destSize+1);

		err = HexDumpMem(msgdata, destSize, (unsigned char *) message.octets, srcSize, hexdumpCols);
		if (err == 0)
		{
			// Fehler
			if (Signatur.signature.bits) free(Signatur.signature.bits);
			if (message.octets) free(message.octets);
			return TRUE;
		}
		CString mData(msgdata);
		m_Message = mData;
		free(msgdata);
	}
	// Länge der signierten Nachricht
	char buffer[30];
	_itoa( message.noctets, buffer, 10 );
	LoadString(AfxGetInstanceHandle(),IDS_STRING_SIGNATURE_MESSAGE_LENGTH,pc_str1,STR_LAENGE_STRING_TABLE);
	sprintf(pc_str, pc_str1,((CString)buffer));
	m_MessageLength = (CString) pc_str;
	UpdateData(FALSE);

	if (SignatureType == EC_SIGN)
	{
		//
		CheckRadioButton (IDC_RADIO1, IDC_RADIO4, IDC_RADIO3); UpdateData(TRUE);
		base = 10; // Signatur als Dezimalzahlen darstellen

		int signlength = theApp.SecudeLib.lngtouse(c)+theApp.SecudeLib.lngtouse(d)+2;// Bit-Länge der Signatur

		char buffer[30];
		_itoa( signlength, buffer, 10 );
		LoadString(AfxGetInstanceHandle(),IDS_STRING_SIGNATURE_LENGTH,pc_str1,STR_LAENGE_STRING_TABLE);
		sprintf(pc_str, pc_str1,((CString)buffer));
		m_SignatureLength = (CString) pc_str;
		UpdateData(FALSE);

		UpdateSigEditBox();
	}
	else if (SignatureType == RSA_OR_DSA_SIGN)
	{
		//
		CheckRadioButton (IDC_RADIO1, IDC_RADIO4, IDC_RADIO1); UpdateData(TRUE);
		base = -1; // Signatur als Octets darstellen

		srcSize = (Signatur.signature.nbits+7)/8;
		destSize = ((srcSize+hexdumpCols-1)/hexdumpCols)*(11+hexdumpCols*4)-hexdumpCols+(srcSize%hexdumpCols)+1;

		char *sigdata = (char *) malloc(destSize+1);

		err = HexDumpMem(sigdata, destSize, (unsigned char *) Signatur.signature.bits, srcSize, hexdumpCols);
		if (err == 0)
		{
			// Fehler
			if (Signatur.signature.bits) free(Signatur.signature.bits);
			if (message.octets) free(message.octets);
			return TRUE;
		}
		m_Signature = (CString) sigdata; UpdateData(FALSE);
		free(sigdata);
		
		char buffer[30];
		_itoa( Signatur.signature.nbits, buffer, 10 );
		LoadString(AfxGetInstanceHandle(),IDS_STRING_SIGNATURE_LENGTH,pc_str1,STR_LAENGE_STRING_TABLE);
		sprintf(pc_str, pc_str1,((CString)buffer));
		m_SignatureLength = (CString) pc_str;
		UpdateData(FALSE);
	}
	else // (SignatureType == UNKNOWN_SIGN)
	{
		// unbekanntes Signaturverfahren angegeben
		m_RadioOctets.EnableWindow(FALSE);
		m_RadioOktal.EnableWindow(FALSE);
		m_RadioDezimal.EnableWindow(FALSE);
		m_RadioHexadezimal.EnableWindow(FALSE);
	}
#endif

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX-Eigenschaftenseiten sollten FALSE zurückgeben
}
Example #15
0
static void init_dialog(HWND hwnd, int num)
{
    int drive_type, drive_extend_image_policy, drive_idle_method, n;
    int drive_true_emulation, iecdevice, enabled;
    int xpos;
    int xstart;
    HWND temp_hwnd;
    HWND parent_hwnd;
    HWND element;

    parent_hwnd = GetParent(hwnd);

    /* translate all dialog items */
    uilib_localize_dialog(hwnd, drive_dialog_trans);

    /* translate the parent window items */
    uilib_localize_dialog(parent_hwnd, parent_dialog_trans);

    /* translate the generic items */
    for (n = 0; generic_items[n].text != NULL; n++) {
        element = GetDlgItem(hwnd, generic_items[n].idm);
        SetWindowText(element, generic_items[n].text);
    }

    /* adjust the size of the elements in the main group */
    uilib_adjust_group_width(hwnd, drive_main_group);

    /* get the max x of the elements in the left group */
    uilib_get_group_max_x(hwnd, drive_left_group, &xpos);

    /* get the min x of the none element of the left group */
    uilib_get_element_min_x(hwnd, IDC_SELECT_DRIVE_TYPE_NONE, &xstart);

    /* resize and move the left group element to the correct position */
    uilib_move_and_set_element_width(hwnd, IDC_DRIVE_TYPE, xstart - 10, xpos - xstart + 20);

    /* get the max x of the left group element */
    uilib_get_element_max_x(hwnd, IDC_DRIVE_TYPE, &xpos);
    
    /* move the middle group elements to the correct position */
    uilib_move_group(hwnd, drive_middle_move_group, xpos + 20);
    uilib_move_element(hwnd, IDC_40_TRACK_HANDLING, xpos + 10);
    uilib_move_element(hwnd, IDC_DRIVE_EXPANSION, xpos + 10);

    xstart = xpos + 20;

    /* get the max x of the middle group */
    uilib_get_group_max_x(hwnd, drive_middle_group, &xpos);
    
    /* resize and move the middle group boxes to the correct position */
    uilib_move_and_set_element_width(hwnd, IDC_40_TRACK_HANDLING, xstart - 10, xpos - xstart + 20);
    uilib_move_and_set_element_width(hwnd, IDC_DRIVE_EXPANSION, xstart - 10, xpos - xstart + 20);

    /* get the max x of the middle group element */
    uilib_get_element_max_x(hwnd, IDC_DRIVE_EXPANSION, &xpos);

    /* move the right group elements to the correct position */
    uilib_move_group(hwnd, drive_right_move_group, xpos + 20);
    uilib_move_element(hwnd, IDC_IDLE_METHOD, xpos + 10);

    xstart = xpos + 20;

    /* get the max x of the right group */
    uilib_get_group_max_x(hwnd, drive_right_group, &xpos);

    /* resize and move the right group element to the correct position */
    uilib_move_and_set_element_width(hwnd, IDC_IDLE_METHOD, xstart - 10, xpos - xstart + 20);

    /* get the max x of the drive parallel cable label element */
    uilib_get_element_max_x(hwnd, IDC_DRIVE_PARALLEL_CABLE_LABEL, &xpos);

    /* move the drive parallel cable element to the right position */
    uilib_move_element(hwnd, IDC_DRIVE_PARALLEL_CABLE, xpos + 10);

    /* recenter the buttons in the newly resized dialog window */
    uilib_center_buttons(parent_hwnd, move_buttons_group, 0);

    resources_get_int_sprintf("IECDevice%i", &iecdevice, num);
    resources_get_int("DriveTrueEmulation", &drive_true_emulation);
    enabled = drive_true_emulation && !iecdevice;

    EnableWindow(GetDlgItem(hwnd, IDC_SELECT_DRIVE_TYPE_1541), enabled && drive_check_type(DRIVE_TYPE_1541, num - 8));
    EnableWindow(GetDlgItem(hwnd, IDC_SELECT_DRIVE_TYPE_1541II), enabled && drive_check_type(DRIVE_TYPE_1541II, num - 8));
    EnableWindow(GetDlgItem(hwnd, IDC_SELECT_DRIVE_TYPE_1570), enabled && drive_check_type(DRIVE_TYPE_1570, num - 8));
    EnableWindow(GetDlgItem(hwnd, IDC_SELECT_DRIVE_TYPE_1571), enabled && drive_check_type(DRIVE_TYPE_1571, num - 8));
    EnableWindow(GetDlgItem(hwnd, IDC_SELECT_DRIVE_TYPE_1581), enabled && drive_check_type(DRIVE_TYPE_1581, num - 8));
    EnableWindow(GetDlgItem(hwnd, IDC_SELECT_DRIVE_TYPE_2000), enabled && drive_check_type(DRIVE_TYPE_2000, num - 8));
    EnableWindow(GetDlgItem(hwnd, IDC_SELECT_DRIVE_TYPE_4000), enabled && drive_check_type(DRIVE_TYPE_4000, num - 8));
    EnableWindow(GetDlgItem(hwnd, IDC_SELECT_DRIVE_TYPE_2031), enabled && drive_check_type(DRIVE_TYPE_2031, num - 8));
    EnableWindow(GetDlgItem(hwnd, IDC_SELECT_DRIVE_TYPE_2040), enabled && drive_check_type(DRIVE_TYPE_2040, num - 8));
    EnableWindow(GetDlgItem(hwnd, IDC_SELECT_DRIVE_TYPE_3040), enabled && drive_check_type(DRIVE_TYPE_3040, num - 8));
    EnableWindow(GetDlgItem(hwnd, IDC_SELECT_DRIVE_TYPE_4040), enabled && drive_check_type(DRIVE_TYPE_4040, num - 8));
    EnableWindow(GetDlgItem(hwnd, IDC_SELECT_DRIVE_TYPE_1001), enabled && drive_check_type(DRIVE_TYPE_1001, num - 8));
    EnableWindow(GetDlgItem(hwnd, IDC_SELECT_DRIVE_TYPE_8050), enabled && drive_check_type(DRIVE_TYPE_8050, num - 8));
    EnableWindow(GetDlgItem(hwnd, IDC_SELECT_DRIVE_TYPE_8250), enabled && drive_check_type(DRIVE_TYPE_8250, num - 8));
    EnableWindow(GetDlgItem(hwnd, IDC_SELECT_DRIVE_TYPE_NONE), enabled);

    resources_get_int_sprintf("Drive%dType", &drive_type, num);
    resources_get_int_sprintf("Drive%dExtendImagePolicy", &drive_extend_image_policy, num);
    resources_get_int_sprintf("Drive%dIdleMethod", &drive_idle_method, num);

    dialog_drive_type[num - 8] = drive_type;
    switch (drive_type) {
        case DRIVE_TYPE_NONE:
            n = IDC_SELECT_DRIVE_TYPE_NONE;
            break;
        case DRIVE_TYPE_1541:
            n = IDC_SELECT_DRIVE_TYPE_1541;
            break;
        case DRIVE_TYPE_1541II:
            n = IDC_SELECT_DRIVE_TYPE_1541II;
            break;
        case DRIVE_TYPE_1570:
            n = IDC_SELECT_DRIVE_TYPE_1570;
            break;
        case DRIVE_TYPE_1571:
            n = IDC_SELECT_DRIVE_TYPE_1571;
            break;
        case DRIVE_TYPE_1581:
            n = IDC_SELECT_DRIVE_TYPE_1581;
            break;
        case DRIVE_TYPE_2000:
            n = IDC_SELECT_DRIVE_TYPE_2000;
            break;
        case DRIVE_TYPE_4000:
            n = IDC_SELECT_DRIVE_TYPE_4000;
            break;
        case DRIVE_TYPE_2031:
            n = IDC_SELECT_DRIVE_TYPE_2031;
            break;
        case DRIVE_TYPE_2040:
            n = IDC_SELECT_DRIVE_TYPE_2040;
            break;
        case DRIVE_TYPE_3040:
            n = IDC_SELECT_DRIVE_TYPE_3040;
            break;
        case DRIVE_TYPE_4040:
            n = IDC_SELECT_DRIVE_TYPE_4040;
            break;
        case DRIVE_TYPE_1001:
            n = IDC_SELECT_DRIVE_TYPE_1001;
            break;
        case DRIVE_TYPE_8050:
            n = IDC_SELECT_DRIVE_TYPE_8050;
            break;
        case DRIVE_TYPE_8250:
            n = IDC_SELECT_DRIVE_TYPE_8250;
            break;
    }

    if (!enabled) {
        n = IDC_SELECT_DRIVE_TYPE_NONE;
    }

    CheckRadioButton(hwnd, IDC_SELECT_DRIVE_TYPE_1541, IDC_SELECT_DRIVE_TYPE_NONE, n);

    enable_controls_for_drive_settings(hwnd, n);

    dialog_drive_extend[num - 8] = drive_extend_image_policy;
    switch (drive_extend_image_policy) {
        case DRIVE_EXTEND_NEVER:
            n = IDC_SELECT_DRIVE_EXTEND_NEVER;
            break;
        case DRIVE_EXTEND_ASK:
            n = IDC_SELECT_DRIVE_EXTEND_ASK;
            break;
        case DRIVE_EXTEND_ACCESS:
            n = IDC_SELECT_DRIVE_EXTEND_ACCESS;
            break;
    }

    CheckRadioButton(hwnd, IDC_SELECT_DRIVE_EXTEND_NEVER, IDC_SELECT_DRIVE_EXTEND_ACCESS, n);

    dialog_drive_idle[num - 8] = drive_idle_method;
    switch (drive_idle_method) {
        case DRIVE_IDLE_NO_IDLE:
            n = IDC_SELECT_DRIVE_IDLE_NO_IDLE;
            break;
        case DRIVE_IDLE_TRAP_IDLE:
            n = IDC_SELECT_DRIVE_IDLE_TRAP_IDLE;
            break;
        case DRIVE_IDLE_SKIP_CYCLES:
            n = IDC_SELECT_DRIVE_IDLE_SKIP_CYCLES;
            break;
    }

    CheckRadioButton(hwnd, IDC_SELECT_DRIVE_IDLE_NO_IDLE, IDC_SELECT_DRIVE_IDLE_SKIP_CYCLES, n);

    resources_get_int_sprintf("Drive%dParallelCable", &n, num);

    temp_hwnd = GetDlgItem(hwnd, IDC_DRIVE_PARALLEL_CABLE);
    SendMessage(temp_hwnd, CB_ADDSTRING, 0, (LPARAM)translate_text(IDS_NONE));
    SendMessage(temp_hwnd, CB_ADDSTRING, 0, (LPARAM)translate_text(IDS_STANDARD));
    SendMessage(temp_hwnd, CB_ADDSTRING, 0, (LPARAM)"Dolphin DOS 3");
    SendMessage(temp_hwnd, CB_ADDSTRING, 0, (LPARAM)"Formel 64");
    SendMessage(temp_hwnd, CB_SETCURSEL, (WPARAM)n, 0);

    resources_get_int_sprintf("Drive%dRAM2000", &n, num);
    CheckDlgButton(hwnd, IDC_TOGGLE_DRIVE_EXPANSION_2000, n ? BST_CHECKED : BST_UNCHECKED);

    resources_get_int_sprintf("Drive%dRAM4000", &n, num);
    CheckDlgButton(hwnd, IDC_TOGGLE_DRIVE_EXPANSION_4000, n ? BST_CHECKED : BST_UNCHECKED);

    resources_get_int_sprintf("Drive%dRAM6000", &n, num);
    CheckDlgButton(hwnd, IDC_TOGGLE_DRIVE_EXPANSION_6000, n ? BST_CHECKED : BST_UNCHECKED);

    resources_get_int_sprintf("Drive%dRAM8000", &n, num);
    CheckDlgButton(hwnd, IDC_TOGGLE_DRIVE_EXPANSION_8000, n ? BST_CHECKED : BST_UNCHECKED);

    resources_get_int_sprintf("Drive%dRAMA000", &n, num);
    CheckDlgButton(hwnd, IDC_TOGGLE_DRIVE_EXPANSION_A000, n ? BST_CHECKED : BST_UNCHECKED);
}
Example #16
0
INT_PTR CRecreateDlg::OnInitDialog(HWND hDlg, UINT messg, WPARAM wParam, LPARAM lParam)
{
	LRESULT lbRc = FALSE;

	gpConEmu->OnOurDialogOpened();

	CDynDialog::LocalizeDialog(hDlg);

	// Visual
	SendMessage(hDlg, WM_SETICON, ICON_BIG, (LPARAM)hClassIcon);
	SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)hClassIconSm);

	// Set password style (avoid "bars" on some OS)
	SendDlgItemMessage(hDlg, tRunAsPassword, WM_SETFONT, (LPARAM)(HFONT)GetStockObject(DEFAULT_GUI_FONT), 0);

	// Add menu items
	HMENU hSysMenu = GetSystemMenu(hDlg, FALSE);
	InsertMenu(hSysMenu, 0, MF_BYPOSITION | MF_SEPARATOR, 0, 0);
	InsertMenu(hSysMenu, 0, MF_BYPOSITION | MF_STRING | MF_ENABLED,
				ID_RESETCMDHISTORY, L"Clear history...");
	InsertMenu(hSysMenu, 0, MF_BYPOSITION | MF_STRING | MF_ENABLED
				| (gpSet->isSaveCmdHistory ? MF_CHECKED : 0),
				ID_STORECMDHISTORY, L"Store history");

	//#ifdef _DEBUG
	//SetWindowPos(ghOpWnd, HWND_NOTOPMOST, 0,0,0,0, SWP_NOSIZE|SWP_NOMOVE);
	//#endif

	RConStartArgsEx* pArgs = mp_Args;
	_ASSERTE(pArgs);

	// Fill command and task drop down
	SendMessage(hDlg, UM_FILL_CMDLIST, TRUE, 0);

	// Set text in command and folder fields
	{
	LPCWSTR pszSetCmd = mpsz_DefCmd ? mpsz_DefCmd : pArgs->pszSpecialCmd ? pArgs->pszSpecialCmd : L"";
	CEStr lsTempCmd, lsAppend;
	if (!mpsz_DefCmd && pArgs)
	{
		RConStartArgsEx tempArgs;
		tempArgs.AssignFrom(pArgs);
		tempArgs.CleanSecure();
		tempArgs.RunAsSystem = pArgs->RunAsSystem;
		tempArgs.eSplit = RConStartArgsEx::eSplitNone;
		SafeFree(tempArgs.pszSpecialCmd);
		SafeFree(tempArgs.pszStartupDir);
		tempArgs.NewConsole = pArgs->NewConsole;
		lsAppend = tempArgs.CreateCommandLine();
		if (!lsAppend.IsEmpty())
		{
			lsTempCmd = lstrmerge(pszSetCmd, ((lsAppend[0] == L' ') ? NULL : L" "), lsAppend);
			pszSetCmd = lsTempCmd.ms_Val;
		}
	}
	SetDlgItemText(hDlg, IDC_RESTART_CMD, pszSetCmd);
	// TODO: gh-959: enable autocorrection of cbRunAsAdmin by IDC_RESTART_CMD task contents (first line)
	}

	// "%CD%" was specified as startup dir? In Task parameters for example...
	CEStr lsStartDir;
	if (pArgs->pszStartupDir
		&& (lstrcmpi(pArgs->pszStartupDir, L"%CD%") == 0))
	{
		lsStartDir.Set(ms_RConCurDir);
	}
	// Suggest default ConEmu working directory otherwise (unless it's a cra_RecreateTab)
	if (lsStartDir.IsEmpty())
	{
		lsStartDir.Set(gpConEmu->WorkDir());
	}

	// Current directory, startup directory, ConEmu startup directory, and may be startup directory history in the future
	AddDirectoryList(mpsz_DefDir ? mpsz_DefDir : lsStartDir.ms_Val);
	AddDirectoryList(ms_RConCurDir);
	AddDirectoryList(ms_RConStartDir);
	AddDirectoryList(gpConEmu->WorkDir());
	LPCWSTR pszShowDir;
	if ((pArgs->aRecreate == cra_RecreateTab) && !ms_RConCurDir.IsEmpty())
		pszShowDir = ms_RConCurDir;
	else
		pszShowDir = mpsz_DefDir ? mpsz_DefDir : lsStartDir.ms_Val;
	SetDlgItemText(hDlg, IDC_STARTUP_DIR, pszShowDir);

	// Split controls
	if (pArgs->aRecreate == cra_RecreateTab)
	{
		// Hide Split's
		ShowWindow(GetDlgItem(hDlg, gbRecreateSplit), SW_HIDE);
		ShowWindow(GetDlgItem(hDlg, rbRecreateSplitNone), SW_HIDE);
		ShowWindow(GetDlgItem(hDlg, rbRecreateSplit2Right), SW_HIDE);
		ShowWindow(GetDlgItem(hDlg, rbRecreateSplit2Bottom), SW_HIDE);
		ShowWindow(GetDlgItem(hDlg, stRecreateSplit), SW_HIDE);
		ShowWindow(GetDlgItem(hDlg, tRecreateSplit), SW_HIDE);
	}
	else
	{
		// Fill splits
		SetDlgItemInt(hDlg, tRecreateSplit, (1000-pArgs->nSplitValue)/10, FALSE);
		CheckRadioButton(hDlg, rbRecreateSplitNone, rbRecreateSplit2Bottom, rbRecreateSplitNone+pArgs->eSplit);
		EnableWindow(GetDlgItem(hDlg, tRecreateSplit), (pArgs->eSplit != pArgs->eSplitNone));
		EnableWindow(GetDlgItem(hDlg, stRecreateSplit), (pArgs->eSplit != pArgs->eSplitNone));
	}

	// Спрятать флажок "New window"
	bool bRunInNewWindow_Hidden = (pArgs->aRecreate == cra_EditTab || pArgs->aRecreate == cra_RecreateTab);
	ShowWindow(GetDlgItem(hDlg, cbRunInNewWindow), bRunInNewWindow_Hidden ? SW_HIDE : SW_SHOWNORMAL);


	const wchar_t *pszUser = pArgs->pszUserName;
	const wchar_t *pszDomain = pArgs->pszDomain;
	bool bResticted = (pArgs->RunAsRestricted == crb_On);
	int nChecked = rbCurrentUser;
	int nNetOnly = cbRunAsNetOnly;
	DWORD nUserNameLen = countof(ms_CurUser);

	if (!GetUserName(ms_CurUser, &nUserNameLen))
		ms_CurUser[0] = 0;

	wchar_t szRbCaption[MAX_PATH*3];
	lstrcpy(szRbCaption, L"Run as current &user: "******"UPN format" остается в pszUser
					lstrcpyn(szOtherUser, pszUser, MAX_PATH);
					wcscat_c(szOtherUser, L"@");
					lstrcpyn(szOtherUser+_tcslen(szOtherUser), pszDomain, MAX_PATH);
				}
				else
				{
					// "Старая" нотация domain\user
					lstrcpyn(szOtherUser, pszDomain, MAX_PATH);
					wcscat_c(szOtherUser, L"\\");
					lstrcpyn(szOtherUser+_tcslen(szOtherUser), pszUser, MAX_PATH);
				}
			}
			else
			{
				lstrcpyn(szOtherUser, pszUser, countof(szOtherUser));
			}

			SetDlgItemText(hDlg, tRunAsPassword, pArgs->szUserPassword);
			EnableWindow(GetDlgItem(hDlg, cbRunAsNetOnly), TRUE);
		}
	}

	SetDlgItemText(hDlg, tRunAsUser, (nChecked == rbAnotherUser) ? szOtherUser : L"");
	CheckRadioButton(hDlg, rbCurrentUser, rbAnotherUser, nChecked);
	RecreateDlgProc(hDlg, UM_USER_CONTROLS, 0, 0);

	if (gOSVer.dwMajorVersion < 6)
	{
		// В XP и ниже это просто RunAs - с возможностью ввода имени пользователя и пароля
		//apiShowWindow(GetDlgItem(hDlg, cbRunAsAdmin), SW_HIDE);
		SetDlgItemTextA(hDlg, cbRunAsAdmin, "&Run as..."); //GCC hack. иначе не собирается
		// И уменьшить длину
		RECT rcBox; GetWindowRect(GetDlgItem(hDlg, cbRunAsAdmin), &rcBox);
		SetWindowPos(GetDlgItem(hDlg, cbRunAsAdmin), NULL, 0, 0, (rcBox.right-rcBox.left)/2, rcBox.bottom-rcBox.top,
				        SWP_NOMOVE|SWP_NOZORDER);
	}
	else if (gpConEmu->mb_IsUacAdmin || (pArgs && (pArgs->RunAsAdministrator == crb_On)))
	{
		CheckDlgButton(hDlg, cbRunAsAdmin, BST_CHECKED);

		if (gpConEmu->mb_IsUacAdmin)  // Только в Vista+ если GUI уже запущен под админом
		{
			EnableWindow(GetDlgItem(hDlg, cbRunAsAdmin), FALSE);
		}
		else //if (gOSVer.dwMajorVersion < 6)
		{
			RecreateDlgProc(hDlg, WM_COMMAND, cbRunAsAdmin, 0);
		}
	}

	//}
	SetClassLongPtr(hDlg, GCLP_HICON, (LONG_PTR)hClassIcon);

	if (pArgs->aRecreate == cra_RecreateTab)
	{
		SetWindowText(hDlg, CLngRc::getRsrc(lng_DlgRestartConsole/*"Restart console"*/));
		SendDlgItemMessage(hDlg, IDC_RESTART_ICON, STM_SETICON, (WPARAM)LoadIcon(NULL,IDI_EXCLAMATION), 0);
		lbRc = TRUE;
	}
	else
	{
		SetWindowText(hDlg, CLngRc::getRsrc(lng_DlgCreateNewConsole/*"Create new console"*/));

		// If we disallowed to create "Multiple consoles in one window"
		// - Check & Disable "New window" checkbox
		bool bForceNewWindow = (!gpSetCls->IsMulti() && gpConEmu->isVConExists(0));
		CheckDlgButton(hDlg, cbRunInNewWindow, (pArgs->aRecreate == cra_CreateWindow || bForceNewWindow) ? BST_CHECKED : BST_UNCHECKED);
		EnableWindow(GetDlgItem(hDlg, cbRunInNewWindow), !bForceNewWindow);

		//
		SendDlgItemMessage(hDlg, IDC_RESTART_ICON, STM_SETICON, (WPARAM)LoadIcon(NULL,IDI_QUESTION), 0);
		POINT pt = {0,0};
		MapWindowPoints(GetDlgItem(hDlg, IDC_TERMINATE), hDlg, &pt, 1);
		DestroyWindow(GetDlgItem(hDlg, IDC_TERMINATE));
		SetWindowPos(GetDlgItem(hDlg, IDC_START), NULL, pt.x, pt.y, 0,0, SWP_NOSIZE|SWP_NOZORDER);
		SetDlgItemText(hDlg, IDC_START, (pArgs->aRecreate == cra_EditTab) ? L"&Save" : L"&Start");
		DestroyWindow(GetDlgItem(hDlg, IDC_WARNING));
	}

	// Align "New window" and "Run as administrator" checkboxes
	{
		RECT rcBox = {}; GetWindowRect(GetDlgItem(hDlg, cbRunAsAdmin), &rcBox);
		MapWindowPoints(NULL, hDlg, (LPPOINT)&rcBox, 2);
		const int chk_height = (rcBox.bottom - rcBox.top);

		POINT pt = {rcBox.left};
		if (!bRunInNewWindow_Hidden)
		{
			RECT rcIcoBox = {}; GetWindowRect(GetDlgItem(hDlg, IDC_RESTART_ICON), &rcIcoBox);
			MapWindowPoints(NULL, hDlg, (LPPOINT)&rcIcoBox, 2);
			const int ico_height = (rcIcoBox.bottom - rcIcoBox.top);
			const int h2 = (chk_height * 5) / 2;
			pt.y = rcIcoBox.top + (ico_height - h2)/2;
			SetWindowPos(GetDlgItem(hDlg, cbRunInNewWindow), NULL, pt.x, pt.y, 0,0, SWP_NOSIZE|SWP_NOZORDER);
			pt.y += (h2 - chk_height);
		}
		else
		{
			RECT rcBtnBox = {}; GetWindowRect(GetDlgItem(hDlg, IDC_START), &rcBtnBox);
			MapWindowPoints(NULL, hDlg, (LPPOINT)&rcBtnBox, 2);
			const int btn_height = (rcBtnBox.bottom - rcBtnBox.top);
			pt.y = rcBtnBox.top + (btn_height - chk_height)/2;
		}
		SetWindowPos(GetDlgItem(hDlg, cbRunAsAdmin), NULL, pt.x, pt.y, 0,0, SWP_NOSIZE|SWP_NOZORDER);
	}

	// Dpi aware processing at the end of sequence
	// because we done some manual control reposition
	if (mp_DpiAware)
	{
		mp_DpiAware->Attach(hDlg, ghWnd, CDynDialog::GetDlgClass(hDlg));
	}

	// Ensure, it will be "on screen"
	RECT rect; GetWindowRect(hDlg, &rect);
	RECT rcCenter = CenterInParent(rect, mh_Parent);
	MoveWindow(hDlg, rcCenter.left, rcCenter.top,
			    rect.right - rect.left, rect.bottom - rect.top, false);


	// Была отключена обработка CConEmuMain::OnFocus (лишние телодвижения)
	PostMessage(hDlg, (WM_APP+1), 0,0);


	// Default focus control
	if (pArgs->aRecreate == cra_RecreateTab)
		SetFocus(GetDlgItem(hDlg, IDC_START)); // Win+~ (Recreate tab), Focus on "Restart" button"
	else if ((pArgs->pszUserName && *pArgs->pszUserName) && !*pArgs->szUserPassword)
		SetFocus(GetDlgItem(hDlg, tRunAsPassword)); // We need password, all other fields are ready
	else
		SetFocus(GetDlgItem(hDlg, IDC_RESTART_CMD)); // Set focus in command-line field

	return lbRc;
}
/*
================
DialogAFConstraintSpring::LoadConstraint
================
*/
void DialogAFConstraintSpring::LoadConstraint(idDeclAF_Constraint *c)
{
	int i;

	constraint = c;

	// load first anchor from the current idDeclAF_Constraint
	SetSafeComboBoxSelection(&m_comboAnchorJoint, constraint->anchor.joint1.c_str(), -1);
	m_anchor_x = constraint->anchor.ToVec3().x;
	m_anchor_y = constraint->anchor.ToVec3().y;
	m_anchor_z = constraint->anchor.ToVec3().z;

	if (constraint->anchor.type == idAFVector::VEC_JOINT) {
		i = IDC_RADIO_ANCHOR_JOINT;
	} else {
		i = IDC_RADIO_ANCHOR_COORDINATES;
	}

	CheckRadioButton(IDC_RADIO_ANCHOR_JOINT, IDC_RADIO_ANCHOR_COORDINATES, i);

	// load second anchor from the current idDeclAF_Constraint
	SetSafeComboBoxSelection(&m_comboAnchor2Joint, constraint->anchor2.joint1.c_str(), -1);
	m_anchor2_x = constraint->anchor2.ToVec3().x;
	m_anchor2_y = constraint->anchor2.ToVec3().y;
	m_anchor2_z = constraint->anchor2.ToVec3().z;

	if (constraint->anchor2.type == idAFVector::VEC_JOINT) {
		i = IDC_RADIO_ANCHOR2_JOINT;
	} else {
		i = IDC_RADIO_ANCHOR2_COORDINATES;
	}

	CheckRadioButton(IDC_RADIO_ANCHOR2_JOINT, IDC_RADIO_ANCHOR2_COORDINATES, i);

	// spring settings
	m_stretch = constraint->stretch;
	m_compress = constraint->compress;
	m_damping = constraint->damping;
	m_restLength = constraint->restLength;

	// spring limits
	if (constraint->minLength > 0.0f) {
		i = IDC_RADIO_SPRING_MIN_LENGTH;
	} else {
		i = IDC_RADIO_SPRING_NO_MIN_LENGTH;
	}

	CheckRadioButton(IDC_RADIO_SPRING_NO_MIN_LENGTH, IDC_RADIO_SPRING_MIN_LENGTH, i);
	m_minLength = constraint->minLength;

	if (constraint->maxLength > 0.0f) {
		i = IDC_RADIO_SPRING_MAX_LENGTH;
	} else {
		i = IDC_RADIO_SPRING_NO_MAX_LENGTH;
	}

	CheckRadioButton(IDC_RADIO_SPRING_NO_MAX_LENGTH, IDC_RADIO_SPRING_MAX_LENGTH, i);
	m_maxLength = constraint->maxLength;

	// update displayed values
	UpdateData(FALSE);
}
Example #18
0
INT_PTR CRecreateDlg::OnButtonClicked(HWND hDlg, UINT messg, WPARAM wParam, LPARAM lParam)
{
	switch (LOWORD(wParam))
	{
	case IDC_CHOOSE:
	{
		wchar_t *pszFilePath = SelectFile(L"Choose program to run", NULL, NULL, hDlg, L"Executables (*.exe)\0*.exe\0All files (*.*)\0*.*\0\0", sff_AutoQuote);
		if (pszFilePath)
		{
			SetDlgItemText(hDlg, IDC_RESTART_CMD, pszFilePath);
			SafeFree(pszFilePath);
		}
		return TRUE;
	} // case IDC_CHOOSE:

	case IDC_CHOOSE_DIR:
	{
		wchar_t* pszDefFolder = GetDlgItemTextPtr(hDlg, IDC_STARTUP_DIR);
		wchar_t* pszFolder = SelectFolder(L"Choose startup directory", pszDefFolder, hDlg, sff_Default);
		if (pszFolder)
		{
			SetDlgItemText(hDlg, IDC_STARTUP_DIR, pszFolder);
			SafeFree(pszFolder);
		}
		SafeFree(pszDefFolder);
		return TRUE;
	} // case IDC_CHOOSE_DIR:

	case cbRunAsAdmin:
	{
		// BCM_SETSHIELD = 5644
		BOOL bRunAs = SendDlgItemMessage(hDlg, cbRunAsAdmin, BM_GETCHECK, 0, 0);

		if (gOSVer.dwMajorVersion >= 6)
		{
			SendDlgItemMessage(hDlg, IDC_START, 5644/*BCM_SETSHIELD*/, 0, bRunAs && (mp_Args->aRecreate != cra_EditTab));
		}

		if (bRunAs)
		{
			CheckRadioButton(hDlg, rbCurrentUser, rbAnotherUser, rbCurrentUser);
			CheckDlgButton(hDlg, cbRunAsRestricted, BST_UNCHECKED);
			RecreateDlgProc(hDlg, UM_USER_CONTROLS, 0, 0);
		}

		return TRUE;
	} // case cbRunAsAdmin:

	case rbCurrentUser:
	case rbAnotherUser:
	case cbRunAsNetOnly:
	case cbRunAsRestricted:
	{
		RecreateDlgProc(hDlg, UM_USER_CONTROLS, LOWORD(wParam), 0);
		return TRUE;
	}

	case rbRecreateSplitNone:
	case rbRecreateSplit2Right:
	case rbRecreateSplit2Bottom:
	{
		RConStartArgsEx* pArgs = mp_Args;
		switch (LOWORD(wParam))
		{
		case rbRecreateSplitNone:
			pArgs->eSplit = RConStartArgsEx::eSplitNone; break;
		case rbRecreateSplit2Right:
			pArgs->eSplit = RConStartArgsEx::eSplitHorz; break;
		case rbRecreateSplit2Bottom:
			pArgs->eSplit = RConStartArgsEx::eSplitVert; break;
		}
		EnableWindow(GetDlgItem(hDlg, tRecreateSplit), (pArgs->eSplit != pArgs->eSplitNone));
		EnableWindow(GetDlgItem(hDlg, stRecreateSplit), (pArgs->eSplit != pArgs->eSplitNone));
		if (pArgs->eSplit != pArgs->eSplitNone)
			SetFocus(GetDlgItem(hDlg, tRecreateSplit));
		return TRUE;
	} // case rbRecreateSplitXXX

	case IDC_START:
	{
		RConStartArgsEx* pArgs = mp_Args;
		_ASSERTE(pArgs);
		SafeFree(pArgs->pszUserName);
		SafeFree(pArgs->pszDomain);

		//SafeFree(pArgs->pszUserPassword);
		if (SendDlgItemMessage(hDlg, rbAnotherUser, BM_GETCHECK, 0, 0))
		{
			pArgs->RunAsRestricted = crb_Off;
			pArgs->pszUserName = GetDlgItemTextPtr(hDlg, tRunAsUser);
			pArgs->RunAsNetOnly = SendDlgItemMessage(hDlg, cbRunAsNetOnly, BM_GETCHECK, 0, 0) ? crb_On : crb_Off;

			if (pArgs->pszUserName)
			{
				//pArgs->pszUserPassword = GetDlgItemText(hDlg, tRunAsPassword);
				// Попытаться проверить правильность введенного пароля и возможность запуска
				bool bCheckPwd = pArgs->CheckUserToken(GetDlgItem(hDlg, tRunAsPassword));
				DWORD nErr = bCheckPwd ? 0 : GetLastError();
				if (!bCheckPwd)
				{
					DisplayLastError(L"Invalid user name or password was specified!", nErr, MB_ICONSTOP, NULL, hDlg);
					return 1;
				}
			}
		}
		else
		{
			pArgs->RunAsRestricted = SendDlgItemMessage(hDlg, cbRunAsRestricted, BM_GETCHECK, 0, 0) ? crb_On : crb_Off;
			pArgs->RunAsNetOnly = crb_Off;
		}

		// Vista+ (As Admin...)
		pArgs->RunAsAdministrator = SendDlgItemMessage(hDlg, cbRunAsAdmin, BM_GETCHECK, 0, 0) ? crb_On : crb_Off;

		// StartupDir (may be specified as argument)
		wchar_t* pszDir = GetDlgItemTextPtr(hDlg, IDC_STARTUP_DIR);
		wchar_t* pszExpand = (pszDir && wcschr(pszDir, L'%')) ? ExpandEnvStr(pszDir) : NULL;
		LPCWSTR pszDirResult = pszExpand ? pszExpand : pszDir;
		// Another user? We may fail with access denied. Check only for "current user" account
		if (!pArgs->pszUserName && pszDirResult && *pszDirResult && !DirectoryExists(pszDirResult))
		{
			wchar_t* pszErrInfo = lstrmerge(L"Specified directory does not exists!\n", pszDirResult, L"\n" L"Do you want to choose another directory?\n\n");
			DWORD nErr = GetLastError();
			int iDirBtn = DisplayLastError(pszErrInfo, nErr, MB_ICONEXCLAMATION|MB_YESNO, NULL, hDlg);
			if (iDirBtn == IDYES)
			{
				SafeFree(pszDir);
				SafeFree(pszExpand);
				SafeFree(pszErrInfo);
				return 1;
			}
			// User want to run "as is". Most likely it will fail, but who knows...
		}
		SafeFree(pArgs->pszStartupDir);
		pArgs->pszStartupDir = pszExpand ? pszExpand : pszDir;
		if (pszExpand)
		{
			SafeFree(pszDir)
		}

		// Command
		// pszSpecialCmd мог быть передан аргументом - умолчание для строки ввода
		SafeFree(pArgs->pszSpecialCmd);

		// GetDlgItemText выделяет память через calloc
		pArgs->pszSpecialCmd = GetDlgItemTextPtr(hDlg, IDC_RESTART_CMD);

		if (pArgs->pszSpecialCmd)
			gpSet->HistoryAdd(pArgs->pszSpecialCmd);

		// Especially to reset properly RunAsSystem in active console
		pArgs->ProcessNewConArg();
		if (pArgs->RunAsSystem == crb_Undefined)
			pArgs->RunAsSystem = crb_Off;

		if ((pArgs->aRecreate != cra_RecreateTab) && (pArgs->aRecreate != cra_EditTab))
		{
			if (SendDlgItemMessage(hDlg, cbRunInNewWindow, BM_GETCHECK, 0, 0))
				pArgs->aRecreate = cra_CreateWindow;
			else
				pArgs->aRecreate = cra_CreateTab;
		}
		if (((pArgs->aRecreate == cra_CreateTab) || (pArgs->aRecreate == cra_EditTab))
			&& (pArgs->eSplit != RConStartArgsEx::eSplitNone))
		{
			BOOL bOk = FALSE;
			int nPercent = GetDlgItemInt(hDlg, tRecreateSplit, &bOk, FALSE);
			if (bOk && (nPercent >= 1) && (nPercent <= 99))
			{
				pArgs->nSplitValue = (100-nPercent) * 10;
			}
			//pArgs->nSplitPane = 0; Сбрасывать не будем?
		}
		mn_DlgRc = IDC_START;
		EndDialog(hDlg, IDC_START);
		return TRUE;
	} // case IDC_START:

	case IDC_TERMINATE:
		mn_DlgRc = IDC_TERMINATE;
		EndDialog(hDlg, IDC_TERMINATE);
		return TRUE;

	case IDCANCEL:
		mn_DlgRc = IDCANCEL;
		EndDialog(hDlg, IDCANCEL);
		return TRUE;
	}

	return FALSE;
}
BOOL COptionsDialog::OnInitDialog() 
{
	CDialog::OnInitDialog();

	CGeneralManager * m = ((CReportAsistentApp *) AfxGetApp())->m_pGeneralManager;
	CReportAsistentApp * App = ((CReportAsistentApp *) AfxGetApp());

	//Set Language radio buttons
	if (m->getLanguage() == CString("cz"))
		CheckRadioButton(IDC_CZECH_RADIO, IDC_ENGLISH_RADIO, IDC_CZECH_RADIO);
	else
		CheckRadioButton(IDC_CZECH_RADIO, IDC_ENGLISH_RADIO, IDC_ENGLISH_RADIO);
		
	//Set Tree Items
	//Height edit
	CString Pom;
	Pom.Format("%d",App->m_iTreeItemHeight);
	m_HeightEdit.SetWindowText(Pom);
	m_HeightEdit.SetLimitText(2);

	//Indent Edit
	Pom.Format("%d",App->m_iTreeItemIndent);
	m_IndentEdit.SetWindowText(Pom);
	m_IndentEdit.SetLimitText(2);

	m_LinesCheckBox.SetCheck( App->m_bTreeHasLines);
	m_IdInTreeCheckBox.SetCheck( App->m_bIdInItemName);
	m_ButtonsCheckBox.SetCheck( App->m_bTreeHasButtons);

	//Name Length Edit
	Pom.Format("%d",App->m_iTreeItemNameLength);
	m_NameLengthEdit.SetWindowText(Pom);
	m_NameLengthEdit.SetLimitText(3);

	// Size of text in TextEdit in Text Element dialog
	Pom.Format("%d",App->m_iTextEditSize);
	m_TextEditSize.SetWindowText(Pom);
	m_TextEditSize.SetLimitText(3);

	//Set orphans radio buttons:
	CString OrphSol = App->FirstDocumentInFirstTemplate()->GetReportSettings("orphans_solution");
	if (OrphSol== CString("ignore"))
			CheckRadioButton( IDC_IGNORE_RADIO , IDC_SET_DEFAULT_RADIO, IDC_IGNORE_RADIO );
	else		
		if (OrphSol== CString("delete"))
			CheckRadioButton( IDC_IGNORE_RADIO , IDC_SET_DEFAULT_RADIO, IDC_DELETE_RADIO );
		else
			if (OrphSol== CString("set_default"))
				CheckRadioButton( IDC_IGNORE_RADIO , IDC_SET_DEFAULT_RADIO, IDC_SET_DEFAULT_RADIO );
			else
			{
				CheckRadioButton( IDC_IGNORE_RADIO , IDC_SET_DEFAULT_RADIO, IDC_IGNORE_RADIO );
				App->FirstDocumentInFirstTemplate()->SetReportSettings("orphans_solution","ignore");
			}
	//set mark orphans
	m_MarkOrphansCheckBox.SetCheck( App->m_bMarkOrphans);


	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Example #20
0
VOID
SetProcessFields(
    PSYSTEM_PROCESS_INFORMATION ProcessInfo,
    HWND hwnd
    )
{

    TIME_FIELDS UserTime;
    TIME_FIELDS KernelTime;
    TIME_FIELDS RunTime;
    LARGE_INTEGER Time;
    CHAR TimeString[15];
    CHAR szTempField[MAXTASKNAMELEN];
    CHAR szTemp[80];
    HANDLE hProcess;
    HWND ThreadList,ProcessList;
    int i, nIndex;
    PSYSTEM_THREAD_INFORMATION ThreadInfo;
    PCHAR p;
    ANSI_STRING pname;

    pname.Buffer = NULL;
    hProcess = OpenProcess(PROCESS_ALL_ACCESS,FALSE,(DWORD)ProcessInfo->UniqueProcessId);

    //
    // Set process name and process id
    //

    if ( ProcessInfo->ImageName.Buffer ) {
        RtlUnicodeStringToAnsiString(&pname,(PUNICODE_STRING)&ProcessInfo->ImageName,TRUE);
        p = strrchr(pname.Buffer,'\\');
        if ( p ) {
            p++;
            }
        else {
            p = pname.Buffer;
            }
        }
    else {
        p = "System Process";
        }
    SetDlgItemText(
        hwnd,
        PXPLODE_IMAGENAME,
        p
        );

    SetDlgItemInt(
        hwnd,
        PXPLODE_PROCESS_ID,
        (int)ProcessInfo->UniqueProcessId,
        FALSE
        );

    if ( pname.Buffer ) {
        RtlFreeAnsiString(&pname);
        }

    //
    // Set process priority
    //

    if ( ProcessInfo->BasePriority < 7 ) {
        CheckRadioButton(hwnd,PXPLODE_PRIORITY_IDL,PXPLODE_PRIORITY_HIGH,PXPLODE_PRIORITY_IDL);
        }
    else if ( ProcessInfo->BasePriority < 10 ) {
        CheckRadioButton(hwnd,PXPLODE_PRIORITY_IDL,PXPLODE_PRIORITY_HIGH,PXPLODE_PRIORITY_NORMAL);
        }
    else {
        CheckRadioButton(hwnd,PXPLODE_PRIORITY_IDL,PXPLODE_PRIORITY_HIGH,PXPLODE_PRIORITY_HIGH);
        }

    //
    // Compute address space utilization
    //

    ComputeVaSpace(hwnd,hProcess);

    //
    // Compute runtimes
    //

    RtlTimeToTimeFields ( &ProcessInfo->UserTime, &UserTime);
    RtlTimeToTimeFields ( &ProcessInfo->KernelTime, &KernelTime);

    RtlTimeToTimeFields ( &ProcessInfo->UserTime, &UserTime);
    RtlTimeToTimeFields ( &ProcessInfo->KernelTime, &KernelTime);
    Time.QuadPart = RefreshTimeOfDayInfo.CurrentTime.QuadPart - ProcessInfo->CreateTime.QuadPart;
    RtlTimeToTimeFields ( &Time, &RunTime);
    wsprintf(TimeString,"%3ld:%02ld:%02ld.%03ld",
                RunTime.Hour,
                RunTime.Minute,
                RunTime.Second,
                RunTime.Milliseconds
                );
    SetDlgItemText(
        hwnd,
        PXPLODE_ELAPSED_TIME,
        TimeString
        );

    wsprintf(TimeString,"%3ld:%02ld:%02ld.%03ld",
                UserTime.Hour,
                UserTime.Minute,
                UserTime.Second,
                UserTime.Milliseconds
                );
    SetDlgItemText(
        hwnd,
        PXPLODE_USER_TIME,
        TimeString
        );

    wsprintf(TimeString,"%3ld:%02ld:%02ld.%03ld",
                KernelTime.Hour,
                KernelTime.Minute,
                KernelTime.Second,
                KernelTime.Milliseconds
                );
    SetDlgItemText(
        hwnd,
        PXPLODE_KERNEL_TIME,
        TimeString
        );

    //
    // Set I/O Counts
    //
#if 0
    SetDlgItemInt(
        hwnd,
        PXPLODE_READ_XFER,
        ProcessInfo->ReadTransferCount.LowPart,
        FALSE
        );
    SetDlgItemInt(
        hwnd,
        PXPLODE_WRITE_XFER,
        ProcessInfo->WriteTransferCount.LowPart,
        FALSE
        );
    SetDlgItemInt(
        hwnd,
        PXPLODE_OTHER_XFER,
        ProcessInfo->OtherTransferCount.LowPart,
        FALSE
        );
    SetDlgItemInt(
        hwnd,
        PXPLODE_READ_OPS,
        ProcessInfo->ReadOperationCount,
        FALSE
        );
    SetDlgItemInt(
        hwnd,
        PXPLODE_WRITE_OPS,
        ProcessInfo->WriteOperationCount,
        FALSE
        );
    SetDlgItemInt(
        hwnd,
        PXPLODE_OTHER_OPS,
        ProcessInfo->OtherOperationCount,
        FALSE
        );
#endif
    //
    // Set memory management stats
    //

    wsprintf(szTemp,"%d Kb",ProcessInfo->PeakVirtualSize/1024);
    SetDlgItemText(
        hwnd,
        PXPLODE_PEAK_VSIZE,
        szTemp
        );
    wsprintf(szTemp,"%d Kb",ProcessInfo->VirtualSize/1024);
    SetDlgItemText(
        hwnd,
        PXPLODE_VSIZE,
        szTemp
        );

    SetDlgItemInt(
        hwnd,
        PXPLODE_PFCOUNT,
        ProcessInfo->PageFaultCount,
        FALSE
        );

    wsprintf(szTemp,"%d Kb",(ProcessInfo->PeakWorkingSetSize)/1024);
    SetDlgItemText(
        hwnd,
        PXPLODE_PEAK_WS,
        szTemp
        );

    wsprintf(szTemp,"%d Kb",(ProcessInfo->WorkingSetSize)/1024);
    SetDlgItemText(
        hwnd,
        PXPLODE_WS,
        szTemp
        );
    wsprintf(szTemp,"%d Kb",(ProcessInfo->PeakPagefileUsage)/1024);
    SetDlgItemText(
        hwnd,
        PXPLODE_PEAK_PF,
        szTemp
        );
    wsprintf(szTemp,"%d Kb",(ProcessInfo->PagefileUsage)/1024);
    SetDlgItemText(
        hwnd,
        PXPLODE_PF,
        szTemp
        );
    wsprintf(szTemp,"%d Kb",(ProcessInfo->PrivatePageCount)/1024);
    SetDlgItemText(
        hwnd,
        PXPLODE_PRIVATE_PAGE,
        szTemp
        );
    wsprintf(szTemp,"%d Kb",ProcessInfo->QuotaPeakPagedPoolUsage/1024);
    SetDlgItemText(
        hwnd,
        PXPLODE_PEAK_PAGED,
        szTemp
        );
    wsprintf(szTemp,"%d Kb",ProcessInfo->QuotaPagedPoolUsage/1024);
    SetDlgItemText(
        hwnd,
        PXPLODE_PAGED,
        szTemp
        );
    wsprintf(szTemp,"%d Kb",ProcessInfo->QuotaPeakNonPagedPoolUsage/1024);
    SetDlgItemText(
        hwnd,
        PXPLODE_PEAK_NONPAGED,
        szTemp
        );
    wsprintf(szTemp,"%d Kb",ProcessInfo->QuotaNonPagedPoolUsage/1024);
    SetDlgItemText(
        hwnd,
        PXPLODE_NONPAGED,
        szTemp
        );
    wsprintf(szTemp,"%d Kb",ProcessInfo->QuotaPeakPagedPoolUsage/1024);
    SetDlgItemText(
        hwnd,
        PXPLODE_PEAK_PAGED,
        szTemp
        );

    //
    // Get the usage and limits
    //

    {
        NTSTATUS Status;
        POOLED_USAGE_AND_LIMITS PooledInfo;

            Status = NtQueryInformationProcess(
                        hProcess,
                        ProcessPooledUsageAndLimits,
                        &PooledInfo,
                        sizeof(PooledInfo),
                        NULL
                        );
            if ( !NT_SUCCESS(Status) ) {
                RtlZeroMemory(&PooledInfo,sizeof(PooledInfo));
                }
            //
            // non paged
            //

            wsprintf(szTempField,"%d Kb",
                PooledInfo.PeakNonPagedPoolUsage/1024
                );
            SetDlgItemText(
                hwnd,
                PXPLODE_QNONPEAK,
                szTempField
                );


            wsprintf(szTempField,"%d Kb",
                PooledInfo.NonPagedPoolUsage/1024
                );
            SetDlgItemText(
                hwnd,
                PXPLODE_QNONCUR,
                szTempField
                );

            if (PooledInfo.NonPagedPoolLimit != 0xffffffff ) {
                wsprintf(szTempField,"%d Kb",
                    PooledInfo.NonPagedPoolLimit/1024
                    );
                }
            else {
                strcpy(szTempField,"Unlimited");
                }
            SetDlgItemText(
                hwnd,
                PXPLODE_QNONLIM,
                szTempField
                );


            //
            // paged
            //

            wsprintf(szTempField,"%d Kb",
                PooledInfo.PeakPagedPoolUsage/1024
                );
            SetDlgItemText(
                hwnd,
                PXPLODE_QPGPEAK,
                szTempField
                );

            wsprintf(szTempField,"%d Kb",
                PooledInfo.PagedPoolUsage/1024
                );
            SetDlgItemText(
                hwnd,
                PXPLODE_QPGCUR,
                szTempField
                );

            if (PooledInfo.PagedPoolLimit != 0xffffffff) {
                wsprintf(szTempField,"%d Kb",
                    PooledInfo.PagedPoolLimit/1024
                    );
                }
            else {
                strcpy(szTempField,"Unlimited");
                }
            SetDlgItemText(
                hwnd,
                PXPLODE_QPGLIM,
                szTempField
                );

            //
            // page file
            //

            wsprintf(szTempField,"%d Kb",
                PooledInfo.PeakPagefileUsage*4
                );
            SetDlgItemText(
                hwnd,
                PXPLODE_QPFPEAK,
                szTempField
                );

            wsprintf(szTempField,"%d Kb",
                PooledInfo.PagefileUsage*4
                );
            SetDlgItemText(
                hwnd,
                PXPLODE_QPFCUR,
                szTempField
                );

            if (PooledInfo.PagefileLimit != 0xffffffff) {
                wsprintf(szTempField,"%d Kb",
                    PooledInfo.PagefileLimit*4
                    );
                }
            else {
                strcpy(szTempField,"Unlimited");
                }
            SetDlgItemText(
                hwnd,
                PXPLODE_QPFLIM,
                szTempField
                );
    }
    //
    // Locate the thread list box
    // and clear it
    //

    i = 0;
    ThreadList = GetDlgItem(hwnd, PXPLODE_THREAD_LIST);

//    SendMessage(ThreadList, WM_SETREDRAW, FALSE, 0);
    SendMessage(ThreadList, LB_RESETCONTENT, 0, 0);
    SendMessage(ThreadList, LB_SETITEMDATA, 0L, 0L);

    ThreadInfo = (PSYSTEM_THREAD_INFORMATION)(ProcessInfo + 1);
    while (i < (int)ProcessInfo->NumberOfThreads) {

        wsprintf(szTempField,"%d",
            ThreadInfo->ClientId.UniqueThread
            );

        nIndex = (int)SendMessage(
                        ThreadList,
                        LB_ADDSTRING,
                        0,
                        (DWORD)(LPSTR)szTempField
                        );
        SendMessage(
            ThreadList,
            LB_SETITEMDATA,
            nIndex,
            (DWORD)ThreadInfo
            );

        if ( i == 0 ) {
            SetThreadFields(ThreadInfo,hwnd);
            }
        ThreadInfo += 1;
        i += 1;
        }
    SendMessage(ThreadList, LB_SETCURSEL, 0, 0);

    SetDlgItemInt(
        hwnd,
        PXPLODE_THREAD_COUNT,
        ProcessInfo->NumberOfThreads,
        FALSE
        );

    // Redraw the list now that all items have been inserted.

//    SendMessage(ThreadList, WM_SETREDRAW, TRUE, 0);
//    InvalidateRect(ThreadList, NULL, TRUE);

    ProcessList = GetDlgItem(hwnd, PXPLODE_PROCESS_LIST);
    SetFocus(ProcessList);
    if ( hProcess ) {
        CloseHandle(hProcess);
        }

    //
    // If we can't get at the process (maybe it's process 0?)
    // then don't let people try and edit the security on it or it's token.
    //

    hProcess = OpenProcess(MAXIMUM_ALLOWED,FALSE,(DWORD)ProcessInfo->UniqueProcessId);
    EnableWindow(GetDlgItem(hwnd, PXPLODE_PROCESS_ACL), hProcess != NULL);
    EnableWindow(GetDlgItem(hwnd, PXPLODE_PROCESS_TOKEN), hProcess != NULL);
    EnableWindow(GetDlgItem(hwnd, PXPLODE_PROCESS_TOKEN_ACL), hProcess != NULL);
    if (hProcess) {
        CloseHandle(hProcess);
    }


}
Example #21
0
BOOL WINAPI
SoundProc(HWND hwndDlg, WORD wMessage, WPARAM wParam, LPARAM lParam)
{
static HWND hSoundWaveDuring, hSoundWaveAfter, hFileText, hSoundEdit, hPlay, hBrowse;
static UINT uMaxSoundRadioButton; /* upper boundary of uSoundButtonSelected   */

   switch (wMessage) {
   case WM_INITDIALOG:
      if (CanPlayWave())
      {
         hSoundWaveDuring = GetDlgItem(hwndDlg, IDM_SOUND_WAVE_DURING);
         hSoundWaveAfter = GetDlgItem(hwndDlg, IDM_SOUND_WAVE_AFTER);
         hFileText = GetDlgItem(hwndDlg, IDM_SOUND_FILE_TEXT);
         hSoundEdit = GetDlgItem(hwndDlg, IDM_SOUND_EDIT);
         hPlay = GetDlgItem(hwndDlg, IDM_SOUND_PLAY);
         hBrowse = GetDlgItem(hwndDlg, IDM_SOUND_BROWSE);
         EnableWindow(hSoundWaveDuring, TRUE);
         EnableWindow(hSoundWaveAfter, TRUE);
         WinAssert(hFileText);
         EnableWindow(hFileText, TRUE);
         EnableWindow(hSoundEdit, TRUE);
         EnableWindow(hPlay, TRUE);
         EnableWindow(hBrowse, TRUE);
         SetDlgItemText(hwndDlg, IDM_SOUND_EDIT, lpumb->szSoundName);
         uMaxSoundRadioButton = IDM_SOUND_WAVE_AFTER;
      }
      else   /* Can't play wave */
      {
         uMaxSoundRadioButton = IDM_SOUND_BEEP;
      }
      uSoundButtonSelectedTmp = uSoundButtonSelected; /* initialize temp value */
      CheckRadioButton(hwndDlg, IDM_SOUND_NONE, uMaxSoundRadioButton, uSoundButtonSelectedTmp);
//#ifdef NEEDME
      CenterDialog(GetParent(hwndDlg), hwndDlg);
//#endif
      return TRUE;
   case WM_COMMAND:
      switch (LOWORD(wParam)) {
      case IDM_SOUND_NONE:
      case IDM_SOUND_BEEP:
      case IDM_SOUND_WAVE_DURING:
      case IDM_SOUND_WAVE_AFTER:
         uSoundButtonSelectedTmp = LOWORD(wParam);
         CheckRadioButton(hwndDlg, IDM_SOUND_NONE, uMaxSoundRadioButton,
                        uSoundButtonSelectedTmp);
         break;
      case IDM_SOUND_PLAY:
         GetDlgItemText(hwndDlg, IDM_SOUND_EDIT, lpumb->szSoundName, WIZUNZIP_MAX_PATH);
#ifdef __BORLANDC__
#pragma warn -pro
#endif

#ifdef WIN32
      (*lpSndPlaySound)((LPSTR)lpumb->szSoundName, NULL, SND_ASYNC|SND_NOSTOP);
#else
      (*lpSndPlaySound)((LPSTR)lpumb->szSoundName, SND_ASYNC|SND_NOSTOP);
#endif

#ifdef __BORLANDC__
#pragma warn .pro
#endif
         break;
      case IDM_SOUND_BROWSE:
         if (DoOpenFile(hwndDlg, lpumb->szSoundName))
         {
            /* transfer to command window          */
                SetDlgItemText(hwndDlg, IDM_SOUND_EDIT, lpumb->szSoundName);
         }

         break;
       case IDOK:
         uSoundButtonSelected = uSoundButtonSelectedTmp;
         WritePrivateProfileString(szAppName, szSoundOptKey,
            SoundOptsTbl[uSoundButtonSelected-IDM_SOUND_NONE], szWizUnzipIniFile);
         GetDlgItemText(hwndDlg, IDM_SOUND_EDIT, lpumb->szSoundName, WIZUNZIP_MAX_PATH);
         WritePrivateProfileString(szAppName, szSoundNameKey,
                     lpumb->szSoundName,   szWizUnzipIniFile);
         EndDialog(hwndDlg, TRUE);
         break;
      case IDCANCEL:
         /* restore former value of sound file name
          */
         GetPrivateProfileString(szAppName, szSoundNameKey, szDfltWaveFile,
                     lpumb->szSoundName, WIZUNZIP_MAX_PATH,
                     szWizUnzipIniFile);
         EndDialog(hwndDlg, FALSE);
         break;
      case IDM_SOUND_HELP:
            WinHelp(hwndDlg,szHelpFileName,HELP_CONTEXT, (DWORD)(HELPID_SOUND_OPTIONS));
         break;
      }
      return TRUE;
   }
   return FALSE;
}
Example #22
0
VOID
SetThreadFields(
    PSYSTEM_THREAD_INFORMATION ThreadInfo,
    HWND hwnd
    )
{
    TIME_FIELDS UserTime;
    TIME_FIELDS KernelTime;
    TIME_FIELDS RunTime;
    LARGE_INTEGER Time;
    CHAR TimeString[15];
    CHAR StartString[32];
    HANDLE hThread;
    CONTEXT ThreadContext;
    NTSTATUS Status;
    OBJECT_ATTRIBUTES Obja;
    ULONG PcValue;

    //
    // Display the selected thread information
    //

    //
    // Compute runtimes
    //

    RtlTimeToTimeFields ( &ThreadInfo->UserTime, &UserTime);
    RtlTimeToTimeFields ( &ThreadInfo->KernelTime, &KernelTime);

    RtlTimeToTimeFields ( &ThreadInfo->UserTime, &UserTime);
    RtlTimeToTimeFields ( &ThreadInfo->KernelTime, &KernelTime);
    Time.QuadPart = RefreshTimeOfDayInfo.CurrentTime.QuadPart - ThreadInfo->CreateTime.QuadPart;
    RtlTimeToTimeFields ( &Time, &RunTime);
    wsprintf(TimeString,"%3ld:%02ld:%02ld.%03ld",
                RunTime.Hour,
                RunTime.Minute,
                RunTime.Second,
                RunTime.Milliseconds
                );
    SetDlgItemText(
        hwnd,
        PXPLODE_THREADELAPSED_TIME,
        TimeString
        );

    wsprintf(TimeString,"%3ld:%02ld:%02ld.%03ld",
                UserTime.Hour,
                UserTime.Minute,
                UserTime.Second,
                UserTime.Milliseconds
                );
    SetDlgItemText(
        hwnd,
        PXPLODE_THREADUSER_TIME,
        TimeString
        );

    wsprintf(TimeString,"%3ld:%02ld:%02ld.%03ld",
                KernelTime.Hour,
                KernelTime.Minute,
                KernelTime.Second,
                KernelTime.Milliseconds
                );
    SetDlgItemText(
        hwnd,
        PXPLODE_THREADKERNEL_TIME,
        TimeString
        );

    wsprintf(StartString,"0x%08lx",
                ThreadInfo->StartAddress
                );
    SetDlgItemText(
        hwnd,
        PXPLODE_THREAD_START,
        StartString
        );

    //
    // Do the priority Group
    //

    SetDlgItemInt(
        hwnd,
        PXPLODE_THREAD_DYNAMIC,
        ThreadInfo->Priority,
        FALSE
        );
    switch ( ThreadInfo->BasePriority - DlgProcessInfo->BasePriority ) {

        case 2:
            CheckRadioButton(
                hwnd,
                PXPLODE_THREAD_HIGHEST,
                PXPLODE_THREAD_LOWEST,
                PXPLODE_THREAD_HIGHEST
                );
            break;

        case 1:
            CheckRadioButton(
                hwnd,
                PXPLODE_THREAD_HIGHEST,
                PXPLODE_THREAD_LOWEST,
                PXPLODE_THREAD_ABOVE
                );
            break;

        case -1:
            CheckRadioButton(
                hwnd,
                PXPLODE_THREAD_HIGHEST,
                PXPLODE_THREAD_LOWEST,
                PXPLODE_THREAD_BELOW
                );
            break;
        case -2:
            CheckRadioButton(
                hwnd,
                PXPLODE_THREAD_HIGHEST,
                PXPLODE_THREAD_LOWEST,
                PXPLODE_THREAD_LOWEST
                );
            break;
        case 0:
        default:
            CheckRadioButton(
                hwnd,
                PXPLODE_THREAD_HIGHEST,
                PXPLODE_THREAD_LOWEST,
                PXPLODE_THREAD_NORMAL
                );
            break;
        }
    //
    // Complete thread information
    //

    SetDlgItemInt(
        hwnd,
        PXPLODE_THREAD_SWITCHES,
        ThreadInfo->ContextSwitches,
        FALSE
        );

    PcValue = 0;
    InitializeObjectAttributes(&Obja, NULL, 0, NULL, NULL);
    Status = NtOpenThread(
                &hThread,
                THREAD_GET_CONTEXT,
                &Obja,
                &ThreadInfo->ClientId
                );
    if ( NT_SUCCESS(Status) ) {
        ThreadContext.ContextFlags = CONTEXT_CONTROL;
        Status = NtGetContextThread(hThread,&ThreadContext);
        NtClose(hThread);
        if ( NT_SUCCESS(Status) ) {
            PcValue = (ULONG) CONTEXT_TO_PROGRAM_COUNTER(&ThreadContext);
            }
        }
    if ( PcValue ) {
        wsprintf(StartString,"0x%08lx",
                    PcValue
                    );
        SetDlgItemText(
            hwnd,
            PXPLODE_THREAD_PC,
            StartString
            );
        }
    else {
        SetDlgItemText(
            hwnd,
            PXPLODE_THREAD_PC,
            "Unknown"
            );
        }


    //
    // Disable the thread buttons if we can't get at the thread or it's token
    //

    {
        HANDLE Thread;
        HANDLE Token;
        BOOL ThreadOK = FALSE;
        BOOL GotToken = FALSE;

        Thread = OpenThread(MAXIMUM_ALLOWED, FALSE, (DWORD)ThreadInfo->ClientId.UniqueThread);
        if (Thread != NULL) {

            ThreadOK = TRUE;

            if (OpenThreadToken(Thread, MAXIMUM_ALLOWED, TRUE, &Token)) {
                GotToken = TRUE;
                CloseHandle(Token);
            }
            CloseHandle(Thread);
        }

        EnableWindow(GetDlgItem(hwnd, PXPLODE_THREAD_ACL), ThreadOK);

        EnableWindow(GetDlgItem(hwnd, PXPLODE_THREAD_TOKEN), GotToken);
        EnableWindow(GetDlgItem(hwnd, PXPLODE_THREAD_TOKEN_ACL), GotToken);
    }
}
Example #23
0
BOOL CSetOverlayIcons::OnInitDialog()
{
	ISettingsPropPage::OnInitDialog();

	m_cIconList.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_INFOTIP | LVS_EX_SUBITEMIMAGES);
	// get the path to our icon sets
	TCHAR buf[MAX_PATH] = {0};
	SHGetSpecialFolderPath(m_hWnd, buf, CSIDL_PROGRAM_FILES_COMMON, true);
	m_sIconPath = buf;
	m_sIconPath += _T("\\TortoiseOverlays\\Icons");
	// list all the icon sets
	CDirFileEnum filefinder(m_sIconPath);
	bool isDir = false;
	CString item;
	while (filefinder.NextFile(item, &isDir))
	{
		if (!isDir)
			continue;
		m_cIconSet.AddString(CPathUtils::GetFileNameFromPath(item));
	}
	CheckRadioButton(IDC_LISTRADIO, IDC_SYMBOLRADIO, IDC_LISTRADIO);
	CString sModifiedIcon = m_regModified;
	if (sModifiedIcon.IsEmpty())
	{
		// no custom icon set, use the default
		sModifiedIcon = m_sIconPath + _T("\\XPStyle\\ModifiedIcon.ico");
	}
	if (sModifiedIcon.Left(m_sIconPath.GetLength()).CompareNoCase(m_sIconPath)!=0)
	{
		// an icon set outside our own installation? We don't support that,
		// so fall back to the default!
		sModifiedIcon = m_sIconPath + _T("\\XPStyle\\ModifiedIcon.ico");
	}
	// the name of the icon set is the folder of the icon location
	m_sOriginalIconSet = sModifiedIcon.Mid(m_sIconPath.GetLength()+1);
	m_sOriginalIconSet = m_sOriginalIconSet.Left(m_sOriginalIconSet.ReverseFind('\\'));
	// now we have the name of the icon set. Set the combobox to show
	// that as selected
	CString ComboItem;
	for (int i=0; i<m_cIconSet.GetCount(); ++i)
	{
		m_cIconSet.GetLBText(i, ComboItem);
		if (ComboItem.CompareNoCase(m_sOriginalIconSet)==0)
			m_cIconSet.SetCurSel(i);
	}

	WORD langID = (WORD)(DWORD)CRegStdDWORD(_T("Software\\TortoiseGit\\LanguageID"), GetUserDefaultLangID());
	TCHAR statustext[MAX_STATUS_STRING_LENGTH] = { 0 };
	GitStatus::GetStatusString(AfxGetResourceHandle(), git_wc_status_normal, statustext, _countof(statustext), langID);
	m_sNormal = statustext;
	GitStatus::GetStatusString(AfxGetResourceHandle(), git_wc_status_modified, statustext, _countof(statustext), langID);
	m_sModified = statustext;
	GitStatus::GetStatusString(AfxGetResourceHandle(), git_wc_status_conflicted, statustext, _countof(statustext), langID);
	m_sConflicted = statustext;
	GitStatus::GetStatusString(AfxGetResourceHandle(), git_wc_status_deleted, statustext, _countof(statustext), langID);
	m_sDeleted = statustext;
	GitStatus::GetStatusString(AfxGetResourceHandle(), git_wc_status_added, statustext, _countof(statustext), langID);
	m_sAdded = statustext;
	GitStatus::GetStatusString(AfxGetResourceHandle(), git_wc_status_ignored, statustext, _countof(statustext), langID);
	m_sIgnored = statustext;
	GitStatus::GetStatusString(AfxGetResourceHandle(), git_wc_status_unversioned, statustext, _countof(statustext), langID);
	m_sUnversioned = statustext;

	m_sReadOnly.LoadString(IDS_SETTINGS_READONLYNAME);
	m_sLocked.LoadString(IDS_SETTINGS_LOCKEDNAME);

	SetWindowTheme(m_hWnd, L"Explorer", NULL);

	ShowIconSet(true);

	return TRUE;
}
Example #24
0
// copied and modified from NewStatusNotify
INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam) 
{
	int ID;
	TCHAR str[512];
	HMENU hMenu, hMenu1;
	RECT pos;
	HWND button;
	MCONTACT hContact;

	switch (msg) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hdlg);
		SaveOptions();

		// click actions
		hMenu  = LoadMenu(hInst, MAKEINTRESOURCE(IDR_PMENU));
		hMenu1 = GetSubMenu(hMenu, 0);
		GetMenuString(hMenu1, opt.LeftClickAction, str, sizeof(str), MF_BYCOMMAND);
		SetDlgItemText(hdlg, IDC_LeftClick, TranslateTS(str));
		GetMenuString(hMenu1, opt.RightClickAction, str, sizeof(str), MF_BYCOMMAND);
		SetDlgItemText(hdlg, IDC_RightClick, TranslateTS(str));
		DestroyMenu(hMenu);

		// other options
		CheckDlgButton(hdlg, IDC_E, opt.UsePopup);
		CheckDlgButton(hdlg, IDC_POP2, opt.AlertPopup);
		CheckDlgButton(hdlg, IDC_POP1, opt.UpdatePopup);
		CheckDlgButton(hdlg, IDC_CH, opt.PopupOnChange);
		CheckDlgButton(hdlg, IDC_W, opt.ShowWarnings);
		SetDlgItemText(hdlg,IDC_PText, opt.pText);
		SetDlgItemText(hdlg,IDC_PTitle, opt.pTitle);
		// setting popup delay option
		_ltot(opt.pDelay, str, 10);
		SetDlgItemText(hdlg,IDC_DELAY, str);
		if (opt.pDelay == -1)
			CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD2);
		else if (opt.pDelay == 0)
			CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD1);
		else
			CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD3);
		//Colours. First step is configuring the colours.
		SendDlgItemMessage(hdlg,IDC_BGCOLOUR,CPM_SETCOLOUR,0,opt.BGColour);
		SendDlgItemMessage(hdlg,IDC_TEXTCOLOUR,CPM_SETCOLOUR,0,opt.TextColour);
		//Second step is disabling them if we want to use default Windows ones.
		CheckDlgButton(hdlg, IDC_USEWINCOLORS,opt.UseWinColors?BST_CHECKED:BST_UNCHECKED);
		EnableWindow(GetDlgItem(hdlg, IDC_BGCOLOUR), !opt.UseWinColors);
		EnableWindow(GetDlgItem(hdlg, IDC_TEXTCOLOUR), !opt.UseWinColors);

		// buttons
		SendMessage(GetDlgItem(hdlg,IDC_PREVIEW), BUTTONSETASFLATBTN, TRUE, 0);
		SendMessage(GetDlgItem(hdlg,IDC_PDEF), BUTTONSETASFLATBTN, TRUE, 0);
		SendMessage(GetDlgItem(hdlg,IDC_LeftClick), BUTTONSETASFLATBTN, TRUE, 0);
		SendMessage(GetDlgItem(hdlg,IDC_RightClick), BUTTONSETASFLATBTN, TRUE, 0);
		SendMessage(GetDlgItem(hdlg,IDC_VAR3), BUTTONSETASFLATBTN, TRUE, 0);
		return TRUE;

	case WM_COMMAND:
		// enable the "apply" button 
		if (HIWORD(wParam) == BN_CLICKED && GetFocus() == (HWND)lParam)
			SendMessage(GetParent(hdlg),PSM_CHANGED,0,0);
		if ( !((LOWORD(wParam) == IDC_UPDATE || LOWORD(wParam) == IDC_DEGREE) && 
			(HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())))
			SendMessage(GetParent(hdlg),PSM_CHANGED,0,0);
		//These are simple clicks: we don't save, but we tell the Options Page to enable the "Apply" button.
		switch(LOWORD(wParam)) {
		case IDC_BGCOLOUR: //Fall through
		case IDC_TEXTCOLOUR:
			// select new colors
			if (HIWORD(wParam) == CPN_COLOURCHANGED)
				SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
			break;

		case IDC_USEWINCOLORS:
			// use window color - enable/disable color selection controls
			EnableWindow(GetDlgItem(hdlg, IDC_BGCOLOUR), !(opt.UseWinColors));
			EnableWindow(GetDlgItem(hdlg, IDC_TEXTCOLOUR), !(opt.UseWinColors));
			SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
			break;

		case IDC_E:
		case IDC_CH:
			SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
			break;

		case IDC_RightClick:
			// right click action selection menu
			button = GetDlgItem(hdlg, IDC_RightClick);
			GetWindowRect(button, &pos); 

			hMenu  = LoadMenu(hInst, MAKEINTRESOURCE(IDR_PMENU));
			hMenu1 = GetSubMenu(hMenu, 0);
			TranslateMenu(hMenu1);
			SelectMenuItem(hMenu1, opt.RightClickAction);
			ID = TrackPopupMenu(hMenu1, TPM_LEFTBUTTON|TPM_RETURNCMD, pos.left, pos.bottom, 0, hdlg, NULL);
			if (ID)   opt.RightClickAction = ID;
			DestroyMenu(hMenu);

			hMenu  = LoadMenu(hInst, MAKEINTRESOURCE(IDR_PMENU));
			hMenu1 = GetSubMenu(hMenu, 0);
			GetMenuString(hMenu1, opt.RightClickAction, str, sizeof(str), MF_BYCOMMAND);
			SetDlgItemText(hdlg, IDC_RightClick, TranslateTS(str));
			DestroyMenu(hMenu);
			break;

		case IDC_LeftClick:
			// left click action selection menu
			button = GetDlgItem(hdlg, IDC_LeftClick);
			GetWindowRect(button, &pos); 

			hMenu  = LoadMenu(hInst, MAKEINTRESOURCE(IDR_PMENU));
			hMenu1 = GetSubMenu(hMenu, 0);
			TranslateMenu(hMenu1);
			SelectMenuItem(hMenu1, opt.LeftClickAction);
			ID = TrackPopupMenu(hMenu1, TPM_LEFTBUTTON|TPM_RETURNCMD, pos.left, pos.bottom, 0, hdlg, NULL);
			if (ID)   opt.LeftClickAction = ID;
			DestroyMenu(hMenu);

			hMenu  = LoadMenu(hInst, MAKEINTRESOURCE(IDR_PMENU));
			hMenu1 = GetSubMenu(hMenu, 0);
			GetMenuString(hMenu1, opt.LeftClickAction, str, sizeof(str), MF_BYCOMMAND);
			SetDlgItemText(hdlg, IDC_LeftClick, TranslateTS(str));
			DestroyMenu(hMenu);
			break;

		case IDC_PD1:
			// Popup delay setting from Popup plugin
			SetDlgItemText(hdlg, IDC_DELAY, _T("0"));
			CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD1);
			break;

		case IDC_PD2:
			// Popup delay = permanent
			SetDlgItemText(hdlg, IDC_DELAY, _T("-1"));
			CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD2);
			break;

		case IDC_DELAY:
			// if text is edited
			CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD3);
			break;

		case IDC_PDEF:
			// set the default value for popup texts
			SetTextDefault("Pp");
			SetDlgItemText(hdlg,IDC_PText, opt.pText);
			SetDlgItemText(hdlg,IDC_PTitle, opt.pTitle);
			wfree(&opt.pText);
			wfree(&opt.pTitle);
			break;

		case IDC_VAR3:
			// display variable list
			_tcscpy(str, _T("                                                            \n"));		// to make the message box wider
			_tcscat(str, TranslateT("%c\tcurrent condition\n%d\tcurrent date\n%e\tdewpoint\n%f\tfeel-like temperature\n%h\ttoday's high\n%i\twind direction\n%l\ttoday's low\n%m\thumidity\n%n\tstation name\n%p\tpressure\n%r\tsunrise time\n%s\tstation ID\n%t\ttemperature\n%u\tupdate time\n%v\tvisibility\n%w\twind speed\n%y\tsun set"));
			_tcscat(str, _T("\n"));
			_tcscat(str, TranslateT("%[..]\tcustom variables"));
			MessageBox(NULL, str, TranslateT("Variable List"), MB_OK|MB_ICONASTERISK|MB_TOPMOST);
			break;

		case IDC_PREVIEW:
			// popup preview
			hContact = opt.DefStn;
			ReadPopupOpt(hdlg);	// read new options to memory
			WeatherPopup((WPARAM)opt.DefStn, (BOOL)TRUE);	// display popup using new opt
			DestroyOptions();
			LoadOptions();		// restore old option in memory
			opt.DefStn = hContact;
			break;
		}
		break;
	
	case WM_NOTIFY: //Here we have pressed either the OK or the APPLY button.
		switch (((LPNMHDR)lParam)->code) {
			case PSN_APPLY: {
				ReadPopupOpt(hdlg);

				// save the options, and update main menu
				SaveOptions();
				UpdatePopupMenu(opt.UsePopup);
				return TRUE;
			}
		}
		break;
	}
	return FALSE;
}
Example #25
0
BOOL CPPgNotify::OnInitDialog()
{
#if _ATL_VER >= 0x0710
	m_bEnableEMail = (IsRunningXPSP2OrHigher() > 0);
#endif

	CPropertyPage::OnInitDialog();
	InitWindowStyles(this);

	AddBuddyButton(GetDlgItem(IDC_EDIT_TBN_WAVFILE)->m_hWnd, ::GetDlgItem(m_hWnd, IDC_BTN_BROWSE_WAV));
	InitAttachedBrowseButton(::GetDlgItem(m_hWnd, IDC_BTN_BROWSE_WAV), m_icoBrowse);

	int iBtnID;
	if (thePrefs.notifierSoundType == ntfstSoundFile)
		iBtnID = IDC_CB_TBN_USESOUND;
	else if (thePrefs.notifierSoundType == ntfstSpeech)
		iBtnID = IDC_CB_TBN_USESPEECH;
	else {
		ASSERT( thePrefs.notifierSoundType == ntfstNoSound );
		iBtnID = IDC_CB_TBN_NOSOUND;
	}
	ASSERT( IDC_CB_TBN_NOSOUND < IDC_CB_TBN_USESOUND && IDC_CB_TBN_USESOUND < IDC_CB_TBN_USESPEECH );
	CheckRadioButton(IDC_CB_TBN_NOSOUND, IDC_CB_TBN_USESPEECH, iBtnID);

	CheckDlgButton(IDC_CB_TBN_ONDOWNLOAD, thePrefs.notifierOnDownloadFinished ? BST_CHECKED : BST_UNCHECKED);
	CheckDlgButton(IDC_CB_TBN_ONNEWDOWNLOAD, thePrefs.notifierOnNewDownload ? BST_CHECKED : BST_UNCHECKED);
	CheckDlgButton(IDC_CB_TBN_ONCHAT, thePrefs.notifierOnChat ? BST_CHECKED : BST_UNCHECKED);
	CheckDlgButton(IDC_CB_TBN_ONLOG, thePrefs.notifierOnLog ? BST_CHECKED : BST_UNCHECKED);
	CheckDlgButton(IDC_CB_TBN_IMPORTATNT, thePrefs.notifierOnImportantError ? BST_CHECKED : BST_UNCHECKED);
	CheckDlgButton(IDC_CB_TBN_POP_ALWAYS, thePrefs.notifierOnEveryChatMsg ? BST_CHECKED : BST_UNCHECKED);
	CheckDlgButton(IDC_CB_TBN_ONNEWVERSION, thePrefs.notifierOnNewVersion ? BST_CHECKED : BST_UNCHECKED);

	CButton* btnPTR = (CButton*)GetDlgItem(IDC_CB_TBN_POP_ALWAYS);
	btnPTR->EnableWindow(IsDlgButtonChecked(IDC_CB_TBN_ONCHAT));

	SetDlgItemText(IDC_EDIT_TBN_WAVFILE, thePrefs.notifierSoundFile);

	if (!m_bEnableEMail){
		CheckDlgButton(IDC_CB_ENABLENOTIFICATIONS, BST_UNCHECKED);
		GetDlgItem(IDC_EMAILNOT_GROUP)->EnableWindow(FALSE);
		GetDlgItem(IDC_CB_ENABLENOTIFICATIONS)->EnableWindow(FALSE);
		GetDlgItem(IDC_TXT_SMTPSERVER)->EnableWindow(FALSE);
		GetDlgItem(IDC_TXT_RECEIVER)->EnableWindow(FALSE);
		GetDlgItem(IDC_TXT_SENDER)->EnableWindow(FALSE);
		GetDlgItem(IDC_EDIT_SMTPSERVER)->EnableWindow(FALSE);
		GetDlgItem(IDC_EDIT_RECEIVER)->EnableWindow(FALSE);
		GetDlgItem(IDC_EDIT_SENDER)->EnableWindow(FALSE);
	}
	else{
		SetDlgItemText(IDC_EDIT_SMTPSERVER, thePrefs.GetNotifierMailServer());
		SetDlgItemText(IDC_EDIT_RECEIVER, thePrefs.GetNotifierMailReceiver());
		SetDlgItemText(IDC_EDIT_SENDER, thePrefs.GetNotifierMailSender());
		if (thePrefs.IsNotifierSendMailEnabled()){
			CheckDlgButton(IDC_CB_ENABLENOTIFICATIONS, BST_CHECKED);
			GetDlgItem(IDC_EDIT_SMTPSERVER)->EnableWindow(TRUE);
			GetDlgItem(IDC_EDIT_RECEIVER)->EnableWindow(TRUE);
			GetDlgItem(IDC_EDIT_SENDER)->EnableWindow(TRUE);
		}
		else{
			CheckDlgButton(IDC_CB_ENABLENOTIFICATIONS, BST_UNCHECKED);
			GetDlgItem(IDC_EDIT_SMTPSERVER)->EnableWindow(FALSE);
			GetDlgItem(IDC_EDIT_RECEIVER)->EnableWindow(FALSE);
			GetDlgItem(IDC_EDIT_SENDER)->EnableWindow(FALSE);
		}
	}

	UpdateControls();
	Localize();

	GetDlgItem(IDC_CB_TBN_USESPEECH)->EnableWindow(IsSpeechEngineAvailable());

	return TRUE;  // return TRUE unless you set the focus to a control
				  // EXCEPTION: OCX Property Pages should return FALSE
}
Example #26
0
BOOL CEditPropBugtraq::OnInitDialog()
{
    CResizableStandAloneDialog::OnInitDialog();
    CAppUtils::MarkWindowAsUnpinnable(m_hWnd);

    ExtendFrameIntoClientArea(IDC_DWM);
    m_aeroControls.SubclassControl(this, IDC_PROPRECURSIVE);
    m_aeroControls.SubclassOkCancelHelp(this);

    CheckRadioButton(IDC_TOPRADIO, IDC_BOTTOMRADIO, IDC_BOTTOMRADIO);
    CheckRadioButton(IDC_TEXTRADIO, IDC_NUMERICRADIO, IDC_NUMERICRADIO);

    for (IT it = m_properties.begin(); it != m_properties.end(); ++it)
    {
        if (it->first.compare(BUGTRAQPROPNAME_URL) == 0)
        {
            m_sBugtraqUrl = CUnicodeUtils::StdGetUnicode(it->second.value).c_str();
        }
        else if (it->first.compare(BUGTRAQPROPNAME_MESSAGE) == 0)
        {
            m_sBugtraqMessage = CUnicodeUtils::StdGetUnicode(it->second.value).c_str();
        }
        else if (it->first.compare(BUGTRAQPROPNAME_LABEL) == 0)
        {
            m_sBugtraqLabel = CUnicodeUtils::StdGetUnicode(it->second.value).c_str();
        }
        else if (it->first.compare(BUGTRAQPROPNAME_PROVIDERUUID) == 0)
        {
            m_sProviderUUID = CUnicodeUtils::StdGetUnicode(it->second.value).c_str();
        }
        else if (it->first.compare(BUGTRAQPROPNAME_PROVIDERUUID64) == 0)
        {
            m_sProviderUUID64 = CUnicodeUtils::StdGetUnicode(it->second.value).c_str();
        }
        else if (it->first.compare(BUGTRAQPROPNAME_PROVIDERPARAMS) == 0)
        {
            m_sProviderParams = CUnicodeUtils::StdGetUnicode(it->second.value).c_str();
        }
        else if (it->first.compare(BUGTRAQPROPNAME_LOGREGEX) == 0)
        {
            CString sRegex = CUnicodeUtils::StdGetUnicode(it->second.value).c_str();
            int nl = sRegex.Find('\n');
            if (nl >= 0)
            {
                m_sBugtraqRegex1 = sRegex.Mid(nl+1);
                m_sBugtraqRegex2 = sRegex.Left(nl);
            }
            else
                m_sBugtraqRegex1 = sRegex;
        }
        else if (it->first.compare(BUGTRAQPROPNAME_WARNIFNOISSUE) == 0)
        {
            CString sYesNo = CUnicodeUtils::StdGetUnicode(it->second.value).c_str();
            m_bWarnIfNoIssue = ((sYesNo.CompareNoCase(_T("yes")) == 0)||((sYesNo.CompareNoCase(_T("true")) == 0)));
        }
        else if (it->first.compare(BUGTRAQPROPNAME_APPEND) == 0)
        {
            CString sYesNo = CUnicodeUtils::StdGetUnicode(it->second.value).c_str();
            if ((sYesNo.CompareNoCase(_T("no")) == 0)||((sYesNo.CompareNoCase(_T("false")) == 0)))
                CheckRadioButton(IDC_TOPRADIO, IDC_BOTTOMRADIO, IDC_TOPRADIO);
        }
        else if (it->first.compare(BUGTRAQPROPNAME_NUMBER) == 0)
        {
            CString sYesNo = CUnicodeUtils::StdGetUnicode(it->second.value).c_str();
            if ((sYesNo.CompareNoCase(_T("no")) == 0)||((sYesNo.CompareNoCase(_T("false")) == 0)))
                CheckRadioButton(IDC_TEXTRADIO, IDC_NUMERICRADIO, IDC_TEXTRADIO);
        }
    }

    CString sWindowTitle;
    GetWindowText(sWindowTitle);
    CAppUtils::SetWindowTitle(m_hWnd, m_pathList.GetCommonRoot().GetUIPathString(), sWindowTitle);

    m_tooltips.Create(this);
    m_tooltips.AddTool(IDC_TESTREGEX, IDS_EDITPROPS_TESTREGEX_TT);
    UpdateData(false);

    AdjustControlSize(IDC_BUGTRAQWARN);
    AdjustControlSize(IDC_TEXTRADIO);
    AdjustControlSize(IDC_NUMERICRADIO);
    AdjustControlSize(IDC_TOPRADIO);
    AdjustControlSize(IDC_BOTTOMRADIO);
    AdjustControlSize(IDC_PROPRECURSIVE);

    RECT rect;
    GetWindowRect(&rect);
    m_height = rect.bottom - rect.top;

    GetDlgItem(IDC_PROPRECURSIVE)->EnableWindow(m_bFolder || m_bMultiple);
    GetDlgItem(IDC_PROPRECURSIVE)->ShowWindow(m_bRevProps || m_bRemote ? SW_HIDE : SW_SHOW);

    AddAnchor(IDC_ISSUETRACKERGROUP, TOP_LEFT, TOP_RIGHT);
    AddAnchor(IDC_URLLABEL, TOP_LEFT, TOP_RIGHT);
    AddAnchor(IDC_URLLABEL2, TOP_LEFT);
    AddAnchor(IDC_BUGTRAQURL, TOP_LEFT, TOP_RIGHT);
    AddAnchor(IDC_BUGTRAQWARN, TOP_LEFT, TOP_RIGHT);
    AddAnchor(IDC_MESSAGEGROUP, TOP_LEFT, TOP_RIGHT);
    AddAnchor(IDC_MESSAGEHINTLABEL, TOP_LEFT, TOP_RIGHT);
    AddAnchor(IDC_MESSAGEPATTERNLABEL, TOP_LEFT);
    AddAnchor(IDC_BUGTRAQMESSAGE, TOP_LEFT, TOP_RIGHT);
    AddAnchor(IDC_MESSAGELABEL, TOP_LEFT);
    AddAnchor(IDC_BUGTRAQLABEL, TOP_LEFT, TOP_RIGHT);
    AddAnchor(IDC_BUGIDLABEL, TOP_LEFT);
    AddAnchor(IDC_TEXTRADIO, TOP_LEFT);
    AddAnchor(IDC_NUMERICRADIO, TOP_LEFT);
    AddAnchor(IDC_INSERTLABEL, TOP_LEFT);
    AddAnchor(IDC_TOPRADIO, TOP_LEFT);
    AddAnchor(IDC_BOTTOMRADIO, TOP_LEFT);
    AddAnchor(IDC_REGEXGROUP, TOP_LEFT, TOP_RIGHT);
    AddAnchor(IDC_REGEXLABEL, TOP_LEFT, TOP_RIGHT);
    AddAnchor(IDC_REGEXIDLABEL, TOP_LEFT);
    AddAnchor(IDC_BUGTRAQLOGREGEX1, TOP_LEFT, TOP_RIGHT);
    AddAnchor(IDC_REGEXMSGLABEL, TOP_LEFT);
    AddAnchor(IDC_BUGTRAQLOGREGEX2, TOP_LEFT, TOP_RIGHT);
    AddAnchor(IDC_TESTREGEX, TOP_RIGHT);
    AddAnchor(IDC_IBUGTRAQPROVIDERGROUP, TOP_LEFT, TOP_RIGHT);
    AddAnchor(IDC_UUIDLABEL32, TOP_LEFT);
    AddAnchor(IDC_UUID32, TOP_LEFT);
    AddAnchor(IDC_UUIDLABEL64, TOP_LEFT);
    AddAnchor(IDC_UUID64, TOP_LEFT, TOP_RIGHT);
    AddAnchor(IDC_PARAMSLABEL, TOP_LEFT);
    AddAnchor(IDC_PARAMS, TOP_LEFT, TOP_RIGHT);
    AddAnchor(IDC_DWM, TOP_LEFT);
    AddAnchor(IDC_PROPRECURSIVE, BOTTOM_LEFT, BOTTOM_RIGHT);
    AddAnchor(IDOK, BOTTOM_RIGHT);
    AddAnchor(IDCANCEL, BOTTOM_RIGHT);
    AddAnchor(IDHELP, BOTTOM_RIGHT);
    EnableSaveRestore(_T("EditPropBugtraq"));

    GetDlgItem(IDC_BUGTRAQURL)->SetFocus();
    return FALSE;
}
Example #27
0
//--------------------------------------------------------------------
void CWrapperConfigDialog::OnInitDialog(HWND p_hWndDialog)
{
	CSimulatorConfig *defaults = CSimulatorConfig::GetInstance();
	m_hWndDialog = p_hWndDialog;
	HWND list = GetDlgItem(m_hWndDialog, IDC_COMBO_SCREEN_SIZE);

	BOOL isLandscape = FALSE;
	int currentSizeIndex = defaults->CheckScreenSize(m_tagAppConfig.GetFrameSize());
	if (currentSizeIndex < 0)
	{
		currentSizeIndex = 0;
	}
	else
	{
		isLandscape = m_tagAppConfig.IsLandscapeFrame();
	}

	for (int i = 0; i < defaults->GetScreenSizeCount(); ++i)
	{
		const SSimulatorScreenSize &size = defaults->GetScreenSize(i);
		wstring title;
		title.assign(size.m_szTitle.begin(), size.m_szTitle.end());
		ComboBox_AddString(list, title.c_str());

		if (i == currentSizeIndex)
		{
			char buff[32];
			sprintf_s(buff, "%d", isLandscape ? size.m_nHeight : size.m_nWidth);
			SetDlgItemTextA(m_hWndDialog, IDC_EDIT_SCREEN_WIDTH, buff);
			sprintf_s(buff, "%d", isLandscape ? size.m_nWidth : size.m_nHeight);
			SetDlgItemTextA(m_hWndDialog, IDC_EDIT_SCREEN_HEIGHT, buff);
		}
	}
	ComboBox_AddString(list, L"Custom Size");
	ComboBox_SetCurSel(list, currentSizeIndex);

	Edit_LimitText(GetDlgItem(m_hWndDialog, IDC_EDIT_SCREEN_WIDTH), 4);
	Edit_LimitText(GetDlgItem(m_hWndDialog, IDC_EDIT_SCREEN_HEIGHT), 4);

	HWND direction = GetDlgItem(m_hWndDialog, IDC_RADIO_PORTRAIT);
	CheckRadioButton(m_hWndDialog, IDC_RADIO_PORTRAIT, IDC_RADIO_LANDSCAPE, isLandscape ? IDC_RADIO_LANDSCAPE : IDC_RADIO_PORTRAIT);

	Button_SetCheck(GetDlgItem(m_hWndDialog, IDC_CHECK_SHOW_DEBUG_CONSOLE), m_tagAppConfig.IsShowConsole());
	Button_SetCheck(GetDlgItem(m_hWndDialog, IDC_CHECK_WRITE_DEBUG_LOG_TO_FILE), m_tagAppConfig.IsWriteDebugLogToFile());
	Button_SetCheck(GetDlgItem(m_hWndDialog, IDC_CHECK_LOAD_PRECOMPILED_FRAMEWORK), m_tagAppConfig.IsLoadPrecompiledFramework());

	// center a dialog box within its owner window
	RECT rc, rcOwner, rcDlg;
	GetWindowRect(m_hWnd, &rcOwner); 
	GetWindowRect(m_hWndDialog, &rcDlg); 
	CopyRect(&rc, &rcOwner); 

	OffsetRect(&rcDlg, -rcDlg.left, -rcDlg.top); 
	OffsetRect(&rc, -rc.left, -rc.top); 
	OffsetRect(&rc, -rcDlg.right, -rcDlg.bottom); 

	SetWindowPos(m_hWndDialog,
		HWND_TOP,
		rcOwner.left + (rc.right / 2),
		rcOwner.top + (rc.bottom / 2),
		0, 0,          // Ignores size arguments. 
		SWP_NOSIZE);
}
Example #28
0
static INT_PTR CALLBACK SettingsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hwndDlg);
		{
			hwndSettingsDlg = hwndDlg;
			LCID locale = Langpack_GetDefaultLocale();
			SendDlgItemMessage(hwndDlg, IDC_ICON_HEADER, STM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIcon("AutoShutdown_Header"));
			{
				HFONT hBoldFont;
				LOGFONT lf;
				if (GetObject((HFONT)SendDlgItemMessage(hwndDlg, IDC_TEXT_HEADER, WM_GETFONT, 0, 0), sizeof(lf), &lf)) {
					lf.lfWeight = FW_BOLD;
					hBoldFont = CreateFontIndirect(&lf);
				}
				else hBoldFont = NULL;
				SendDlgItemMessage(hwndDlg, IDC_TEXT_HEADER, WM_SETFONT, (WPARAM)hBoldFont, FALSE);
			}
			/* read-in watcher flags */
			{
				WORD watcherType = db_get_w(NULL, "AutoShutdown", "WatcherFlags", SETTING_WATCHERFLAGS_DEFAULT);
				CheckRadioButton(hwndDlg, IDC_RADIO_STTIME, IDC_RADIO_STCOUNTDOWN, (watcherType&SDWTF_ST_TIME) ? IDC_RADIO_STTIME : IDC_RADIO_STCOUNTDOWN);
				CheckDlgButton(hwndDlg, IDC_CHECK_SPECIFICTIME, (watcherType&SDWTF_SPECIFICTIME) != 0 ? BST_CHECKED : BST_UNCHECKED);
				CheckDlgButton(hwndDlg, IDC_CHECK_MESSAGE, (watcherType&SDWTF_MESSAGE) != 0 ? BST_CHECKED : BST_UNCHECKED);
				CheckDlgButton(hwndDlg, IDC_CHECK_FILETRANSFER, (watcherType&SDWTF_FILETRANSFER) != 0 ? BST_CHECKED : BST_UNCHECKED);
				CheckDlgButton(hwndDlg, IDC_CHECK_IDLE, (watcherType&SDWTF_IDLE) != 0 ? BST_CHECKED : BST_UNCHECKED);
				CheckDlgButton(hwndDlg, IDC_CHECK_STATUS, (watcherType&SDWTF_STATUS) != 0 ? BST_CHECKED : BST_UNCHECKED);
				CheckDlgButton(hwndDlg, IDC_CHECK_CPUUSAGE, (watcherType&SDWTF_CPUUSAGE) != 0 ? BST_CHECKED : BST_UNCHECKED);
			}
			/* read-in countdown val */
			{
				SYSTEMTIME st;
				if (!TimeStampToSystemTime((time_t)db_get_dw(NULL, "AutoShutdown", "TimeStamp", SETTING_TIMESTAMP_DEFAULT), &st))
					GetLocalTime(&st);
				DateTime_SetSystemtime(GetDlgItem(hwndDlg, IDC_TIME_TIMESTAMP), GDT_VALID, &st);
				DateTime_SetSystemtime(GetDlgItem(hwndDlg, IDC_DATE_TIMESTAMP), GDT_VALID, &st);
				SendMessage(hwndDlg, M_CHECK_DATETIME, 0, 0);
			}
			{
				DWORD setting = db_get_dw(NULL, "AutoShutdown", "Countdown", SETTING_COUNTDOWN_DEFAULT);
				if (setting < 1) setting = SETTING_COUNTDOWN_DEFAULT;
				SendDlgItemMessage(hwndDlg, IDC_SPIN_COUNTDOWN, UDM_SETRANGE, 0, MAKELPARAM(UD_MAXVAL, 1));
				SendDlgItemMessage(hwndDlg, IDC_EDIT_COUNTDOWN, EM_SETLIMITTEXT, (WPARAM)10, 0);
				SendDlgItemMessage(hwndDlg, IDC_SPIN_COUNTDOWN, UDM_SETPOS, 0, MAKELPARAM(setting, 0));
				SetDlgItemInt(hwndDlg, IDC_EDIT_COUNTDOWN, setting, FALSE);
			}
			{
				HWND hwndCombo = GetDlgItem(hwndDlg, IDC_COMBO_COUNTDOWNUNIT);
				DWORD lastUnit = db_get_dw(NULL, "AutoShutdown", "CountdownUnit", SETTING_COUNTDOWNUNIT_DEFAULT);
				SendMessage(hwndCombo, CB_SETLOCALE, (WPARAM)locale, 0); /* sort order */
				SendMessage(hwndCombo, CB_INITSTORAGE, _countof(unitNames), _countof(unitNames) * 16); /* approx. */
				for (int i = 0; i < _countof(unitNames); ++i) {
					int index = SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)TranslateTS(unitNames[i]));
					if (index != LB_ERR) {
						SendMessage(hwndCombo, CB_SETITEMDATA, index, (LPARAM)unitValues[i]);
						if (i == 0 || unitValues[i] == lastUnit) SendMessage(hwndCombo, CB_SETCURSEL, index, 0);
					}
				}
			}
			{
				DBVARIANT dbv;
				if (!db_get_ts(NULL, "AutoShutdown", "Message", &dbv)) {
					SetDlgItemText(hwndDlg, IDC_EDIT_MESSAGE, dbv.ptszVal);
					mir_free(dbv.ptszVal);
				}
			}
			/* cpuusage threshold */
			{
				BYTE setting = DBGetContactSettingRangedByte(NULL, "AutoShutdown", "CpuUsageThreshold", SETTING_CPUUSAGETHRESHOLD_DEFAULT, 1, 100);
				SendDlgItemMessage(hwndDlg, IDC_SPIN_CPUUSAGE, UDM_SETRANGE, 0, MAKELPARAM(100, 1));
				SendDlgItemMessage(hwndDlg, IDC_EDIT_CPUUSAGE, EM_SETLIMITTEXT, (WPARAM)3, 0);
				SendDlgItemMessage(hwndDlg, IDC_SPIN_CPUUSAGE, UDM_SETPOS, 0, MAKELPARAM(setting, 0));
				SetDlgItemInt(hwndDlg, IDC_EDIT_CPUUSAGE, setting, FALSE);
			}
			/* shutdown types */
			{
				HWND hwndCombo = GetDlgItem(hwndDlg, IDC_COMBO_SHUTDOWNTYPE);
				BYTE lastShutdownType = db_get_b(NULL, "AutoShutdown", "ShutdownType", SETTING_SHUTDOWNTYPE_DEFAULT);
				SendMessage(hwndCombo, CB_SETLOCALE, (WPARAM)locale, 0); /* sort order */
				SendMessage(hwndCombo, CB_SETEXTENDEDUI, TRUE, 0);
				SendMessage(hwndCombo, CB_INITSTORAGE, SDSDT_MAX, SDSDT_MAX * 32);
				for (BYTE shutdownType = 1; shutdownType <= SDSDT_MAX; ++shutdownType)
					if (ServiceIsTypeEnabled(shutdownType, 0)) {
						TCHAR *pszText = (TCHAR*)ServiceGetTypeDescription(shutdownType, GSTDF_TCHAR); /* never fails */
						int index = SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)pszText);
						if (index != LB_ERR) {
							SendMessage(hwndCombo, CB_SETITEMDATA, index, (LPARAM)shutdownType);
							if (shutdownType == 1 || shutdownType == lastShutdownType) SendMessage(hwndCombo, CB_SETCURSEL, (WPARAM)index, 0);
						}
					}
				SendMessage(hwndDlg, M_UPDATE_SHUTDOWNDESC, 0, (LPARAM)hwndCombo);
			}
			/* check if proto is installed that supports instant messages and check if a message dialog plugin is installed */
			if (!AnyProtoHasCaps(PF1_IMRECV) || !ServiceExists(MS_MSG_SENDMESSAGE)) { /* no srmessage present? */
				CheckDlgButton(hwndDlg, IDC_CHECK_MESSAGE, BST_UNCHECKED);
				EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK_MESSAGE), FALSE);
				EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_MESSAGE), FALSE);
			}
			/* check if proto is installed that supports file transfers and check if a file transfer dialog is available */
			if (!AnyProtoHasCaps(PF1_FILESEND) && !AnyProtoHasCaps(PF1_FILERECV)) {  /* no srfile present? */
				CheckDlgButton(hwndDlg, IDC_CHECK_FILETRANSFER, BST_UNCHECKED);
				EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK_FILETRANSFER), FALSE);
			}
			/* check if cpu usage can be detected */
			if (!PollCpuUsage(DisplayCpuUsageProc, (LPARAM)GetDlgItem(hwndDlg, IDC_TEXT_CURRENTCPU), 1800)) {
				CheckDlgButton(hwndDlg, IDC_CHECK_CPUUSAGE, BST_UNCHECKED);
				EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK_CPUUSAGE), FALSE);
			}
		}
		SendMessage(hwndDlg, M_ENABLE_SUBCTLS, 0, 0);
		Utils_RestoreWindowPositionNoSize(hwndDlg, NULL, "AutoShutdown", "SettingsDlg_");
		return TRUE; /* default focus */

	case WM_DESTROY:
		Utils_SaveWindowPosition(hwndDlg, NULL, "AutoShutdown", "SettingsDlg_");
		{
			HFONT hFont = (HFONT)SendDlgItemMessage(hwndDlg, IDC_TEXT_HEADER, WM_GETFONT, 0, 0);
			SendDlgItemMessage(hwndDlg, IDC_TEXT_HEADER, WM_SETFONT, 0, FALSE); /* no return value */
			if (hFont != NULL)
				DeleteObject(hFont);
			hwndSettingsDlg = NULL;
		}
		return TRUE;

	case WM_CTLCOLORSTATIC:
		switch (GetDlgCtrlID((HWND)lParam)) {
		case IDC_ICON_HEADER:
			SetBkMode((HDC)wParam, TRANSPARENT);

		case IDC_RECT_HEADER:
			/* need to set COLOR_WINDOW manually for Win9x */
			SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW));
			return (INT_PTR)GetSysColorBrush(COLOR_WINDOW);

		case IDC_TEXT_HEADER:
		case IDC_TEXT_HEADERDESC:
			SetBkMode((HDC)wParam, TRANSPARENT);
			return (INT_PTR)GetStockObject(NULL_BRUSH);
		}
		break;

	case M_ENABLE_SUBCTLS:
		{
			BOOL checked = IsDlgButtonChecked(hwndDlg, IDC_CHECK_MESSAGE) != 0;
			EnableDlgItem(hwndDlg, IDC_EDIT_MESSAGE, checked);
			checked = IsDlgButtonChecked(hwndDlg, IDC_CHECK_SPECIFICTIME) != 0;
			EnableDlgItem(hwndDlg, IDC_RADIO_STTIME, checked);
			EnableDlgItem(hwndDlg, IDC_RADIO_STCOUNTDOWN, checked);
			checked = (IsDlgButtonChecked(hwndDlg, IDC_CHECK_SPECIFICTIME) && IsDlgButtonChecked(hwndDlg, IDC_RADIO_STTIME));
			EnableDlgItem(hwndDlg, IDC_TIME_TIMESTAMP, checked);
			EnableDlgItem(hwndDlg, IDC_DATE_TIMESTAMP, checked);
			checked = (IsDlgButtonChecked(hwndDlg, IDC_CHECK_SPECIFICTIME) && IsDlgButtonChecked(hwndDlg, IDC_RADIO_STCOUNTDOWN));
			EnableDlgItem(hwndDlg, IDC_EDIT_COUNTDOWN, checked);
			EnableDlgItem(hwndDlg, IDC_SPIN_COUNTDOWN, checked);
			EnableDlgItem(hwndDlg, IDC_COMBO_COUNTDOWNUNIT, checked);
			checked = IsDlgButtonChecked(hwndDlg, IDC_CHECK_IDLE) != 0;
			EnableDlgItem(hwndDlg, IDC_URL_IDLE, checked);
			checked = IsDlgButtonChecked(hwndDlg, IDC_CHECK_CPUUSAGE) != 0;
			EnableDlgItem(hwndDlg, IDC_EDIT_CPUUSAGE, checked);
			EnableDlgItem(hwndDlg, IDC_SPIN_CPUUSAGE, checked);
			EnableDlgItem(hwndDlg, IDC_TEXT_PERCENT, checked);
			EnableDlgItem(hwndDlg, IDC_TEXT_CURRENTCPU, checked);
			checked = (IsDlgButtonChecked(hwndDlg, IDC_CHECK_SPECIFICTIME) || IsDlgButtonChecked(hwndDlg, IDC_CHECK_MESSAGE) ||
				IsDlgButtonChecked(hwndDlg, IDC_CHECK_IDLE) || IsDlgButtonChecked(hwndDlg, IDC_CHECK_STATUS) ||
				IsDlgButtonChecked(hwndDlg, IDC_CHECK_FILETRANSFER) || IsDlgButtonChecked(hwndDlg, IDC_CHECK_CPUUSAGE));
			EnableDlgItem(hwndDlg, IDOK, checked);
		}
		return TRUE;

	case M_UPDATE_SHUTDOWNDESC: /* lParam=(LPARAM)(HWND)hwndCombo */
		{
			BYTE shutdownType = (BYTE)SendMessage((HWND)lParam, CB_GETITEMDATA, SendMessage((HWND)lParam, CB_GETCURSEL, 0, 0), 0);
			SetDlgItemText(hwndDlg, IDC_TEXT_SHUTDOWNTYPE, (TCHAR*)ServiceGetTypeDescription(shutdownType, GSTDF_LONGDESC | GSTDF_TCHAR));
		}
		return TRUE;

	case WM_TIMECHANGE: /* system time changed */
		SendMessage(hwndDlg, M_CHECK_DATETIME, 0, 0);
		return TRUE;

	case M_CHECK_DATETIME:
		{
			SYSTEMTIME st, stBuf;
			time_t timestamp;
			DateTime_GetSystemtime(GetDlgItem(hwndDlg, IDC_DATE_TIMESTAMP), &stBuf);
			DateTime_GetSystemtime(GetDlgItem(hwndDlg, IDC_TIME_TIMESTAMP), &st);
			st.wDay = stBuf.wDay;
			st.wDayOfWeek = stBuf.wDayOfWeek;
			st.wMonth = stBuf.wMonth;
			st.wYear = stBuf.wYear;
			GetLocalTime(&stBuf);
			if (SystemTimeToTimeStamp(&st, &timestamp)) {
				/* set to current date if earlier */
				if (timestamp < time(NULL)) {
					st.wDay = stBuf.wDay;
					st.wDayOfWeek = stBuf.wDayOfWeek;
					st.wMonth = stBuf.wMonth;
					st.wYear = stBuf.wYear;
					if (SystemTimeToTimeStamp(&st, &timestamp)) {
						/* step one day up if still earlier */
						if (timestamp < time(NULL)) {
							timestamp += 24 * 60 * 60;
							TimeStampToSystemTime(timestamp, &st);
						}
					}
				}
			}
			DateTime_SetRange(GetDlgItem(hwndDlg, IDC_DATE_TIMESTAMP), GDTR_MIN, &stBuf);
			DateTime_SetRange(GetDlgItem(hwndDlg, IDC_TIME_TIMESTAMP), GDTR_MIN, &stBuf);
			DateTime_SetSystemtime(GetDlgItem(hwndDlg, IDC_DATE_TIMESTAMP), GDT_VALID, &st);
			DateTime_SetSystemtime(GetDlgItem(hwndDlg, IDC_TIME_TIMESTAMP), GDT_VALID, &st);
		}
		return TRUE;

	case WM_NOTIFY:
		switch (((NMHDR*)lParam)->idFrom) {
		case IDC_TIME_TIMESTAMP:
		case IDC_DATE_TIMESTAMP:
			switch (((NMHDR*)lParam)->code) {
			case DTN_CLOSEUP:
			case NM_KILLFOCUS:
				PostMessage(hwndDlg, M_CHECK_DATETIME, 0, 0);
				return TRUE;
			}
		}
		break;

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDC_CHECK_MESSAGE:
		case IDC_CHECK_FILETRANSFER:
		case IDC_CHECK_IDLE:
		case IDC_CHECK_CPUUSAGE:
		case IDC_CHECK_STATUS:
		case IDC_CHECK_SPECIFICTIME:
		case IDC_RADIO_STTIME:
		case IDC_RADIO_STCOUNTDOWN:
			SendMessage(hwndDlg, M_ENABLE_SUBCTLS, 0, 0);
			return TRUE;

		case IDC_EDIT_COUNTDOWN:
			if (HIWORD(wParam) == EN_KILLFOCUS) {
				if ((int)GetDlgItemInt(hwndDlg, IDC_EDIT_COUNTDOWN, NULL, TRUE) < 1) {
					SendDlgItemMessage(hwndDlg, IDC_SPIN_COUNTDOWN, UDM_SETPOS, 0, MAKELPARAM(1, 0));
					SetDlgItemInt(hwndDlg, IDC_EDIT_COUNTDOWN, 1, FALSE);
				}
				return TRUE;
			}
			break;

		case IDC_EDIT_CPUUSAGE:
			if (HIWORD(wParam) == EN_KILLFOCUS) {
				WORD val = (WORD)GetDlgItemInt(hwndDlg, IDC_EDIT_CPUUSAGE, NULL, FALSE);
				if (val < 1) val = 1;
				else if (val>100) val = 100;
				SendDlgItemMessage(hwndDlg, IDC_SPIN_CPUUSAGE, UDM_SETPOS, 0, MAKELPARAM(val, 0));
				SetDlgItemInt(hwndDlg, IDC_EDIT_CPUUSAGE, val, FALSE);
				return TRUE;
			}
			break;

		case IDC_URL_IDLE:
			{
				OPENOPTIONSDIALOG ood;
				ood.cbSize = sizeof(ood);
				ood.pszGroup = "Status"; /* autotranslated */
				ood.pszPage = "Idle"; /* autotranslated */
				ood.pszTab = NULL;
				Options_Open(&ood);
				return TRUE;
			}

		case IDC_COMBO_SHUTDOWNTYPE:
			if (HIWORD(wParam) == CBN_SELCHANGE)
				SendMessage(hwndDlg, M_UPDATE_SHUTDOWNDESC, 0, lParam);
			return TRUE;

		case IDOK: /* save settings and start watcher */
			ShowWindow(hwndDlg, SW_HIDE);
			/* message text */
			{
				HWND hwndEdit = GetDlgItem(hwndDlg, IDC_EDIT_MESSAGE);
				int len = GetWindowTextLength(hwndEdit) + 1;
				TCHAR *pszText = (TCHAR*)mir_alloc(len*sizeof(TCHAR));
				if (pszText != NULL && GetWindowText(hwndEdit, pszText, len + 1)) {
					TrimString(pszText);
					db_set_ts(NULL, "AutoShutdown", "Message", pszText);
				}
				mir_free(pszText); /* does NULL check */
			}
			/* timestamp */
			{
				SYSTEMTIME st;
				time_t timestamp;
				DateTime_GetSystemtime(GetDlgItem(hwndDlg, IDC_TIME_TIMESTAMP), &st); /* time gets synchronized */
				if (!SystemTimeToTimeStamp(&st, &timestamp))
					timestamp = time(NULL);
				db_set_dw(NULL, "AutoShutdown", "TimeStamp", (DWORD)timestamp);
			}
			/* shutdown type */
			{
				int index = SendDlgItemMessage(hwndDlg, IDC_COMBO_SHUTDOWNTYPE, CB_GETCURSEL, 0, 0);
				if (index != LB_ERR)
					db_set_b(NULL, "AutoShutdown", "ShutdownType", (BYTE)SendDlgItemMessage(hwndDlg, IDC_COMBO_SHUTDOWNTYPE, CB_GETITEMDATA, (WPARAM)index, 0));
				index = SendDlgItemMessage(hwndDlg, IDC_COMBO_COUNTDOWNUNIT, CB_GETCURSEL, 0, 0);
				if (index != LB_ERR)
					db_set_dw(NULL, "AutoShutdown", "CountdownUnit", (DWORD)SendDlgItemMessage(hwndDlg, IDC_COMBO_COUNTDOWNUNIT, CB_GETITEMDATA, (WPARAM)index, 0));
				db_set_dw(NULL, "AutoShutdown", "Countdown", (DWORD)GetDlgItemInt(hwndDlg, IDC_EDIT_COUNTDOWN, NULL, FALSE));
				db_set_b(NULL, "AutoShutdown", "CpuUsageThreshold", (BYTE)GetDlgItemInt(hwndDlg, IDC_EDIT_CPUUSAGE, NULL, FALSE));
			}
			/* watcher type */
			{
				WORD watcherType = (WORD)(IsDlgButtonChecked(hwndDlg, IDC_RADIO_STTIME) ? SDWTF_ST_TIME : SDWTF_ST_COUNTDOWN);
				if (IsDlgButtonChecked(hwndDlg, IDC_CHECK_SPECIFICTIME)) watcherType |= SDWTF_SPECIFICTIME;
				if (IsDlgButtonChecked(hwndDlg, IDC_CHECK_MESSAGE)) watcherType |= SDWTF_MESSAGE;
				if (IsDlgButtonChecked(hwndDlg, IDC_CHECK_FILETRANSFER)) watcherType |= SDWTF_FILETRANSFER;
				if (IsDlgButtonChecked(hwndDlg, IDC_CHECK_IDLE)) watcherType |= SDWTF_IDLE;
				if (IsDlgButtonChecked(hwndDlg, IDC_CHECK_STATUS)) watcherType |= SDWTF_STATUS;
				if (IsDlgButtonChecked(hwndDlg, IDC_CHECK_CPUUSAGE)) watcherType |= SDWTF_CPUUSAGE;
				db_set_w(NULL, "AutoShutdown", "WatcherFlags", watcherType);
				ServiceStartWatcher(0, watcherType);
			}
			DestroyWindow(hwndDlg);
			return TRUE;
			// fall through 

		case IDCANCEL: /* WM_CLOSE */
			DestroyWindow(hwndDlg);
			SetShutdownToolbarButton(false);
			SetShutdownMenuItem(false);
			return TRUE;
		}
		break;
	}
	return FALSE;
}
Example #29
0
void CKademliaWnd::OnEnSetfocusBootstrapip()
{
	CheckRadioButton(IDC_RADIP, IDC_RADNODESURL, IDC_RADIP);
	UpdateControlsState();
}
	void CAnalysisHowPage::SetComputationKind(short kind)
	{
		ASSERT(kind >= 0 && kind < CAnalysisComputation::NB_KIND);
		CheckRadioButton(IDC_STATISTIC, IDC_EVENT, IDC_STATISTIC + kind);
	}