Browse Source

Handle Ctrl+A keyboard shortcut in MD5/SHA256 Generators

Added new window procedures for the HASH_PATH_EDIT/HASH_RESULT_EDIT
and HASH_TEXT_EDIT/HASH_RESULT_FOMTEXT_EDIT controls, where Ctrl+A
is now processed.

Fix #3863, close #3898, close #6034, close #6059
pull/6093/head
luisffranca 7 years ago committed by Don HO
parent
commit
0d87d37d35
No known key found for this signature in database
GPG Key ID: 6C429F1D8D84F46E
  1. 78
      PowerEditor/src/MISC/md5/md5Dlgs.cpp
  2. 32
      PowerEditor/src/MISC/md5/md5Dlgs.h

78
PowerEditor/src/MISC/md5/md5Dlgs.cpp

@ -34,8 +34,18 @@ INT_PTR CALLBACK HashFromFilesDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
HFONT hFont = ::CreateFontA(fontDpiDynamicalHeight, 0, 0, 0, 0, FALSE, FALSE, FALSE, ANSI_CHARSET,
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH | FF_DONTCARE, "Courier New");
::SendMessage(::GetDlgItem(_hSelf, IDC_HASH_PATH_EDIT), WM_SETFONT, reinterpret_cast<WPARAM>(hFont), TRUE);
::SendMessage(::GetDlgItem(_hSelf, IDC_HASH_RESULT_EDIT), WM_SETFONT, reinterpret_cast<WPARAM>(hFont), TRUE);
const HWND hHashPathEdit = ::GetDlgItem(_hSelf, IDC_HASH_PATH_EDIT);
const HWND hHashResult = ::GetDlgItem(_hSelf, IDC_HASH_RESULT_EDIT);
::SendMessage(hHashPathEdit, WM_SETFONT, reinterpret_cast<WPARAM>(hFont), TRUE);
::SendMessage(hHashResult, WM_SETFONT, reinterpret_cast<WPARAM>(hFont), TRUE);
::SetWindowLongPtr(hHashPathEdit, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
_oldHashPathEditProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(hHashPathEdit, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(HashPathEditStaticProc)));
::SetWindowLongPtr(hHashResult, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
_oldHashResultProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(hHashResult, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(HashResultStaticProc)));
}
return TRUE;
@ -138,6 +148,31 @@ INT_PTR CALLBACK HashFromFilesDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
return FALSE;
}
LRESULT HashFromFilesDlg::run_textEditProc(WNDPROC oldEditProc, HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_GETDLGCODE:
{
return DLGC_WANTALLKEYS | ::CallWindowProc(oldEditProc, hwnd, message, wParam, lParam);
}
case WM_CHAR:
{
if (wParam == 1) // Ctrl+A
{
::SendMessage(hwnd, EM_SETSEL, 0, -1);
return TRUE;
}
break;
}
default:
break;
}
return ::CallWindowProc(oldEditProc, hwnd, message, wParam, lParam);
}
void HashFromFilesDlg::setHashType(hashType hashType2set)
{
_ht = hashType2set;
@ -265,8 +300,18 @@ INT_PTR CALLBACK HashFromTextDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
HFONT hFont = ::CreateFontA(fontDpiDynamicalHeight, 0, 0, 0, 0, FALSE, FALSE, FALSE, ANSI_CHARSET,
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH | FF_DONTCARE, "Courier New");
::SendMessage(::GetDlgItem(_hSelf, IDC_HASH_TEXT_EDIT), WM_SETFONT, reinterpret_cast<WPARAM>(hFont), TRUE);
::SendMessage(::GetDlgItem(_hSelf, IDC_HASH_RESULT_FOMTEXT_EDIT), WM_SETFONT, reinterpret_cast<WPARAM>(hFont), TRUE);
const HWND hHashTextEdit = ::GetDlgItem(_hSelf, IDC_HASH_TEXT_EDIT);
const HWND hHashResult = ::GetDlgItem(_hSelf, IDC_HASH_RESULT_FOMTEXT_EDIT);
::SendMessage(hHashTextEdit, WM_SETFONT, reinterpret_cast<WPARAM>(hFont), TRUE);
::SendMessage(hHashResult, WM_SETFONT, reinterpret_cast<WPARAM>(hFont), TRUE);
::SetWindowLongPtr(hHashTextEdit, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
_oldHashTextEditProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(hHashTextEdit, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(HashTextEditStaticProc)));
::SetWindowLongPtr(hHashResult, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
_oldHashResultProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(hHashResult, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(HashResultStaticProc)));
}
return TRUE;
@ -329,6 +374,31 @@ INT_PTR CALLBACK HashFromTextDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
return FALSE;
}
LRESULT HashFromTextDlg::run_textEditProc(WNDPROC oldEditProc, HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_GETDLGCODE:
{
return DLGC_WANTALLKEYS | ::CallWindowProc(oldEditProc, hwnd, message, wParam, lParam);
}
case WM_CHAR:
{
if (wParam == 1) // Ctrl+A
{
::SendMessage(hwnd, EM_SETSEL, 0, -1);
return TRUE;
}
break;
}
default:
break;
}
return ::CallWindowProc(oldEditProc, hwnd, message, wParam, lParam);
}
void HashFromTextDlg::setHashType(hashType hashType2set)
{
_ht = hashType2set;

32
PowerEditor/src/MISC/md5/md5Dlgs.h

@ -33,6 +33,22 @@ public :
protected :
virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
hashType _ht = hash_md5;
LRESULT run_textEditProc(WNDPROC oldEditProc, HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
static LRESULT CALLBACK HashPathEditStaticProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
const auto dlg = (HashFromFilesDlg *)(::GetWindowLongPtr(hwnd, GWLP_USERDATA));
return (dlg->run_textEditProc(dlg->_oldHashPathEditProc, hwnd, message, wParam, lParam));
};
static LRESULT CALLBACK HashResultStaticProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
const auto dlg = (HashFromFilesDlg *)(::GetWindowLongPtr(hwnd, GWLP_USERDATA));
return (dlg->run_textEditProc(dlg->_oldHashResultProc, hwnd, message, wParam, lParam));
};
private :
WNDPROC _oldHashPathEditProc = nullptr;
WNDPROC _oldHashResultProc = nullptr;
};
class HashFromTextDlg : public StaticDialog
@ -49,5 +65,21 @@ public :
protected :
virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
hashType _ht = hash_md5;
LRESULT run_textEditProc(WNDPROC oldEditProc, HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
static LRESULT CALLBACK HashTextEditStaticProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
const auto dlg = (HashFromTextDlg *)(::GetWindowLongPtr(hwnd, GWLP_USERDATA));
return (dlg->run_textEditProc(dlg->_oldHashTextEditProc, hwnd, message, wParam, lParam));
};
static LRESULT CALLBACK HashResultStaticProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
const auto dlg = (HashFromTextDlg *)(::GetWindowLongPtr(hwnd, GWLP_USERDATA));
return (dlg->run_textEditProc(dlg->_oldHashResultProc, hwnd, message, wParam, lParam));
};
private :
WNDPROC _oldHashTextEditProc = nullptr;
WNDPROC _oldHashResultProc = nullptr;
};

Loading…
Cancel
Save