From 83b866f13c9615c5c695ddb8246fa604bb5f3812 Mon Sep 17 00:00:00 2001 From: Katsuhisa Yuasa Date: Sun, 7 Oct 2018 17:42:49 +0900 Subject: [PATCH 1/3] =?UTF-8?q?CEditView::Create=20=E3=81=AB=E3=81=8A?= =?UTF-8?q?=E3=81=84=E3=81=A6=20SystemParametersInfo=20=E5=91=BC=E3=81=B3?= =?UTF-8?q?=E5=87=BA=E3=81=97=E3=81=8C=E5=A4=B1=E6=95=97=E3=81=97=E3=81=9F?= =?UTF-8?q?=E5=A0=B4=E5=90=88=E3=81=AE=E5=AF=BE=E7=AD=96=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sakura_core/view/CEditView.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sakura_core/view/CEditView.cpp b/sakura_core/view/CEditView.cpp index 3e125534cb..dcfca2148c 100644 --- a/sakura_core/view/CEditView.cpp +++ b/sakura_core/view/CEditView.cpp @@ -385,7 +385,12 @@ BOOL CEditView::Create( /* キーボードの現在のリピート間隔を取得 */ DWORD dwKeyBoardSpeed; - SystemParametersInfo( SPI_GETKEYBOARDSPEED, 0, &dwKeyBoardSpeed, 0 ); + if( SystemParametersInfo( SPI_GETKEYBOARDSPEED, 0, &dwKeyBoardSpeed, 0 ) ){ + assert(dwKeyBoardSpeed <= 31); + } + else{ + dwKeyBoardSpeed = 31; + } /* リピート速度の設定をミリ秒に変換 */ UINT uElapse = 400 - dwKeyBoardSpeed * (400 - 33) / 31; /* タイマー起動 */ From 8927c9bfb7828853559fe4d25a2e436a34bd27c2 Mon Sep 17 00:00:00 2001 From: Katsuhisa Yuasa Date: Sun, 7 Oct 2018 18:04:00 +0900 Subject: [PATCH 2/3] =?UTF-8?q?=E3=83=AC=E3=83=93=E3=83=A5=E3=83=BC?= =?UTF-8?q?=E6=8C=87=E6=91=98=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sakura_core/view/CEditView.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sakura_core/view/CEditView.cpp b/sakura_core/view/CEditView.cpp index dcfca2148c..1f8b0797f0 100644 --- a/sakura_core/view/CEditView.cpp +++ b/sakura_core/view/CEditView.cpp @@ -385,14 +385,15 @@ BOOL CEditView::Create( /* キーボードの現在のリピート間隔を取得 */ DWORD dwKeyBoardSpeed; + constexpr DWORD keyboardRepeatSpeedMax = 31; if( SystemParametersInfo( SPI_GETKEYBOARDSPEED, 0, &dwKeyBoardSpeed, 0 ) ){ - assert(dwKeyBoardSpeed <= 31); + assert(dwKeyBoardSpeed <= keyboardRepeatSpeedMax); } else{ - dwKeyBoardSpeed = 31; + dwKeyBoardSpeed = keyboardRepeatSpeedMax; } /* リピート速度の設定をミリ秒に変換 */ - 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) ); From 83458a2ddfee09f2fe43fd33a2c2729faeab1f2b Mon Sep 17 00:00:00 2001 From: Katsuhisa Yuasa Date: Sun, 7 Oct 2018 21:02:42 +0900 Subject: [PATCH 3/3] =?UTF-8?q?=E3=83=AC=E3=83=93=E3=83=A5=E3=83=BC?= =?UTF-8?q?=E6=8C=87=E6=91=98=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sakura_core/view/CEditView.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sakura_core/view/CEditView.cpp b/sakura_core/view/CEditView.cpp index 1f8b0797f0..58a4287978 100644 --- a/sakura_core/view/CEditView.cpp +++ b/sakura_core/view/CEditView.cpp @@ -385,12 +385,15 @@ BOOL CEditView::Create( /* キーボードの現在のリピート間隔を取得 */ DWORD dwKeyBoardSpeed; - constexpr DWORD keyboardRepeatSpeedMax = 31; + constexpr DWORD keyboardRepeatSpeedMax = 31; // 0~31の範囲の最大値 if( SystemParametersInfo( SPI_GETKEYBOARDSPEED, 0, &dwKeyBoardSpeed, 0 ) ){ + // 念の為に assert で確認 assert(dwKeyBoardSpeed <= keyboardRepeatSpeedMax); } else{ - dwKeyBoardSpeed = keyboardRepeatSpeedMax; + // SystemParametersInfo の呼び出しが失敗した場合は最大値をデフォルト値として設定 + constexpr DWORD keyboardRepeatSpeedDefault = keyboardRepeatSpeedMax; + dwKeyBoardSpeed = keyboardRepeatSpeedDefault; } /* リピート速度の設定をミリ秒に変換 */ UINT uElapse = 400 - dwKeyBoardSpeed * (400 - 33) / keyboardRepeatSpeedMax;