Skip to content

Commit

Permalink
Merge pull request sakura-editor#1212 from beru/ImeSetOpen
Browse files Browse the repository at this point in the history
設定画面の数値入力用のエディット コントロールにフォーカス時にIMEを使わないように設定
  • Loading branch information
beru authored Mar 8, 2020
2 parents 51272a9 + a1905b1 commit 5eb328f
Show file tree
Hide file tree
Showing 18 changed files with 355 additions and 3 deletions.
1 change: 1 addition & 0 deletions sakura_core/dlg/CDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ BOOL CDialog::OnCommand( WPARAM wParam, LPARAM lParam )
}else if( ::lstrcmpi(szClass, L"Edit") == 0 ){
switch( wNotifyCode ){
case EN_CHANGE: return OnEnChange( hwndCtl, wID );
case EN_SETFOCUS: return OnEnSetFocus( hwndCtl, wID );
case EN_KILLFOCUS: return OnEnKillFocus( hwndCtl, wID );
}
}else if( ::lstrcmpi(szClass, L"ListBox") == 0 ){
Expand Down
1 change: 1 addition & 0 deletions sakura_core/dlg/CDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class CDialog
virtual BOOL OnBnClicked(int wID);
virtual BOOL OnStnClicked( int ){return FALSE;}
virtual BOOL OnEnChange( HWND hwndCtl, int wID ){return FALSE;}
virtual BOOL OnEnSetFocus( HWND hwndCtl, int wID ){return FALSE;}
virtual BOOL OnEnKillFocus( HWND hwndCtl, int wID ){return FALSE;}
virtual BOOL OnLbnSelChange( HWND hwndCtl, int wID ){return FALSE;}
virtual BOOL OnLbnDblclk( int wID ){return FALSE;}
Expand Down
30 changes: 30 additions & 0 deletions sakura_core/dlg/CDlgJump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "outline/CFuncInfo.h"
#include "outline/CFuncInfoArr.h"// 2002/2/10 aroka ヘッダ整理
#include "util/shell.h"
#include "util/os.h"
#include "window/CEditWnd.h"
#include "sakura_rc.h"
#include "sakura.hh"
Expand Down Expand Up @@ -184,6 +185,35 @@ BOOL CDlgJump::OnBnClicked( int wID )
return CDialog::OnBnClicked( wID );
}

// IMEのオープン状態復帰用
static BOOL s_isImmOpenBkup;

// IMEを使用したくないコントロールのID判定
static bool isImeUndesirable(int id)
{
switch (id) {
case IDC_EDIT_LINENUM:
case IDC_EDIT_PLSQL_E1:
return true;
default:
return false;
}
}

BOOL CDlgJump::OnEnSetFocus(HWND hwndCtl, int wID)
{
if (isImeUndesirable(wID))
ImeSetOpen(hwndCtl, FALSE, &s_isImmOpenBkup);
return 0;
}

BOOL CDlgJump::OnEnKillFocus(HWND hwndCtl, int wID)
{
if (isImeUndesirable(wID))
ImeSetOpen(hwndCtl, s_isImmOpenBkup, nullptr);
return 0;
}

/* ダイアログデータの設定 */
void CDlgJump::SetData( void )
{
Expand Down
3 changes: 3 additions & 0 deletions sakura_core/dlg/CDlgJump.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ class CDlgJump final : public CDialog
BOOL OnNotify(WPARAM wParam, LPARAM lParam) override; // Oct. 6, 2000 JEPRO added for Spin control
BOOL OnCbnSelChange(HWND hwndCtl, int wID) override;
BOOL OnBnClicked(int wID) override;
BOOL OnEnSetFocus(HWND hwndCtl, int wID) override;
BOOL OnEnKillFocus(HWND hwndCtl, int wID) override;

LPVOID GetHelpIdTable(void) override; //@@@ 2002.01.18 add
void SetData( void ) override; /* ダイアログデータの設定 */
int GetData( void ) override; /* ダイアログデータの取得 */
Expand Down
33 changes: 33 additions & 0 deletions sakura_core/dlg/CDlgPrintSetting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "func/Funccode.h" // Stonee, 2001/03/12
#include "util/shell.h"
#include "util/window.h"
#include "util/os.h"
#include "sakura_rc.h" // 2002/2/10 aroka
#include "sakura.hh"

Expand Down Expand Up @@ -406,6 +407,34 @@ BOOL CDlgPrintSetting::OnEnChange( HWND hwndCtl, int wID )
return CDialog::OnEnChange( hwndCtl, wID );
}

// IMEのオープン状態復帰用
static BOOL s_isImmOpenBkup;

// IMEを使用したくないコントロールのID判定
static bool isImeUndesirable(int id)
{
switch (id) {
case IDC_EDIT_FONTHEIGHT:
case IDC_EDIT_LINESPACE:
case IDC_EDIT_DANSUU:
case IDC_EDIT_DANSPACE:
case IDC_EDIT_MARGINTY:
case IDC_EDIT_MARGINBY:
case IDC_EDIT_MARGINLX:
case IDC_EDIT_MARGINRX:
return true;
default:
return false;
}
}

