From 3b52095ab08fdb749d454698721300351eb49ffa Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Tue, 7 Apr 2015 04:12:03 -0400 Subject: [PATCH] Added uiControlHandle() and fixed other uiButton issues. --- new/button_windows.c | 6 +++++- new/main_windows.c | 6 ++++++ new/ui.h | 1 + new/window_windows.c | 3 +++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/new/button_windows.c b/new/button_windows.c index a66490d..d7921ad 100644 --- a/new/button_windows.c +++ b/new/button_windows.c @@ -38,6 +38,7 @@ uiControl *uiNewButton(const char *text) struct button *b; uiWindowsNewControlParams p; WCHAR *wtext; + HWND hwnd; b = uiNew(struct button); @@ -52,9 +53,12 @@ uiControl *uiNewButton(const char *text) p.data = b; b->c = uiWindowsNewControl(&p); + hwnd = (HWND) uiControlHandle(b->c); wtext = toUTF16(text); - // TODO set text + if (SetWindowTextW(hwnd, wtext) == 0) + logLastError("error setting button text in uiNewButton()"); uiFree(wtext); + SendMessageW(hwnd, WM_SETFONT, (WPARAM) hMessageFont, (LPARAM) TRUE); b->onClicked = defaultOnClicked; diff --git a/new/main_windows.c b/new/main_windows.c index bd973b7..9c8132a 100644 --- a/new/main_windows.c +++ b/new/main_windows.c @@ -54,3 +54,9 @@ void uiQuit(void) { PostQuitMessage(0); } + +// TODO move somewhere else +uintptr_t uiControlHandle(uiControl *c) +{ + return (*(c->handle))(c); +} diff --git a/new/ui.h b/new/ui.h index cc10300..b698c85 100644 --- a/new/ui.h +++ b/new/ui.h @@ -16,6 +16,7 @@ void uiMain(void); void uiQuit(void); typedef struct uiControl uiControl; +uintptr_t uiControlHandle(uiControl *); typedef struct uiWindow uiWindow; uiWindow *uiNewWindow(char *, int, int); diff --git a/new/window_windows.c b/new/window_windows.c index 3f2abb2..b4d0163 100644 --- a/new/window_windows.c +++ b/new/window_windows.c @@ -1,6 +1,9 @@ // 6 april 2015 #include "uipriv_windows.h" +// TODOs: +// - child not set to fit initial size + struct uiWindow { HWND hwnd; uiControl *child;