diff --git a/sakura_core/view/CEditView.cpp b/sakura_core/view/CEditView.cpp index 3e125534cb..58a4287978 100644 --- a/sakura_core/view/CEditView.cpp +++ b/sakura_core/view/CEditView.cpp @@ -385,9 +385,18 @@ BOOL CEditView::Create( /* キーボードの現在のリピート間隔を取得 */ DWORD dwKeyBoardSpeed; - SystemParametersInfo( SPI_GETKEYBOARDSPEED, 0, &dwKeyBoardSpeed, 0 ); + constexpr DWORD keyboardRepeatSpeedMax = 31; // 0~31の範囲の最大値 + if( SystemParametersInfo( SPI_GETKEYBOARDSPEED, 0, &dwKeyBoardSpeed, 0 ) ){ + // 念の為に assert で確認 + assert(dwKeyBoardSpeed <= keyboardRepeatSpeedMax); + } + else{ + // SystemParametersInfo の呼び出しが失敗した場合は最大値をデフォルト値として設定 + constexpr DWORD keyboardRepeatSpeedDefault = keyboardRepeatSpeedMax; + dwKeyBoardSpeed = keyboardRepeatSpeedDefault; + } /* リピート速度の設定をミリ秒に変換 */ - UINT uElapse = 400 - dwKeyBoardSpeed * (400 - 33) / 31; + UINT uElapse = 400 - dwKeyBoardSpeed * (400 - 33) / keyboardRepeatSpeedMax; /* タイマー起動 */ if( 0 == ::SetTimer( GetHwnd(), IDT_ROLLMOUSE, uElapse, EditViewTimerProc ) ){ WarningMessage( GetHwnd(), LS(STR_VIEW_TIMER) );