summaryrefslogtreecommitdiff
path: root/alf
diff options
context:
space:
mode:
authorJonas Kümmerlin <jonas@kuemmerlin.eu>2019-01-11 16:17:48 +0100
committerJonas Kümmerlin <jonas@kuemmerlin.eu>2019-01-11 16:17:48 +0100
commit3ecdf8ec97ee6a0b7453f7b4d0c58a84916cfab0 (patch)
tree1e113eb67605db65900951c5d55cd8102bf0f178 /alf
parent9279dd93c3997a51b227d3380b4da659fcbdff96 (diff)
add pretranslate message hook
Diffstat (limited to 'alf')
-rw-r--r--alf/alf.cpp26
-rw-r--r--alf/alf.h5
-rw-r--r--alf/alfpriv.h3
3 files changed, 33 insertions, 1 deletions
diff --git a/alf/alf.cpp b/alf/alf.cpp
index 6f8d28a..57059d2 100644
--- a/alf/alf.cpp
+++ b/alf/alf.cpp
@@ -154,6 +154,10 @@ ALF_DefWindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
return 0;
}
+ if (msg == ALF_WM_PRETRANSLATEMSG) {
+ return (LRESULT)ALF_PreTranslateMessagePriv(hwnd, priv, (MSG *)lparam);
+ }
+
if (msg == WM_COMMAND) {
HWND source = (HWND)lparam;
WORD code = HIWORD(wparam);
@@ -453,6 +457,26 @@ ALF_ApplicationFromWindow(HWND hwnd)
return (ALFAPP)SendMessage(hwnd, ALF_WM_GETAPPLICATION, 0, 0);
}
+BOOL
+ALF_PreTranslateMessage(HWND hwnd, MSG *message)
+{
+ return (BOOL)SendMessage(hwnd, ALF_WM_PRETRANSLATEMSG, 0, (LPARAM)message);
+}
+
+BOOL
+ALF_PreTranslateMessagePriv(HWND win, ALFWindowPriv *priv, MSG *message)
+{
+ BOOL ret = FALSE;
+
+ if (priv->vtbl->pretranslatemessage)
+ ret = priv->vtbl->pretranslatemessage(priv->closure, win, message);
+
+ if (!ret)
+ ret = IsDialogMessage(win, message);
+
+ return ret;
+}
+
int
ALF_ShowModal(HWND win)
{
@@ -467,7 +491,7 @@ ALF_ShowModal(HWND win)
// TODO: call application message hooks
// TODO: call preprocess message hook
- if (!IsDialogMessage(win, &msg)) {
+ if (!ALF_PreTranslateMessage(win, &msg)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
diff --git a/alf/alf.h b/alf/alf.h
index 0c32a20..38e3b0b 100644
--- a/alf/alf.h
+++ b/alf/alf.h
@@ -22,6 +22,7 @@ typedef struct {
LRESULT (*message)(void * /*closure*/, HWND, UINT, WPARAM, LPARAM);
LRESULT (*command)(void * /*closure*/, HWND /*window*/, WORD /*notificationcode*/, WORD /*sourceid*/, HWND /*control*/);
LRESULT (*notify)(void * /*closure*/, HWND /*window*/, WPARAM /*sourceid*/, NMHDR *);
+ BOOL (*pretranslatemessage)(void * /*closure*/, HWND /*window*/, MSG * /*message*/);
} ALFWindowVTable;
// layout flags
@@ -53,6 +54,7 @@ typedef struct {
#define ALF_WM_SETLAYOUTPARAMS (ALF_WM__BASE + 14)
#define ALF_WM_GETWIDGETATPOS (ALF_WM__BASE + 15)
#define ALF_WM_APPLYFONTS (ALF_WM__BASE + 16)
+#define ALF_WM_PRETRANSLATEMSG (ALF_WM__BASE + 17)
typedef struct {
const TCHAR *className;
@@ -102,6 +104,9 @@ ALF_DestroyWindow(HWND win);
ALFAPP
ALF_ApplicationFromWindow(HWND hwnd);
+BOOL
+ALF_PreTranslateMessage(HWND hwnd, MSG *message);
+
int
ALF_CentipointsToPixels(HWND win, int cptValue);
diff --git a/alf/alfpriv.h b/alf/alfpriv.h
index 775d421..61d7b39 100644
--- a/alf/alfpriv.h
+++ b/alf/alfpriv.h
@@ -44,6 +44,9 @@ ALF_UpdateFontsPriv(HWND hwnd, ALFWindowPriv *priv);
void
ALF_ApplyFontsPriv(HWND win, ALFWindowPriv *priv);
+BOOL
+ALF_PreTranslateMessagePriv(HWND win, ALFWindowPriv *priv, MSG *message);
+
void
ALF_RegisterComboClass(ALFAPP app);