BOOL CDlgPrintSetting::OnEnSetFocus(HWND hwndCtl, int wID)
{
if (isImeUndesirable(wID))
ImeSetOpen(hwndCtl, FALSE, &s_isImmOpenBkup);
return 0;
}

BOOL CDlgPrintSetting::OnEnKillFocus( HWND hwndCtl, int wID )
{
switch( wID ){
Expand All @@ -426,6 +455,10 @@ BOOL CDlgPrintSetting::OnEnKillFocus( HWND hwndCtl, int wID )
UpdatePrintableLineAndColumn();
break; // ここでは行と桁の更新要求のみ。後の処理はCDialogに任せる。
}

if (isImeUndesirable(wID))
ImeSetOpen(hwndCtl, s_isImmOpenBkup, nullptr);

/* 基底クラスメンバ */
return CDialog::OnEnKillFocus( hwndCtl, wID );
}
Expand Down
1 change: 1 addition & 0 deletions sakura_core/dlg/CDlgPrintSetting.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class CDlgPrintSetting final : public CDialog
BOOL OnBnClicked(int wID) override;
BOOL OnStnClicked(int wID) override;
BOOL OnEnChange( HWND hwndCtl, int wID ) override;
BOOL OnEnSetFocus(HWND hwndCtl, int wID) override;
BOOL OnEnKillFocus( HWND hwndCtl, int wID ) override;
LPVOID GetHelpIdTable(void) override; //@@@ 2002.01.18 add

Expand Down
32 changes: 32 additions & 0 deletions sakura_core/dlg/CDlgWinSize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "StdAfx.h"
#include "dlg/CDlgWinSize.h"
#include "util/shell.h"
#include "util/os.h"
#include "sakura_rc.h"
#include "sakura.hh"

Expand Down Expand Up @@ -125,6 +126,37 @@ BOOL CDlgWinSize::OnBnClicked( int wID )
return CDialog::OnBnClicked( wID );
}

// IMEのオープン状態復帰用
static BOOL s_isImmOpenBkup;

// IMEを使用したくないコントロールのID判定
static bool isImeUndesirable(int id)
{
switch (id) {
case IDC_EDIT_WX:
case IDC_EDIT_WY:
case IDC_EDIT_SX:
case IDC_EDIT_SY:
return true;
default:
return false;
}
}

BOOL CDlgWinSize::OnEnSetFocus(HWND hwndCtl, int wID)
{
if (isImeUndesirable(wID))
ImeSetOpen(hwndCtl, FALSE, &s_isImmOpenBkup);
return 0;
}

BOOL CDlgWinSize::OnEnKillFocus(HWND hwndCtl, int wID)
{
if (isImeUndesirable(wID))
ImeSetOpen(hwndCtl, s_isImmOpenBkup, nullptr);
return 0;
}

/*! @brief ダイアログボックスにデータを設定
*/
void CDlgWinSize::SetData( void )
Expand Down
2 changes: 2 additions & 0 deletions sakura_core/dlg/CDlgWinSize.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class CDlgWinSize final : public CDialog

BOOL OnInitDialog(HWND hwndDlg, WPARAM wParam, LPARAM lParam) override;
BOOL OnBnClicked(int wID) override;
BOOL OnEnSetFocus(HWND hwndCtl, int wID) override;
BOOL OnEnKillFocus(HWND hwndCtl, int wID) override;
int GetData( void ) override;
void SetData( void ) override;
LPVOID GetHelpIdTable( void ) override;
Expand Down
28 changes: 28 additions & 0 deletions sakura_core/prop/CPropComFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "CPropertyManager.h"
#include "util/shell.h"
#include "util/window.h"
#include "util/os.h"
#include "sakura_rc.h"
#include "sakura.hh"

Expand Down Expand Up @@ -67,6 +68,23 @@ INT_PTR CALLBACK CPropFile::DlgProc_page(
}
// To Here Jun. 2, 2001 genta

// IMEのオープン状態復帰用
static BOOL s_isImmOpenBkup;

// IMEを使用したくないコントロールのID判定
static bool isImeUndesirable(int id)
{
switch (id) {
case IDC_EDIT_AUTOLOAD_DELAY:
case IDC_EDIT_nDropFileNumMax:
case IDC_EDIT_ALERT_FILESIZE:
case IDC_EDIT_AUTOBACKUP_INTERVAL:
return true;
default:
return false;
}
}

