summaryrefslogtreecommitdiff
path: root/alf/alf.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'alf/alf.cpp')
-rw-r--r--alf/alf.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/alf/alf.cpp b/alf/alf.cpp
index b711085..36e17ac 100644
--- a/alf/alf.cpp
+++ b/alf/alf.cpp
@@ -360,6 +360,20 @@ ALF_DefWindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
return 0;
}
+ if (msg == WM_COMMAND) {
+ HWND source = (HWND)lparam;
+ WORD code = HIWORD(wparam);
+ WORD id = LOWORD(wparam);
+ LRESULT ret = 0;
+ if (source != 0)
+ ret = SendMessage(source, 0x2000 + WM_COMMAND, wparam, lparam);
+
+ if (ret == 0 && priv->vtbl->command)
+ ret = priv->vtbl->command(priv->closure, hwnd, code, id, source);
+
+ return ret;
+ }
+
if (msg == WM_ACTIVATE) {
if (!HIWORD(wparam)) { // if !minimized
if (LOWORD(wparam)) {
@@ -706,3 +720,42 @@ ALF_WidgetHwndById(HWND win, WORD id)
return closure.result;
}
+void
+ALF_SetText(HWND hwnd, const TCHAR *text)
+{
+ SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM)text);
+}
+
+void
+ALF_SetWidgetText(HWND parent, WORD id, const TCHAR *text)
+{
+ HWND h = ALF_WidgetHwndById(parent, id);
+ if (h)
+ ALF_SetText(h, text);
+}
+
+TCHAR * // free with HeapFree
+ALF_Text(HWND hwnd)
+{
+ int len = (int)SendMessage(hwnd, WM_GETTEXTLENGTH, 0, 0);
+ if (len > 0) {
+ TCHAR *buf = (TCHAR*)HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY, (len + 1)*sizeof(TCHAR));
+ if (SendMessage(hwnd, WM_GETTEXT, 0, (LPARAM)buf)) {
+ return buf;
+ } else {
+ HeapFree(GetProcessHeap(), 0, buf);
+ }
+ }
+
+ return NULL;
+}
+
+TCHAR * // free with HeapFree
+ALF_WidgetText(HWND parent, WORD id)
+{
+ HWND h = ALF_WidgetHwndById(parent, id);
+ if (h)
+ return ALF_Text(h);
+
+ return NULL;
+}