diff options
| author | Jonas Kümmerlin <jonas@kuemmerlin.eu> | 2019-01-02 16:56:43 +0100 |
|---|---|---|
| committer | Jonas Kümmerlin <jonas@kuemmerlin.eu> | 2019-01-02 16:56:43 +0100 |
| commit | 89d174ab47af8a31ba316e03e36883e6924171bf (patch) | |
| tree | 25b21619207cda9a81885b4b17e2933a905453dd /alf/alf.cpp | |
| parent | d19993c9d4891978c0b593eced6376d17aa1ffec (diff) | |
make combobox implementation more complete
Diffstat (limited to 'alf/alf.cpp')
| -rw-r--r-- | alf/alf.cpp | 53 |
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; +} |