/*! ファイルページ メッセージ処理 */
INT_PTR CPropFile::DispatchEvent(
HWND hwndDlg, //!< handle to dialog box
Expand All @@ -77,6 +95,7 @@ INT_PTR CPropFile::DispatchEvent(
{
WORD wNotifyCode;
WORD wID;
HWND hwndCtl;
NMHDR* pNMHDR;
NM_UPDOWN* pMNUD;
int idCtrl;
Expand Down Expand Up @@ -210,6 +229,7 @@ INT_PTR CPropFile::DispatchEvent(
case WM_COMMAND:
wNotifyCode = HIWORD(wParam); /* 通知コード */
wID = LOWORD(wParam); /* 項目ID、 コントロールID、 またはアクセラレータID */
hwndCtl = (HWND) lParam; /* コントロールのハンドル */

if( wID == IDC_COMBO_FILESHAREMODE && wNotifyCode == CBN_SELCHANGE ){ // コンボボックスの選択変更
EnableFilePropInput(hwndDlg);
Expand All @@ -228,6 +248,14 @@ INT_PTR CPropFile::DispatchEvent(
break;
}
break;
case EN_SETFOCUS:
if (isImeUndesirable(wID))
ImeSetOpen(hwndCtl, FALSE, &s_isImmOpenBkup);
break;
case EN_KILLFOCUS:
if (isImeUndesirable(wID))
ImeSetOpen(hwndCtl, s_isImmOpenBkup, nullptr);
break;
}
break;

Expand Down
36 changes: 36 additions & 0 deletions sakura_core/prop/CPropComFileName.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "prop/CPropCommon.h"
#include "util/shell.h"
#include "util/window.h"
#include "util/os.h"
#include "sakura_rc.h"
#include "sakura.hh"

Expand All @@ -56,9 +57,44 @@ static const DWORD p_helpids[] = { //13400
0, 0 //
};

// IMEのオープン状態復帰用
static BOOL s_isImmOpenBkup;

// IMEを使用したくないコントロールのID判定
static bool isImeUndesirable(int id)
{
switch (id) {
case IDC_EDIT_SHORTMAXWIDTH:
return true;
default:
return false;
}
}

INT_PTR CALLBACK CPropFileName::DlgProc_page(
HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
WORD wNotifyCode;
WORD wID;
HWND hwndCtl;
switch (uMsg) {
case WM_COMMAND:
wNotifyCode = HIWORD(wParam); /* 通知コード */
wID = LOWORD(wParam); /* 項目ID、 コントロールID、 またはアクセラレータID */
hwndCtl = (HWND) lParam; /* コントロールのハンドル */
switch( wNotifyCode ){
case EN_SETFOCUS:
if (isImeUndesirable(wID))
ImeSetOpen(hwndCtl, FALSE, &s_isImmOpenBkup);
break;
case EN_KILLFOCUS:
if (isImeUndesirable(wID))
ImeSetOpen(hwndCtl, s_isImmOpenBkup, nullptr);
break;
}
break;
}

return DlgProc( reinterpret_cast<pDispatchPage>(&CPropFileName::DispatchEvent), hwndDlg, uMsg, wParam, lParam );
}

Expand Down
30 changes: 28 additions & 2 deletions sakura_core/prop/CPropComGeneral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "recent/CMRUFile.h"
#include "recent/CMRUFolder.h"
#include "util/shell.h"
#include "util/os.h"
#include "sakura_rc.h"
#include "sakura.hh"

Expand Down Expand Up @@ -73,6 +74,23 @@ INT_PTR CALLBACK CPropGeneral::DlgProc_page(
return DlgProc( reinterpret_cast<pDispatchPage>(&CPropGeneral::DispatchEvent), hwndDlg, uMsg, wParam, lParam );
}

// IMEのオープン状態復帰用
static BOOL s_isImmOpenBkup;

// IMEを使用したくないコントロールのID判定
static bool isImeUndesirable(int id)
{
switch (id) {
case IDC_EDIT_REPEATEDSCROLLLINENUM:
case IDD_PROP_GENERAL:
case IDC_EDIT_MAX_MRU_FILE:
case IDC_EDIT_MAX_MRU_FOLDER:
return true;
default:
return false;
}
}

/* General メッセージ処理 */
INT_PTR CPropGeneral::DispatchEvent(
HWND hwndDlg, // handle to dialog box
Expand All @@ -83,7 +101,7 @@ INT_PTR CPropGeneral::DispatchEvent(
{
WORD wNotifyCode;
WORD wID;
// HWND hwndCtl;
HWND hwndCtl;
NMHDR* pNMHDR;
NM_UPDOWN* pMNUD;
int idCtrl;
Expand All @@ -104,7 +122,7 @@ INT_PTR CPropGeneral::DispatchEvent(
case WM_COMMAND:
wNotifyCode = HIWORD(wParam); /* 通知コード */
wID = LOWORD(wParam); /* 項目ID、 コントロールID、 またはアクセラレータID */
// hwndCtl = (HWND) lParam; /* コントロールのハンドル */
hwndCtl = (HWND) lParam; /* コントロールのハンドル */
switch( wNotifyCode ){
/* ボタン/チェックボックスがクリックされた */
case BN_CLICKED:
Expand Down Expand Up @@ -181,6 +199,14 @@ INT_PTR CPropGeneral::DispatchEvent(
return TRUE;
}
break; // CBN_SELENDOK
case EN_SETFOCUS:
if (isImeUndesirable(wID))
ImeSetOpen(hwndCtl, FALSE, &s_isImmOpenBkup);
break;
case EN_KILLFOCUS:
if (isImeUndesirable(wID))
ImeSetOpen(hwndCtl, s_isImmOpenBkup, nullptr);
break;
}
break; /* WM_COMMAND */
case WM_NOTIFY:
Expand Down
Loading

0 comments on commit 5eb328f

Please sign in to comment.