Code enhancement: remove duplicated code

pull/6093/head
Don HO 5 years ago
parent 0d87d37d35
commit ab46fe0806
No known key found for this signature in database
GPG Key ID: 6C429F1D8D84F46E

@ -148,7 +148,7 @@ INT_PTR CALLBACK HashFromFilesDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
return FALSE; return FALSE;
} }
LRESULT HashFromFilesDlg::run_textEditProc(WNDPROC oldEditProc, HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) LRESULT run_textEditProc(WNDPROC oldEditProc, HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{ {
switch (message) switch (message)
{ {
@ -374,31 +374,6 @@ INT_PTR CALLBACK HashFromTextDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
return FALSE; 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) void HashFromTextDlg::setHashType(hashType hashType2set)
{ {
_ht = hashType2set; _ht = hashType2set;

@ -21,6 +21,8 @@
enum hashType {hash_md5, hash_sha256}; enum hashType {hash_md5, hash_sha256};
LRESULT run_textEditProc(WNDPROC oldEditProc, HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
class HashFromFilesDlg : public StaticDialog class HashFromFilesDlg : public StaticDialog
{ {
public : public :
@ -34,16 +36,14 @@ protected :
virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
hashType _ht = hash_md5; 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) {
static LRESULT CALLBACK HashPathEditStaticProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
const auto dlg = (HashFromFilesDlg *)(::GetWindowLongPtr(hwnd, GWLP_USERDATA)); const auto dlg = (HashFromFilesDlg *)(::GetWindowLongPtr(hwnd, GWLP_USERDATA));
return (dlg->run_textEditProc(dlg->_oldHashPathEditProc, hwnd, message, wParam, lParam)); return (run_textEditProc(dlg->_oldHashPathEditProc, hwnd, message, wParam, lParam));
}; };
static LRESULT CALLBACK HashResultStaticProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{ static LRESULT CALLBACK HashResultStaticProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
const auto dlg = (HashFromFilesDlg *)(::GetWindowLongPtr(hwnd, GWLP_USERDATA)); const auto dlg = (HashFromFilesDlg *)(::GetWindowLongPtr(hwnd, GWLP_USERDATA));
return (dlg->run_textEditProc(dlg->_oldHashResultProc, hwnd, message, wParam, lParam)); return (run_textEditProc(dlg->_oldHashResultProc, hwnd, message, wParam, lParam));
}; };
private : private :
@ -66,16 +66,14 @@ protected :
virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
hashType _ht = hash_md5; 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) {
static LRESULT CALLBACK HashTextEditStaticProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
const auto dlg = (HashFromTextDlg *)(::GetWindowLongPtr(hwnd, GWLP_USERDATA)); const auto dlg = (HashFromTextDlg *)(::GetWindowLongPtr(hwnd, GWLP_USERDATA));
return (dlg->run_textEditProc(dlg->_oldHashTextEditProc, hwnd, message, wParam, lParam)); return (run_textEditProc(dlg->_oldHashTextEditProc, hwnd, message, wParam, lParam));
}; };
static LRESULT CALLBACK HashResultStaticProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{ static LRESULT CALLBACK HashResultStaticProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
const auto dlg = (HashFromTextDlg *)(::GetWindowLongPtr(hwnd, GWLP_USERDATA)); const auto dlg = (HashFromTextDlg *)(::GetWindowLongPtr(hwnd, GWLP_USERDATA));
return (dlg->run_textEditProc(dlg->_oldHashResultProc, hwnd, message, wParam, lParam)); return (run_textEditProc(dlg->_oldHashResultProc, hwnd, message, wParam, lParam));
}; };
private : private :

Loading…
Cancel
Save